org.jikesrvm.runtime
Class Statics

java.lang.Object
  extended by org.jikesrvm.runtime.Statics
All Implemented Interfaces:
Constants, HeapLayoutConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public class Statics
extends Object
implements Constants

The static fields and methods comprising a running virtual machine image.

These fields, methods and literal constants form the "root set" of all the objects in the running virtual machine. They are stored in an array where the middle element is always pointed to by the virtual machine's "table of contents" (JTOC) register. The slots of this array hold either primitives (int, long, float, double), object pointers, or array pointers. To enable the garbage collector to differentiate between reference and non-reference values, reference values are indexed positively and numeric values negatively with respect to the middle of the table.

Consider the following declarations:

      class A { static int    i = 123;    }
      class B { static String s = "abc";  }
      class C { static double d = 4.56;   }
      class D { static void m() {} }
 

Here's a picture of what the corresponding JTOC would look like in memory:

                     +---------------+
                     |     ...       |
                     +---------------+
 field            -6 |   C.d (hi)    |
                     +---------------+
 field            -5 |   C.d (lo)    |
                     +---------------+
 literal          -4 |  4.56 (hi)    |
                     +---------------+
 literal          -3 |  4.56 (lo)    |
                     +---------------+
 field            -2 |     A.i       |
                     +---------------+
 literal          -1 |     123       |
                     +---------------+       +---------------+
 [jtoc register]-> 0:|      0        |       |   (header)    |
                     +---------------+       +---------------+
 literal           1:|  (objref)   --------->|    "abc"      |
                     +---------------+       +---------------+
 field             2:|     B.s       |
                     +---------------+       +---------------+
                   3:|  (coderef)  ------+   |   (header)    |
                     +---------------+   |   +---------------+
                     |     ...       |   +-->|  machine code |
                     +---------------+       |    for "m"    |
                                             +---------------+
 


Field Summary
static int middleOfTable
          The logical middle of the table, references are slots above this and numeric values below this.
private static int nextNumericSlot
          Next available numeric slot number
private static int nextReferenceSlot
          Next available reference slot number
private static BitVector numericFieldVector
          Bit vector indicating whether a numeric slot is a field (true) or a literal (false).
private static int numericSlotHole
          Numeric slot hole.
private static int numNumericSlots
          How many 32bit slots do we want in the JTOC to hold numeric (non-reference) values?
private static int numReferenceSlots
          How many reference-sized slots do we want in the JTOC to hold reference values?
private static ImmutableEntryIdentityHashMapRVM<Object,Integer> objectLiterals
          Map of objects to their literal offsets
private static Object[] objectSlots
          Object version of the slots used during boot image creation and destroyed shortly after.
private static int[] slots
          Static data values (pointed to by JTOC register).
 
Fields inherited from interface org.jikesrvm.Constants
NOT_REACHED, REFLECTION_FPRS_BITS, REFLECTION_FPRS_MASK, REFLECTION_GPRS_BITS, REFLECTION_GPRS_MASK
 
Fields inherited from interface org.jikesrvm.objectmodel.ThinLockConstants
TL_DEDICATED_U16_OFFSET, TL_DEDICATED_U16_SHIFT, TL_LOCK_COUNT_MASK, TL_LOCK_COUNT_SHIFT, TL_LOCK_COUNT_UNIT, TL_LOCK_ID_MASK, TL_LOCK_ID_SHIFT, TL_NUM_BITS_RC, TL_NUM_BITS_STAT, TL_NUM_BITS_TID, TL_STAT_BIASABLE, TL_STAT_FAT, TL_STAT_MASK, TL_STAT_SHIFT, TL_STAT_THIN, TL_THREAD_ID_MASK, TL_THREAD_ID_SHIFT, TL_UNLOCK_MASK
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Constructor Summary
Statics()
           
 
Method Summary
static Offset allocateNumericSlot(int size, boolean field)
          Allocate a numeric slot in the JTOC.
static Offset allocateReferenceSlot(boolean field)
          Allocate a reference slot in the JTOC.
