org.jikesrvm.runtime
Class Magic

java.lang.Object
  extended by org.jikesrvm.runtime.Magic

public final class Magic
extends Object

Magic methods for accessing raw machine memory, registers, and operating system calls.

These are "inline assembler functions" that cannot be implemented in Java code. Their names are recognized by RVM's compilers and cause inline machine code to be generated instead of actual method calls.


Field Summary
private static ObjectAddressRemapper objectAddressRemapper
           
 
Constructor Summary
Magic()
           
 
Method Summary
static byte[] addressAsByteArray(Address byte_array)
          Recast.
static Object addressAsObject(Address address)
          Cast bits.
static TIB addressAsTIB(Address address)
          Cast bits.
static boolean attemptAddress(Object object, Offset offset, Address oldValue, Address newValue)
          Sets the memory at (object + offset) to newValue if its contents are oldValue.
static boolean attemptInt(Object object, Offset offset, int oldValue, int newValue)
          Sets the memory at (object + offset) to newValue if its contents are oldValue.
static boolean attemptLong(Object object, Offset offset, long oldValue, long newValue)
          Sets the memory at (object + offset) to newValue if its contents are oldValue.
static boolean attemptObject(Object object, Offset offset, Object oldValue, Object newValue)
          Sets the memory at (object + offset) to newValue if its contents are oldValue.
static boolean attemptWord(Object object, Offset offset, Word oldValue, Word newValue)
          Sets the memory at (object + offset) to newValue if its contents are oldValue.
static int bootImageIdentityHashCode(Object object)
          Certain objects aren't replicated in the boot image to save space.
static
<T> T
bootImageIntern(T object)
          Certain objects aren't replicated in the boot image to save space.
static Object codeArrayAsObject(ArchitectureSpecific.CodeArray code)
          Cast bits of code array into an object Note: for use by Statics when assigning slots to static method pointers
static long doubleAsLongBits(double number)
          Cast bits.
static void dynamicBridgeTo(ArchitectureSpecific.CodeArray instructions)
          Transfer execution to target of a dynamic bridge method.
static void fence()
          A strong memory fence, used to enforce StoreLoad in the JMM.
static int floatAsIntBits(float number)
          Cast bits.
static Address getAddressAtOffset(Object object, Offset offset)
          Get Address at arbitrary (byte) offset from object.
static Address getAddressAtOffset(Object object, Offset offset, int locationMetadata)
          Get Address at arbitrary (byte) offset from object.
static int getArrayLength(Object object)
          Get an array's length.
static byte getByteAtOffset(Object object, Offset offset)
          Get byte at arbitrary (byte) offset from object.
static Address getCallerFramePointer(Address fp)
          Get fp for parent frame
static char getCharAtOffset(Object object, Offset offset)
          Get char at arbitrary (byte) offset from object.
static int getCompiledMethodID(Address fp)
          Get Compiled Method ID for a frame
static double getDoubleAtOffset(Object object, Offset offset)
          Get double at arbitrary (byte) offset from object.
static RVMThread getESIAsThread()
          Get contents of ESI, as a RVMThread.
static Extent getExtentAtOffset(Object object, Offset offset)
          Get Extent at arbitrary (byte) offset from object.
static Extent getExtentAtOffset(Object object, Offset offset, int locationMetadata)
          Get Extent at arbitrary (byte) offset from object.
static float getFloatAtOffset(Object object, Offset offset)
          Get float at arbitrary (byte) offset from object.
static Address getFramePointer()
          Get contents of "stack frame pointer" register.
static int getInlineDepth()
          How deeply inlined is this method (0 means no inlining).
static int getIntAtOffset(Object object, Offset offset)
          Get int at arbitrary (byte) offset from object.
static Address getJTOC()
          Get contents of "JTOC" register
static long getLongAtOffset(Object object, Offset offset)
          Get long at arbitrary (byte) offset from object.
static Address getNextInstructionAddress(Address fp)
          Get next instruction address for a frame
static Object getObjectAtOffset(Object object, Offset offset)
          Get Object at arbitrary (byte) offset from object.
static Object getObjectAtOffset(Object object, Offset offset, int locationMetadata)
          Get Object at arbitrary (byte) offset from object.
static RVMType getObjectType(Object object)
          Get an object's type.
static Offset getOffsetAtOffset(Object object, Offset offset)
          Get Offset at arbitrary (byte) offset from object.
