public class Statics extends Object
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" | +---------------+
Modifier and Type | Field and Description |
---|---|
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).
|
Constructor and Description |
---|
Statics() |
Modifier and Type | Method and Description |
---|---|
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() |
static int |
getLowestInUseSlot() |
static int |
getNumberOfNumericSlots() |
static int |
getNumberOfReferenceSlots() |
static int |
getReferenceSlotSize() |
static Address |
getSlotContentsAsAddress(Offset offset) |
static int |
getSlotContentsAsInt(Offset offset) |
static long |
getSlotContentsAsLong(Offset offset) |
static Object |
getSlotContentsAsObject(Offset offset) |
static Address |
getSlots() |
static int[] |
getSlotsAsIntArray() |
static int |
getTotalNumberOfSlots() |
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,
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 TIB.
|
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.
|
private static final int numNumericSlots
private static final int numReferenceSlots
private static final int[] slots
private static Object[] objectSlots
public static final int middleOfTable
private static volatile int nextNumericSlot
private static volatile int numericSlotHole
private static volatile int nextReferenceSlot
private static final BitVector numericFieldVector
private static final ImmutableEntryIdentityHashMapRVM<Object,Integer> objectLiterals
public Statics()
public static Offset slotAsOffset(int slot)
slot
- the JTOC slot indexpublic static int offsetAsSlot(Offset offset)
offset
- the JTOC offsetpublic static int getLowestInUseSlot()
public static int getHighestInUseSlot()
public static int findOrCreateIntSizeLiteral(int literal)
literal
- the literal value to find or createpublic static int findOrCreateLongSizeLiteral(long literal)
literal
- the literal value to find or createpublic static int findOrCreate16ByteSizeLiteral(long literal_high, long literal_low)
literal_high
- the high part of the literal value to find or createliteral_low
- the low part of the literal value to find or createpublic static int findOrCreateObjectLiteral(Object literal)
literal
- valuepublic static int findObjectLiteral(Object literal)
literal
- valuepublic static void markAsNumericLiteral(int size, Offset fieldOffset)
size
- the slot's sizefieldOffset
- the field's offset in the JTOCpublic static void markAsReferenceLiteral(Offset fieldOffset)
fieldOffset
- the field's offset in the JTOCpublic static Offset allocateNumericSlot(int size, boolean field)
size
- of slotfield
- is the slot for a fieldpublic static Offset allocateReferenceSlot(boolean field)
field
- is the slot for a fieldprivate static void enlargeTable()
public static int getNumberOfNumericSlots()
public static int getNumberOfReferenceSlots()
public static int getTotalNumberOfSlots()
public static boolean isReference(int slot)
slot
- obtained from offsetAsSlot()true
--> slot contains a referencepublic static boolean isIntSizeLiteral(int slot)
slot
- obtained from offsetAsSlot()true
--> slot contains a referencepublic static boolean isLongSizeLiteral(int slot)
slot
- obtained from offsetAsSlot()true
--> slot contains a referencepublic static boolean isReferenceLiteral(int slot)
slot
- obtained from offsetAsSlot()true
--> slot contains a referencepublic static int getReferenceSlotSize()
public static int[] getSlotsAsIntArray()
public static int getSlotContentsAsInt(Offset offset)
offset
- the slot's offset in the JTOCpublic static long getSlotContentsAsLong(Offset offset)
offset
- the slot's offsetpublic static Object getSlotContentsAsObject(Offset offset)
offset
- the slot's offsetpublic static Address getSlotContentsAsAddress(Offset offset)
offset
- the slot's offsetpublic static void setSlotContents(Offset offset, int value)
offset
- the slot's offsetvalue
- new value for the slotpublic static void setSlotContents(Offset offset, float value)
offset
- the slot's offsetvalue
- new value for the slotpublic static void setSlotContents(Offset offset, double value)
offset
- the slot's offsetvalue
- new value for the slotpublic static void setSlotContents(Offset offset, long value)
offset
- the slot's offsetvalue
- new value for the slotpublic static void setSlotContents(Offset offset, Object object)
offset
- the slot's offsetobject
- new value for the slotpublic static void setSlotContents(Offset offset, CodeArray code)
offset
- the slot's offsetcode
- new value for the slotpublic static void setSlotContents(Offset offset, TIB tib)
offset
- the slot's offsettib
- new value for the slotpublic static void setSlotContents(Offset offset, Word word)
offset
- the slot's offsetword
- new value for the slotpublic static void setSlotContents(Offset offset, Address value)
offset
- the slot's offsetvalue
- new value for the slotpublic static void setSlotContents(Offset offset, Extent value)
offset
- the slot's offsetvalue
- new value for the slotpublic static void setSlotContents(Offset offset, Offset value)
offset
- the slot's offsetvalue
- new value for the slotpublic static Object bootImageInstantiationFinished()
public static void bootImageReportGeneration(Object slots)
slots
- object slots to restore