static Object bootImageInstantiationFinished()
          Inform Statics that boot image instantiation is over and that unnecessary data structures, for runtime, can be released.
static void bootImageReportGeneration(Object slots)
          After serializing Statics the boot image writer generates a report.
private static void enlargeTable()
          Grow the statics table
static int findObjectLiteral(Object literal)
          Find a slot in the JTOC with this object literal in else return 0
static int findOrCreate16ByteSizeLiteral(long literal_high, long literal_low)
          Find the given literal in the 16byte like literal map, if not found create a slot for the literal and place an entry in the map
static int findOrCreateIntSizeLiteral(int literal)
          Find the given literal in the int like literal map, if not found create a slot for the literal and place an entry in the map
static int findOrCreateLongSizeLiteral(long literal)
          Find the given literal in the long like literal map, if not found create a slot for the literal and place an entry in the map
static int findOrCreateObjectLiteral(Object literal)
          Find or allocate a slot in the JTOC for an object literal.
static int getHighestInUseSlot()
          Return the highest slot number in use
static int getLowestInUseSlot()
          Return the lowest slot number in use
static int getNumberOfNumericSlots()
          Fetch number of numeric JTOC slots currently allocated.
static int getNumberOfReferenceSlots()
          Fetch number of reference JTOC slots currently allocated.
static int getReferenceSlotSize()
          Get size occupied by a reference
static Address getSlotContentsAsAddress(Offset offset)
          Fetch contents of a slot, as an Address.
static int getSlotContentsAsInt(Offset offset)
          Fetch contents of a slot, as an integer
static long getSlotContentsAsLong(Offset offset)
          Fetch contents of a slot-pair, as a long integer.
static Object getSlotContentsAsObject(Offset offset)
          Fetch contents of a slot, as an object.
static Address getSlots()
          Fetch JTOC object (for JNI environment and GC).
static int[] getSlotsAsIntArray()
          Fetch JTOC object (for JNI environment and GC).
static int getTotalNumberOfSlots()
          Fetch total number of slots comprising the JTOC.
static boolean isIntSizeLiteral(int slot)
          Does specified JTOC slot contain an int sized literal?
static boolean isLongSizeLiteral(int slot)
          Does specified JTOC slot contain a long sized literal?
static boolean isReference(int slot)
          Does specified JTOC slot contain a reference?
static boolean isReferenceLiteral(int slot)
          Does specified JTOC slot contain a reference literal?
static void markAsNumericLiteral(int size, Offset fieldOffset)
          Marks a slot that was previously a field as being a literal as its value is final.
static void markAsReferenceLiteral(Offset fieldOffset)
          Marks a slot that was previously a field as being a literal as its value is final.
static int offsetAsSlot(Offset offset)
          Conversion from JTOC offset to JTOC slot index.
static void setSlotContents(Offset offset, Address value)
          Set contents of a slot, as a Address
static void setSlotContents(Offset offset, ArchitectureSpecific.CodeArray code)
          Set contents of a slot, as a CodeArray.
static void setSlotContents(Offset offset, double value)
          Set contents of a slot, as a double.
static void setSlotContents(Offset offset, Extent value)
          Set contents of a slot, as a Extent
static void setSlotContents(Offset offset, float value)
          Set contents of a slot, as an float.
static void setSlotContents(Offset offset, int value)
          Set contents of a slot, as an integer.
static void setSlotContents(Offset offset, long value)
          Set contents of a slot, as a long integer.
static void setSlotContents(Offset offset, Object object)
          Set contents of a slot, as an object.
static void setSlotContents(Offset offset, Offset value)
          Set contents of a slot, as a Offset
static void setSlotContents(Offset offset, TIB tib)
          Set contents of a slot, as a CodeArray.
static void setSlotContents(Offset offset, Word word)
          Set contents of a slot, as a Word.
static Offset slotAsOffset(int slot)
          Conversion from JTOC slot index to JTOC offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numNumericSlots

private static final int numNumericSlots
How many 32bit slots do we want in the JTOC to hold numeric (non-reference) values?