static Offset getOffsetAtOffset(Object object, Offset offset, int locationMetadata)
          Get Offset at arbitrary (byte) offset from object.
static Address getReturnAddress(Address fp)
          Get return address for a frame in the current thread
static Address getReturnAddress(Address fp, RVMThread thread)
          Get return address for a frame in a specific thread
static Address getReturnAddressLocation(Address fp)
          Get location containing return address for a frame
static Address getReturnAddressUnchecked(Address fp)
          Get return address for a frame in a case where the frame is known not to be a trampoline frame.
static short getShortAtOffset(Object object, Offset offset)
          Get short at arbitrary (byte) offset from object.
static RVMThread getThreadRegister()
          Get contents of "thread" register.
static TIB getTIBAtOffset(Object object, Offset offset)
          Get TIB at arbitrary (byte) offset from object.
static long getTimeBase()
          Read contents of hardware time base registers.
static Address getTocPointer()
          Get contents of "JTOC" register.
static byte getUnsignedByteAtOffset(Object object, Offset offset)
          Get unsigned byte at arbitrary (byte) offset from object.
static Word getWordAtOffset(Object object, Offset offset)
          Get Word at arbitrary (byte) offset from object.
static Word getWordAtOffset(Object object, Offset offset, int locationMetadata)
          Get Word at arbitrary (byte) offset from object.
static float intBitsAsFloat(int number)
          Cast bits.
static void invokeClassInitializer(ArchitectureSpecific.CodeArray clinit)
          Call <clinit> method with no argument list.
