The Artima Developer Community
Sponsored Link

Java Community News
Supporting Fixnums in the JVM

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Supporting Fixnums in the JVM Posted: Mar 15, 2008 7:35 AM
Reply to this message Reply
Summary
John Rose, a lead designer of Sun's HotSpot JVM and project lead of the java.net Multi-Language JVM project, discusses supporting headerless objects in the JVM, illustrating the key concepts with Ruby's Fixnum type.
Advertisement

A key goal of the Multi-Language JVM project on java.net is to allow experimentation with new VM implementation techniques, including new types of JVM optimizations. As the JVM supports an increasing number of dynamic languages, the representation of dynamic objects becomes an important concern for performance.

John Rose, a lead on the Multi-Language JVM project, and a key architect of Sun's HotSpot JVM, describes in a recent article, Fixnums in the VM, the ins and outs of supporting dynamic integer types, such as Ruby's Fixnum, on the Java VM:

In many language-specific systems, integers of 20-30 bits or less are compressed into pseudo-pointers. Lisp and Ruby call them fixnums, while Smalltalk uses the name SmallInteger. Some languages, like Emacs Lisp, simply call them “integer” and do not allow overflow. Most dynamic languages check for arithmetic overflow beyond the 20-30 bits, and either signal an error or provide a more or less seamless transition from fixnum to bignum, i.e., from a machine word subrange to a multiple precision array-based representation.

In highlighting how Fixnums can be supported on the VM, Rose describes the more general concept involved in dynamic object types, headerless objects:

Dynamic languages typically perform arithmetic using dynamically typed references to boxed numbers. Normally (at least in a JVM) a dynamically typed reference is a pointer to an object in the heap, whose header in turn contains the required dynamic type information.

But language-specific implementations often use pseudo-pointers to represent a commonly used subset of numbers, with the actual bits of the pseudo-pointer carrying a value field “payload”. Also, because their relaxed typing encourages data structure reuse, dynamic languages typically feature a few small but ever-present types like Lisp’s cons cell which are overwhelmingly common in the heap. Again, language specific implementations have historically provided “headerless” representations for these, in which the fields are stored in the heap but are not accompanied by a header...

The JVM can support fixnums and other headerless objects for the sake of these languages, and even for Java. The idea is to make ordinary object pointers (sometimes called oops) coexist with more specialized formats for headerless objects, which we will call iops and xops.

The techniques are mature and well-known, and the overheads (of extra tag checking before pointer usage) can be controlled by optimizations already used widely in JVMs. In particular, the Hotspot JVM could cleanly represent fixnums and other immediate data types by modifying extending its oop type.

The rest of Rose's article describes implementation issues of supporting headerless objects in the Multi-Language JVM project, a feature that may find its way to the mainstream Java VM in the future.

What do you think of the current state of dynamic language performance on the JVM?

Topic: VisualVM Beta Released Previous Topic   Next Topic Topic: Damien Katz Critiques Erlang

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use