See Also:
Constant Field Values

numReferenceSlots

private static final int numReferenceSlots
How many reference-sized slots do we want in the JTOC to hold reference values?

See Also:
Constant Field Values

slots

private static final int[] slots
Static data values (pointed to by JTOC register). This is currently fixed-size, although at one point the system's plans called for making it dynamically growable. We could also make it non-contiguous.


objectSlots

private static Object[] objectSlots
Object version of the slots used during boot image creation and destroyed shortly after. This is required to support conversion of a slot address to its associated object during boot image creation.


middleOfTable

public static final int middleOfTable
The logical middle of the table, references are slots above this and numeric values below this. The JTOC points to the middle of the table.

See Also:
Constant Field Values

nextNumericSlot

private static volatile int nextNumericSlot
Next available numeric slot number


numericSlotHole

private static volatile int numericSlotHole
Numeric slot hole. Holes are created to align 8byte values. We allocate into a hole rather than consume another numeric slot. The value of middleOfTable indicates the slot isn't in use.


nextReferenceSlot

private static volatile int nextReferenceSlot
Next available reference slot number


numericFieldVector

private static final BitVector numericFieldVector
Bit vector indicating whether a numeric slot is a field (true) or a literal (false).


objectLiterals

private static final ImmutableEntryIdentityHashMapRVM<Object,Integer> objectLiterals
Map of objects to their literal offsets

Constructor Detail

Statics

public Statics()
Method Detail

slotAsOffset

public static Offset slotAsOffset(int slot)
Conversion from JTOC slot index to JTOC offset.


offsetAsSlot

public static int offsetAsSlot(Offset offset)
Conversion from JTOC offset to JTOC slot index.


getLowestInUseSlot

public static int getLowestInUseSlot()
Return the lowest slot number in use


getHighestInUseSlot

public static int getHighestInUseSlot()
Return the highest slot number in use


findOrCreateIntSizeLiteral

public static int findOrCreateIntSizeLiteral(int literal)
Find the given literal in the int like literal map, if not found create a slot for the literal and place an entry in the map

Parameters:
literal - the literal value to find or create
Returns:
the offset in the JTOC of the literal

findOrCreateLongSizeLiteral

public static int findOrCreateLongSizeLiteral(long literal)
Find the given literal in the long like literal map, if not found create a slot for the literal and place an entry in the map

Parameters:
literal - the literal value to find or create
Returns:
the offset in the JTOC of the literal

findOrCreate16ByteSizeLiteral

public static int findOrCreate16ByteSizeLiteral(long literal_high,
                                                long literal_low)
Find the given literal in the 16byte like literal map, if not found create a slot for the literal and place an entry in the map

Parameters:
literal_high - the high part of the literal value to find or create
literal_low - the low part of the literal value to find or create
Returns:
the offset in the JTOC of the literal

findOrCreateObjectLiteral

public static int findOrCreateObjectLiteral(Object literal)
Find or allocate a slot in the JTOC for an object literal.

Parameters:
literal - value
Returns:
offset of slot that was allocated Side effect: literal value is stored into JTOC

findObjectLiteral

public static int findObjectLiteral(Object literal)
Find a slot in the JTOC with this object literal in else return 0

Parameters:
literal - value
Returns:
offset containing literal or 0

markAsNumericLiteral

public static void markAsNumericLiteral(int size,
                                        Offset fieldOffset)
Marks a slot that was previously a field as being a literal as its value is final.


markAsReferenceLiteral

public static void markAsReferenceLiteral(Offset fieldOffset)
Marks a slot that was previously a field as being a literal as its value is final.


allocateNumericSlot

public static Offset allocateNumericSlot(int size,
                                         boolean field)
Allocate a numeric slot in the JTOC.

Parameters:
size - of slot
field - is the slot for a field
Returns:
offset of slot that was allocated as int (two slots are allocated for longs and doubles)

allocateReferenceSlot

public static Offset allocateReferenceSlot(boolean field)
Allocate a reference slot in the JTOC.