static double invokeMethodReturningDouble(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
          Call arbitrary method with argument list.
static float invokeMethodReturningFloat(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
          Call arbitrary method with argument list.
static int invokeMethodReturningInt(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
          Call arbitrary method with argument list.
static long invokeMethodReturningLong(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
          Call arbitrary method with argument list.
static Object invokeMethodReturningObject(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
          Call arbitrary method with argument list.
static void invokeMethodReturningVoid(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
          Call arbitrary method with argument list.
static boolean isConstantParameter(int index)
          Is the specified parameter constant (due to either inlining or specialization).
static void isync()
          Wait for all preceeding instructions to complete and discard any prefetched instructions on this processor.
static double longBitsAsDouble(long number)
          Cast bits.
static
<T> Address
objectAsAddress(T object)
          Cast bits.
static int[] objectAsIntArray(Object object)
          Cast object.
static short[] objectAsShortArray(Object object)
          Cast object.
static RVMThread objectAsThread(Object object)
          Cast object.
static RVMType objectAsType(Object object)
          Cast object.
static void pause()
          On IA32, emit a PAUSE instruction, to optimize spin-wait loops.
static Address prepareAddress(Object object, Offset offset)
          Get contents of (object + offset) and begin conditional critical section.
static int prepareInt(Object object, Offset offset)
          Get contents of (object + offset) and begin conditional critical section.
static long prepareLong(Object object, Offset offset)
          Get contents of (object + offset) and begin conditional critical section.
static Object prepareObject(Object object, Offset offset)
          Get contents of (object + offset) and begin conditional critical section.
static Word prepareWord(Object object, Offset offset)
          Get contents of (object + offset) and begin conditional critical section.
static void readCeiling()
          Disallow any reads to float above this point.
static void restoreHardwareExceptionState(ArchitectureSpecific.Registers registers)
          Resume execution with specified thread exception state.
static void returnToNewStack(Address fp)
          Return to caller of current method, resuming execution on a new stack that's a copy of the original.
static void saveThreadState(ArchitectureSpecific.Registers registers)
          Saves current thread state.
static void setAddressAtOffset(Object object, Offset offset, Address newvalue)
          Set Address at arbitrary (byte) offset from object.
static void setAddressAtOffset(Object object, Offset offset, Address newvalue, int locationMetadata)
          Set Address at arbitrary (byte) offset from object.
static void setBooleanAtOffset(Object object, Offset offset, boolean newvalue)
          Set boolean at arbitrary (byte) offset from object.
static void setBooleanAtOffset(Object object, Offset offset, boolean newvalue, int locationMetadata)
          Set boolean at arbitrary (byte) offset from object.
static void setByteAtOffset(Object object, Offset offset, byte newvalue)
          Set byte at arbitrary (byte) offset from object.
static void setByteAtOffset(Object object, Offset offset, byte newvalue, int locationMetadata)
          Set byte at arbitrary (byte) offset from object.
static void setCallerFramePointer(Address fp, Address newCallerFP)
          Set fp for parent frame
static void setCharAtOffset(Object object, Offset offset, char newvalue)
          Set char at arbitrary (byte) offset from object.
static void setCharAtOffset(Object object, Offset offset, char newvalue, int locationMetadata)
          Set char at arbitrary (byte) offset from object.
static void setCompiledMethodID(Address fp, int newCMID)
          Set the Compiled Method ID for a frame.
static void setDoubleAtOffset(Object object, Offset offset, double newvalue)
          Set double at arbitrary (byte) offset from object.
static void setDoubleAtOffset(Object object, Offset offset, double newvalue, int locationMetadata)
          Set double at arbitrary (byte) offset from object.
static void setESIAsThread(RVMThread p)
          Set contents of ESI to hold a reference to a thread object.
static void setExtentAtOffset(Object object, Offset offset, Extent newvalue)
          Set Extent at arbitrary (byte) offset from object.
static void setExtentAtOffset(Object object, Offset offset, Extent newvalue, int locationMetadata)
          Set Extent at arbitrary (byte) offset from object.
static void setFloatAtOffset(Object object, Offset offset, float newvalue)
          Set float at arbitrary (byte) offset from object.
static void setFloatAtOffset(Object object, Offset offset, float newvalue, int locationMetadata)
          Set float at arbitrary (byte) offset from object.
static void setIntAtOffset(Object object, Offset offset, int newvalue)
          Set int at arbitrary (byte) offset from object.
static void setIntAtOffset(Object object, Offset offset, int newvalue, int locationMetadata)
          Set int at arbitrary (byte) offset from object.
static void setLongAtOffset(Object object, Offset offset, long newvalue)
          Set long at arbitrary (byte) offset from object.
static void setLongAtOffset(Object object, Offset offset, long newvalue, int locationMetadata)
          Set long at arbitrary (byte) offset from object.
static void setObjectAddressRemapper(ObjectAddressRemapper x)
          Specify how to handle "objectAsAddress" and "addressAsObject" casts.
static void setObjectAtOffset(Object object, Offset offset, Object newvalue)
          Set Object at arbitrary (byte) offset from object.
static void setObjectAtOffset(Object object, Offset offset, Object newvalue, int locationMetadata)
          Set Object at arbitrary (byte) offset from object.
static void setOffsetAtOffset(Object object, Offset offset, Offset newvalue)
          Set Offset at arbitrary (byte) offset from object.
static void setOffsetAtOffset(Object object, Offset offset, Offset newvalue, int locationMetadata)
          Set Offset at arbitrary (byte) offset from object.
static void setReturnAddress(Address fp, Address v)
          Get return address for a frame
static void setShortAtOffset(Object object, Offset offset, short newvalue)
          Set short at arbitrary (byte) offset from object.
static void setShortAtOffset(Object object, Offset offset, short newvalue, int locationMetadata)
          Set short at arbitrary (byte) offset from object.
static void setThreadRegister(RVMThread p)
          Set contents of "thread" register.
static void setWordAtOffset(Object object, Offset offset, Word newvalue)
          Set Word at arbitrary (byte) offset from object.
static void setWordAtOffset(Object object, Offset offset, Word newvalue, int locationMetadata)
          Set Word at arbitrary (byte) offset from object.
static double sqrt(double value)
          A hardware SQRT instruction
static float sqrt(float value)
          A hardware SQRT instruction
static void sync()
          Wait for preceeding cache flush/invalidate instructions to complete on all processors.
static void threadSwitch(RVMThread currentThread, ArchitectureSpecific.Registers restoreRegs)
          Switch threads.
static Object tibAsObject(TIB tib)
          Cast bits of tib into an object Note: for use by Statics when assigning slots
static void writeFloor()
          Disallow any writes to sink below this point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectAddressRemapper

private static ObjectAddressRemapper objectAddressRemapper
Constructor Detail

Magic

public Magic()
Method Detail

getFramePointer

public static Address getFramePointer()
Get contents of "stack frame pointer" register.


getTocPointer

public static Address getTocPointer()
Get contents of "JTOC" register.


getJTOC

public static Address getJTOC()
Get contents of "JTOC" register


getThreadRegister

public static RVMThread getThreadRegister()
Get contents of "thread" register.


setThreadRegister

public static void setThreadRegister(RVMThread p)
Set contents of "thread" register.


getESIAsThread

public static RVMThread getESIAsThread()
Get contents of ESI, as a RVMThread. NOTE: IA-specific


setESIAsThread

public static void setESIAsThread(RVMThread p)
Set contents of ESI to hold a reference to a thread object. NOTE: IA-specific


getTimeBase

public static long getTimeBase()
Read contents of hardware time base registers.

Note: we think that 1 "tick" == 4 "machine cycles", but this seems to be undocumented and may vary across processor implementations.

Returns:
number of ticks (epoch undefined)

getCallerFramePointer

public static Address getCallerFramePointer(Address fp)
Get fp for parent frame

Parameters:
fp - frame pointer for child frame

setCallerFramePointer

public static void setCallerFramePointer(Address fp,
                                         Address newCallerFP)
Set fp for parent frame

Parameters:
fp - frame pointer for child frame
newCallerFP - new value for caller frame pointer

getCompiledMethodID

public static int getCompiledMethodID(Address fp)
Get Compiled Method ID for a frame

Parameters:
fp - its frame pointer).

setCompiledMethodID

public static void setCompiledMethodID(Address fp,
                                       int newCMID)
Set the Compiled Method ID for a frame.

Parameters:
fp - its frame pointer
newCMID - a new cmid for the frame

getNextInstructionAddress

public static Address getNextInstructionAddress(Address fp)
Get next instruction address for a frame

Parameters:
fp - its frame pointer.

getReturnAddressLocation

public static Address getReturnAddressLocation(Address fp)
Get location containing return address for a frame

Parameters:
fp - its frame pointer

getReturnAddressUnchecked

public static Address getReturnAddressUnchecked(Address fp)
Get return address for a frame in a case where the frame is known not to be a trampoline frame.

Parameters:
fp - its frame pointer

getReturnAddress

public static Address getReturnAddress(Address fp)
Get return address for a frame in the current thread

Parameters:
fp - its frame pointer

getReturnAddress

public static Address getReturnAddress(Address fp,
                                       RVMThread thread)
Get return address for a frame in a specific thread

Parameters:
fp - its frame pointer
thread - the thread whose stack is being examined

setReturnAddress

public static void setReturnAddress(Address fp,
                                    Address v)
Get return address for a frame

Parameters:
fp - its frame pointer

getUnsignedByteAtOffset

public static byte getUnsignedByteAtOffset(Object object,
                                           Offset offset)
Get unsigned byte at arbitrary (byte) offset from object. The most significant 24bits of the result will be 0.


getByteAtOffset

public static byte getByteAtOffset(Object object,
                                   Offset offset)
Get byte at arbitrary (byte) offset from object. The most significant 24bits of the result will be the same as the most significant bit in the byte.


getCharAtOffset

public static char getCharAtOffset(Object object,
                                   Offset offset)
Get char at arbitrary (byte) offset from object. The most significant 16bits will be 0.


getShortAtOffset

public static short getShortAtOffset(Object object,
                                     Offset offset)
Get short at arbitrary (byte) offset from object. The most significant 16bits will be the same as the most significant bit in the short.


getIntAtOffset

public static int getIntAtOffset(Object object,
                                 Offset offset)
Get int at arbitrary (byte) offset from object. Use getIntAtOffset(obj, ofs) instead of getMemoryInt(objectAsAddress(obj)+ofs)


getLongAtOffset

public static long getLongAtOffset(Object object,
                                   Offset offset)
Get long at arbitrary (byte) offset from object. Use getlongAtOffset(obj, ofs) instead of two getIntAtOffset


getFloatAtOffset

public static float getFloatAtOffset(Object object,
                                     Offset offset)
Get float at arbitrary (byte) offset from object.


getDoubleAtOffset

public static double getDoubleAtOffset(Object object,
                                       Offset offset)
Get double at arbitrary (byte) offset from object. Use getDoubleAtOffset(obj, ofs) instead of two getIntAtOffset


getObjectAtOffset

public static Object getObjectAtOffset(Object object,
                                       Offset offset)
Get Object at arbitrary (byte) offset from object. Use getObjectAtOffset(obj, ofs) instead of addressAsObject(getMemoryAddress(objectAsAddress(obj)+ofs))


getObjectAtOffset

public static Object getObjectAtOffset(Object object,
                                       Offset offset,
                                       int locationMetadata)
Get Object at arbitrary (byte) offset from object. Use getObjectAtOffset(obj, ofs) instead of addressAsObject(getMemoryAddress(objectAsAddress(obj)+ofs))


getWordAtOffset

public static Word getWordAtOffset(Object object,
                                   Offset offset)
Get Word at arbitrary (byte) offset from object. Use getWordAtOffset(obj, ofs) instead of getMemoryWord(objectAsAddress(obj)+ofs)


getWordAtOffset

public static Word getWordAtOffset(Object object,
                                   Offset offset,
                                   int locationMetadata)
Get Word at arbitrary (byte) offset from object.


getAddressAtOffset

public static Address getAddressAtOffset(Object object,
                                         Offset offset)
Get Address at arbitrary (byte) offset from object. Use getAddressAtOffset(obj, ofs) instead of getMemoryWord(objectAsAddress(obj)+ofs)


getAddressAtOffset

public static Address getAddressAtOffset(Object object,
                                         Offset offset,
                                         int locationMetadata)
Get Address at arbitrary (byte) offset from object.


getExtentAtOffset

public static Extent getExtentAtOffset(Object object,
                                       Offset offset)
Get Extent at arbitrary (byte) offset from object. Use getExtentAtOffset(obj, ofs) instead of getMemoryWord(objectAsAddress(obj)+ofs)


getExtentAtOffset

public static Extent getExtentAtOffset(Object object,
                                       Offset offset,
                                       int locationMetadata)
Get Extent at arbitrary (byte) offset from object.


getOffsetAtOffset

public static Offset getOffsetAtOffset(Object object,
                                       Offset offset)
Get Offset at arbitrary (byte) offset from object. Use getOffsetAtOffset(obj, ofs) instead of getMemoryWord(objectAsAddress(obj)+ofs)


getOffsetAtOffset

public static Offset getOffsetAtOffset(Object object,
                                       Offset offset,
                                       int locationMetadata)
Get Offset at arbitrary (byte) offset from object.


getTIBAtOffset

public static TIB getTIBAtOffset(Object object,
                                 Offset offset)
Get TIB at arbitrary (byte) offset from object. Use getTIBAtOffset(obj, ofs) instead of (TIB])addressAsObject(getMemoryAddr(objectAsAddress(obj)+ofs))


setBooleanAtOffset

public static void setBooleanAtOffset(Object object,
                                      Offset offset,
                                      boolean newvalue)
Set boolean at arbitrary (byte) offset from object.


setBooleanAtOffset

public static void setBooleanAtOffset(Object object,
                                      Offset offset,
                                      boolean newvalue,
                                      int locationMetadata)
Set boolean at arbitrary (byte) offset from object.


setByteAtOffset

public static void setByteAtOffset(Object object,
                                   Offset offset,
                                   byte newvalue)
Set byte at arbitrary (byte) offset from object.


setByteAtOffset

public static void setByteAtOffset(Object object,
                                   Offset offset,
                                   byte newvalue,
                                   int locationMetadata)
Set byte at arbitrary (byte) offset from object.


setCharAtOffset

public static void setCharAtOffset(Object object,
                                   Offset offset,
                                   char newvalue)
Set char at arbitrary (byte) offset from object.


setCharAtOffset

public static void setCharAtOffset(Object object,
                                   Offset offset,
                                   char newvalue,
                                   int locationMetadata)
Set char at arbitrary (byte) offset from object.


setShortAtOffset

public static void setShortAtOffset(Object object,
                                    Offset offset,
                                    short newvalue)
Set short at arbitrary (byte) offset from object.


setShortAtOffset

public static void setShortAtOffset(Object object,
                                    Offset offset,
                                    short newvalue,
                                    int locationMetadata)
Set short at arbitrary (byte) offset from object.


setIntAtOffset

public static void setIntAtOffset(Object object,
                                  Offset offset,
                                  int newvalue)
Set int at arbitrary (byte) offset from object. Use setIntAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setIntAtOffset

public static void setIntAtOffset(Object object,
                                  Offset offset,
                                  int newvalue,
                                  int locationMetadata)
Set int at arbitrary (byte) offset from object.


setLongAtOffset

public static void setLongAtOffset(Object object,
                                   Offset offset,
                                   long newvalue)
Set long at arbitrary (byte) offset from object. Use setlongAtOffset(obj, ofs) instead of two setIntAtOffset


setLongAtOffset

public static void setLongAtOffset(Object object,
                                   Offset offset,
                                   long newvalue,
                                   int locationMetadata)
Set long at arbitrary (byte) offset from object. Use setlongAtOffset(obj, ofs) instead of two setIntAtOffset


setFloatAtOffset

public static void setFloatAtOffset(Object object,
                                    Offset offset,
                                    float newvalue)
Set float at arbitrary (byte) offset from object.


setFloatAtOffset

public static void setFloatAtOffset(Object object,
                                    Offset offset,
                                    float newvalue,
                                    int locationMetadata)
Set float at arbitrary (byte) offset from object.


setDoubleAtOffset

public static void setDoubleAtOffset(Object object,
                                     Offset offset,
                                     double newvalue)
Set double at arbitrary (byte) offset from object. Use setDoubleAtOffset(obj, ofs) instead of two setIntAtOffset


setDoubleAtOffset

public static void setDoubleAtOffset(Object object,
                                     Offset offset,
                                     double newvalue,
                                     int locationMetadata)
Set double at arbitrary (byte) offset from object. Use setDoubleAtOffset(obj, ofs) instead of two setIntAtOffset


setWordAtOffset

public static void setWordAtOffset(Object object,
                                   Offset offset,
                                   Word newvalue)
Set Word at arbitrary (byte) offset from object. Use setWordAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setWordAtOffset

public static void setWordAtOffset(Object object,
                                   Offset offset,
                                   Word newvalue,
                                   int locationMetadata)
Set Word at arbitrary (byte) offset from object. Use setWordAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setAddressAtOffset

public static void setAddressAtOffset(Object object,
                                      Offset offset,
                                      Address newvalue)
Set Address at arbitrary (byte) offset from object. Use setAddressAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setAddressAtOffset

public static void setAddressAtOffset(Object object,
                                      Offset offset,
                                      Address newvalue,
                                      int locationMetadata)
Set Address at arbitrary (byte) offset from object. Use setAddressAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setExtentAtOffset

public static void setExtentAtOffset(Object object,
                                     Offset offset,
                                     Extent newvalue)
Set Extent at arbitrary (byte) offset from object. Use setExtentAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setExtentAtOffset

public static void setExtentAtOffset(Object object,
                                     Offset offset,
                                     Extent newvalue,
                                     int locationMetadata)
Set Extent at arbitrary (byte) offset from object. Use setExtenttOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setOffsetAtOffset

public static void setOffsetAtOffset(Object object,
                                     Offset offset,
                                     Offset newvalue)
Set Offset at arbitrary (byte) offset from object. Use setOffsetAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setOffsetAtOffset

public static void setOffsetAtOffset(Object object,
                                     Offset offset,
                                     Offset newvalue,
                                     int locationMetadata)
Set Offset at arbitrary (byte) offset from object. Use setOffsetAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, new)


setObjectAtOffset

public static void setObjectAtOffset(Object object,
                                     Offset offset,
                                     Object newvalue)
Set Object at arbitrary (byte) offset from object. Use setObjectAtOffset(obj, ofs, new) instead of setMemoryWord(objectAsAddress(obj)+ofs, objectAsAddress(new))


setObjectAtOffset

public static void setObjectAtOffset(Object object,
                                     Offset offset,
                                     Object newvalue,
                                     int locationMetadata)
Set Object at arbitrary (byte) offset from object.


prepareInt

public static int prepareInt(Object object,
                             Offset offset)
Get contents of (object + offset) and begin conditional critical section.


prepareObject

public static Object prepareObject(Object object,
                                   Offset offset)
Get contents of (object + offset) and begin conditional critical section.


prepareAddress

public static Address prepareAddress(Object object,
                                     Offset offset)
Get contents of (object + offset) and begin conditional critical section.


prepareWord

public static Word prepareWord(Object object,
                               Offset offset)
Get contents of (object + offset) and begin conditional critical section.


prepareLong

public static long prepareLong(Object object,
                               Offset offset)
Get contents of (object + offset) and begin conditional critical section.


attemptInt

public static boolean attemptInt(Object object,
                                 Offset offset,
                                 int oldValue,
                                 int newValue)
Sets the memory at (object + offset) to newValue if its contents are oldValue. Must be paired with a preceding prepare (which returned the oldValue) Returns true if successful. Ends conditional critical section.


attemptObject

public static boolean attemptObject(Object object,
                                    Offset offset,
                                    Object oldValue,
                                    Object newValue)
Sets the memory at (object + offset) to newValue if its contents are oldValue. Must be paired with a preceding prepare (which returned the oldValue) Returns true if successful. Ends conditional critical section.


attemptAddress

public static boolean attemptAddress(Object object,
                                     Offset offset,
                                     Address oldValue,
                                     Address newValue)
Sets the memory at (object + offset) to newValue if its contents are oldValue. Must be paired with a preceding prepare (which returned the oldValue) Returns true if successful. Ends conditional critical section.


attemptWord

public static boolean attemptWord(Object object,
                                  Offset offset,
                                  Word oldValue,
                                  Word newValue)
Sets the memory at (object + offset) to newValue if its contents are oldValue. Must be paired with a preceding prepare (which returned the oldValue) Returns true if successful. Ends conditional critical section.


attemptLong

public static boolean attemptLong(Object object,
                                  Offset offset,
                                  long oldValue,
                                  long newValue)
Sets the memory at (object + offset) to newValue if its contents are oldValue. Must be paired with a preceding prepare (which returned the oldValue) Returns true if successful. Ends conditional critical section.


setObjectAddressRemapper

public static void setObjectAddressRemapper(ObjectAddressRemapper x)
Specify how to handle "objectAsAddress" and "addressAsObject" casts. Used by debugger and boot image writer.


objectAsAddress

public static <T> Address objectAsAddress(T object)
Cast bits. Note: the returned integer is only valid until next garbage collection cycle (thereafter the referenced object might have moved and its address changed)

Parameters:
object - object reference
Returns:
object reference as bits

bootImageIntern

public static <T> T bootImageIntern(T object)
Certain objects aren't replicated in the boot image to save space.

Parameters:
object - to intern
Returns:
interned object

bootImageIdentityHashCode

public static int bootImageIdentityHashCode(Object object)
Certain objects aren't replicated in the boot image to save space.

Parameters:
object - to intern
Returns:
interned object

addressAsObject

public static Object addressAsObject(Address address)
Cast bits.

Parameters:
address - object reference as bits
Returns:
object reference

codeArrayAsObject

public static Object codeArrayAsObject(ArchitectureSpecific.CodeArray code)
Cast bits of code array into an object Note: for use by Statics when assigning slots to static method pointers

Parameters:
code - the code array to convert
Returns:
object reference

tibAsObject

public static Object tibAsObject(TIB tib)
Cast bits of tib into an object Note: for use by Statics when assigning slots

Parameters:
tib - the tib to convert
Returns:
object reference

addressAsTIB

public static TIB addressAsTIB(Address address)
Cast bits.

Parameters:
address - object array reference as bits
Returns:
object array reference

objectAsType

public static RVMType objectAsType(Object object)
Cast object.

Parameters:
object - object reference
Returns:
object reference as type (no checking on cast)

objectAsThread

public static RVMThread objectAsThread(Object object)
Cast object. Note: for use by GC to avoid checkcast during GC

Parameters:
object - object reference
Returns:
object reference as thread (no checking on cast)

floatAsIntBits

public static int floatAsIntBits(float number)
Cast bits.

Parameters:
number - A floating point number
Returns:
number as bits

intBitsAsFloat

public static float intBitsAsFloat(int number)
Cast bits.

Parameters:
number - as bits
Returns:
number as a float

doubleAsLongBits

public static long doubleAsLongBits(double number)
Cast bits.

Parameters:
number - as double
Returns:
number as bits

longBitsAsDouble

public static double longBitsAsDouble(long number)
Cast bits.

Parameters:
number - as bits
Returns:
number as double

addressAsByteArray

public static byte[] addressAsByteArray(Address byte_array)
Recast. Note: for use by GC to avoid checkcast during GC

Parameters:
byte_array - an address Returned: byte array (byte[]) object reference

objectAsShortArray

public static short[] objectAsShortArray(Object object)
Cast object. Note: for use in dynamic type checking (avoid dynamic type checking in impl. of dynamic type checking)

Parameters:
object -
Returns:
short array (short[]) object reference

objectAsIntArray

public static int[] objectAsIntArray(Object object)
Cast object. Note: for use in dynamic type checking (avoid dynamic type checking in impl. of dynamic type checking)

Parameters:
object -
Returns:
int array (int[]) object reference

getObjectType

public static RVMType getObjectType(Object object)
Get an object's type.

Parameters:
object - object reference
Returns:
object type

getArrayLength

public static int getArrayLength(Object object)
Get an array's length.

Parameters:
object - object reference
Returns:
array length (number of elements)

saveThreadState

public static void saveThreadState(ArchitectureSpecific.Registers registers)
Saves current thread state. Stores the values in the hardware registers into a Registers object.

We used to use this to implement thread switching, but we have a threadSwitch magic now that does both of these in a single step as that is less error-prone. saveThreadState is now only used in the implementation of athrow (RuntimeEntrypoints.athrow).

The following registers are saved:

Parameters:
registers - place to save register values

threadSwitch

public static void threadSwitch(RVMThread currentThread,
                                ArchitectureSpecific.Registers restoreRegs)
Switch threads. The following registers are saved/restored *

Parameters:
currentThread - thread that is currently running
restoreRegs - registers from which we should restore the saved hardware state of another thread.

restoreHardwareExceptionState

public static void restoreHardwareExceptionState(ArchitectureSpecific.Registers registers)
Resume execution with specified thread exception state.

Restores virtually all registers (details vary by architecture). But, the following are _NOT_ restored

does not return (execution resumes at new IP)

Parameters:
registers - register values to be used

returnToNewStack

public static void returnToNewStack(Address fp)
Return to caller of current method, resuming execution on a new stack that's a copy of the original.

Parameters:
fp - value to place into FRAME_POINTER register

dynamicBridgeTo

public static void dynamicBridgeTo(ArchitectureSpecific.CodeArray instructions)
Transfer execution to target of a dynamic bridge method.

The following registers are restored: non-volatiles, volatiles

Note: this method must only be called from a DynamicBridge method because it never returns (target method returns to caller of dynamic bridge method)

Parameters:
instructions - target method

invokeClassInitializer

public static void invokeClassInitializer(ArchitectureSpecific.CodeArray clinit)
                                   throws Exception
Call <clinit> method with no argument list.

Throws:
Exception

invokeMethodReturningVoid

public static void invokeMethodReturningVoid(ArchitectureSpecific.CodeArray code,
                                             WordArray gprs,
                                             double[] fprs,
                                             byte[] fprmeta,
                                             WordArray spills)
Call arbitrary method with argument list.


invokeMethodReturningInt

public static int invokeMethodReturningInt(ArchitectureSpecific.CodeArray code,
                                           WordArray gprs,
                                           double[] fprs,
                                           byte[] fprmeta,
                                           WordArray spills)
Call arbitrary method with argument list.


invokeMethodReturningLong

public static long invokeMethodReturningLong(ArchitectureSpecific.CodeArray code,
                                             WordArray gprs,
                                             double[] fprs,
                                             byte[] fprmeta,
                                             WordArray spills)
Call arbitrary method with argument list.


invokeMethodReturningFloat

public static float invokeMethodReturningFloat(ArchitectureSpecific.CodeArray code,
                                               WordArray gprs,
                                               double[] fprs,
                                               byte[] fprmeta,
                                               WordArray spills)
Call arbitrary method with argument list.


invokeMethodReturningDouble

public static double invokeMethodReturningDouble(ArchitectureSpecific.CodeArray code,
                                                 WordArray gprs,
                                                 double[] fprs,
                                                 byte[] fprmeta,
                                                 WordArray spills)
Call arbitrary method with argument list.


invokeMethodReturningObject

public static Object invokeMethodReturningObject(ArchitectureSpecific.CodeArray code,
                                                 WordArray gprs,
                                                 double[] fprs,
                                                 byte[] fprmeta,
                                                 WordArray spills)
Call arbitrary method with argument list.


readCeiling

public static void readCeiling()
Disallow any reads to float above this point.


writeFloor

public static void writeFloor()
Disallow any writes to sink below this point.


fence

public static void fence()
A strong memory fence, used to enforce StoreLoad in the JMM.


sync

public static void sync()
Wait for preceeding cache flush/invalidate instructions to complete on all processors.


isync

public static void isync()
Wait for all preceeding instructions to complete and discard any prefetched instructions on this processor.


pause

public static void pause()
On IA32, emit a PAUSE instruction, to optimize spin-wait loops.


sqrt

public static float sqrt(float value)
A hardware SQRT instruction


sqrt

public static double sqrt(double value)
A hardware SQRT instruction


getInlineDepth

public static int getInlineDepth()
How deeply inlined is this method (0 means no inlining).


isConstantParameter

public static boolean isConstantParameter(int index)
Is the specified parameter constant (due to either inlining or specialization). Count starts at zero and includes the 'this' parameter for instance methods.