Parameters:
field - is the slot for a field
Returns:
offset of slot that was allocated as int (two slots are allocated on 64bit architectures)

enlargeTable

private static void enlargeTable()
Grow the statics table


getNumberOfNumericSlots

public static int getNumberOfNumericSlots()
Fetch number of numeric JTOC slots currently allocated.


getNumberOfReferenceSlots

public static int getNumberOfReferenceSlots()
Fetch number of reference JTOC slots currently allocated.


getTotalNumberOfSlots

public static int getTotalNumberOfSlots()
Fetch total number of slots comprising the JTOC.


isReference

public static boolean isReference(int slot)
Does specified JTOC slot contain a reference?

Parameters:
slot - obtained from offsetAsSlot()
Returns:
true --> slot contains a reference

isIntSizeLiteral

public static boolean isIntSizeLiteral(int slot)
Does specified JTOC slot contain an int sized literal?

Parameters:
slot - obtained from offsetAsSlot()
Returns:
true --> slot contains a reference

isLongSizeLiteral

public static boolean isLongSizeLiteral(int slot)
Does specified JTOC slot contain a long sized literal?

Parameters:
slot - obtained from offsetAsSlot()
Returns:
true --> slot contains a reference

isReferenceLiteral

public static boolean isReferenceLiteral(int slot)
Does specified JTOC slot contain a reference literal?

Parameters:
slot - obtained from offsetAsSlot()
Returns:
true --> slot contains a reference

getReferenceSlotSize

public static int getReferenceSlotSize()
Get size occupied by a reference


getSlots

public static Address getSlots()
Fetch JTOC object (for JNI environment and GC).


getSlotsAsIntArray

public static int[] getSlotsAsIntArray()
Fetch JTOC object (for JNI environment and GC).


getSlotContentsAsInt

public static int getSlotContentsAsInt(Offset offset)
Fetch contents of a slot, as an integer


getSlotContentsAsLong

public static long getSlotContentsAsLong(Offset offset)
Fetch contents of a slot-pair, as a long integer.


getSlotContentsAsObject

public static Object getSlotContentsAsObject(Offset offset)
Fetch contents of a slot, as an object.


getSlotContentsAsAddress

public static Address getSlotContentsAsAddress(Offset offset)
Fetch contents of a slot, as an Address.


setSlotContents

public static void setSlotContents(Offset offset,
                                   int value)
Set contents of a slot, as an integer.


setSlotContents

public static void setSlotContents(Offset offset,
                                   float value)
Set contents of a slot, as an float.


setSlotContents

public static void setSlotContents(Offset offset,
                                   double value)
Set contents of a slot, as a double.


setSlotContents

public static void setSlotContents(Offset offset,
                                   long value)
Set contents of a slot, as a long integer.


setSlotContents

public static void setSlotContents(Offset offset,
                                   Object object)
Set contents of a slot, as an object.


setSlotContents

public static void setSlotContents(Offset offset,
                                   ArchitectureSpecific.CodeArray code)
Set contents of a slot, as a CodeArray.


setSlotContents

public static void setSlotContents(Offset offset,
                                   TIB tib)
Set contents of a slot, as a CodeArray.


setSlotContents

public static void setSlotContents(Offset offset,
                                   Word word)
Set contents of a slot, as a Word.


setSlotContents

public static void setSlotContents(Offset offset,
                                   Address value)
Set contents of a slot, as a Address


setSlotContents

public static void setSlotContents(Offset offset,
                                   Extent value)
Set contents of a slot, as a Extent


setSlotContents

public static void setSlotContents(Offset offset,
                                   Offset value)
Set contents of a slot, as a Offset


bootImageInstantiationFinished

public static Object bootImageInstantiationFinished()
Inform Statics that boot image instantiation is over and that unnecessary data structures, for runtime, can be released.

Returns:
information that may later be restored to help generate the boot image report

bootImageReportGeneration

public static void bootImageReportGeneration(Object slots)
After serializing Statics the boot image writer generates a report. This method is called to restore data lost by the call to bootImageInstantiationFinished.

Parameters:
slots - object slots to restore