|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.runtime.Magic
public final class Magic
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
|
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
|
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 |
---|
private static ObjectAddressRemapper objectAddressRemapper
Constructor Detail |
---|
public Magic()
Method Detail |
---|
public static Address getFramePointer()
public static Address getTocPointer()
public static Address getJTOC()
public static RVMThread getThreadRegister()
public static void setThreadRegister(RVMThread p)
public static RVMThread getESIAsThread()
public static void setESIAsThread(RVMThread p)
public static long getTimeBase()
Note: we think that 1 "tick" == 4 "machine cycles", but this seems to be undocumented and may vary across processor implementations.
public static Address getCallerFramePointer(Address fp)
fp
- frame pointer for child framepublic static void setCallerFramePointer(Address fp, Address newCallerFP)
fp
- frame pointer for child framenewCallerFP
- new value for caller frame pointerpublic static int getCompiledMethodID(Address fp)
fp
- its frame pointer).public static void setCompiledMethodID(Address fp, int newCMID)
fp
- its frame pointernewCMID
- a new cmid for the framepublic static Address getNextInstructionAddress(Address fp)
fp
- its frame pointer.public static Address getReturnAddressLocation(Address fp)
fp
- its frame pointerpublic static Address getReturnAddressUnchecked(Address fp)
fp
- its frame pointerpublic static Address getReturnAddress(Address fp)
fp
- its frame pointerpublic static Address getReturnAddress(Address fp, RVMThread thread)
fp
- its frame pointerthread
- the thread whose stack is being examinedpublic static void setReturnAddress(Address fp, Address v)
fp
- its frame pointerpublic static byte getUnsignedByteAtOffset(Object object, Offset offset)
public static byte getByteAtOffset(Object object, Offset offset)
public static char getCharAtOffset(Object object, Offset offset)
public static short getShortAtOffset(Object object, Offset offset)
public static int getIntAtOffset(Object object, Offset offset)
public static long getLongAtOffset(Object object, Offset offset)
public static float getFloatAtOffset(Object object, Offset offset)
public static double getDoubleAtOffset(Object object, Offset offset)
public static Object getObjectAtOffset(Object object, Offset offset)
public static Object getObjectAtOffset(Object object, Offset offset, int locationMetadata)
public static Word getWordAtOffset(Object object, Offset offset)
public static Word getWordAtOffset(Object object, Offset offset, int locationMetadata)
public static Address getAddressAtOffset(Object object, Offset offset)
public static Address getAddressAtOffset(Object object, Offset offset, int locationMetadata)
public static Extent getExtentAtOffset(Object object, Offset offset)
public static Extent getExtentAtOffset(Object object, Offset offset, int locationMetadata)
public static Offset getOffsetAtOffset(Object object, Offset offset)
public static Offset getOffsetAtOffset(Object object, Offset offset, int locationMetadata)
public static TIB getTIBAtOffset(Object object, Offset offset)
public static void setBooleanAtOffset(Object object, Offset offset, boolean newvalue)
public static void setBooleanAtOffset(Object object, Offset offset, boolean newvalue, int locationMetadata)
public static void setByteAtOffset(Object object, Offset offset, byte newvalue)
public static void setByteAtOffset(Object object, Offset offset, byte newvalue, int locationMetadata)
public static void setCharAtOffset(Object object, Offset offset, char newvalue)
public static void setCharAtOffset(Object object, Offset offset, char newvalue, int locationMetadata)
public static void setShortAtOffset(Object object, Offset offset, short newvalue)
public static void setShortAtOffset(Object object, Offset offset, short newvalue, int locationMetadata)
public static void setIntAtOffset(Object object, Offset offset, int newvalue)
public static void setIntAtOffset(Object object, Offset offset, int newvalue, int locationMetadata)
public static void setLongAtOffset(Object object, Offset offset, long newvalue)
public static void setLongAtOffset(Object object, Offset offset, long newvalue, int locationMetadata)
public static void setFloatAtOffset(Object object, Offset offset, float newvalue)
public static void setFloatAtOffset(Object object, Offset offset, float newvalue, int locationMetadata)
public static void setDoubleAtOffset(Object object, Offset offset, double newvalue)
public static void setDoubleAtOffset(Object object, Offset offset, double newvalue, int locationMetadata)
public static void setWordAtOffset(Object object, Offset offset, Word newvalue)
public static void setWordAtOffset(Object object, Offset offset, Word newvalue, int locationMetadata)
public static void setAddressAtOffset(Object object, Offset offset, Address newvalue)
public static void setAddressAtOffset(Object object, Offset offset, Address newvalue, int locationMetadata)
public static void setExtentAtOffset(Object object, Offset offset, Extent newvalue)
public static void setExtentAtOffset(Object object, Offset offset, Extent newvalue, int locationMetadata)
public static void setOffsetAtOffset(Object object, Offset offset, Offset newvalue)
public static void setOffsetAtOffset(Object object, Offset offset, Offset newvalue, int locationMetadata)
public static void setObjectAtOffset(Object object, Offset offset, Object newvalue)
public static void setObjectAtOffset(Object object, Offset offset, Object newvalue, int locationMetadata)
public static int prepareInt(Object object, Offset offset)
public static Object prepareObject(Object object, Offset offset)
public static Address prepareAddress(Object object, Offset offset)
public static Word prepareWord(Object object, Offset offset)
public static long prepareLong(Object object, Offset offset)
public static boolean attemptInt(Object object, Offset offset, int oldValue, int newValue)
public static boolean attemptObject(Object object, Offset offset, Object oldValue, Object newValue)
public static boolean attemptAddress(Object object, Offset offset, Address oldValue, Address newValue)
public static boolean attemptWord(Object object, Offset offset, Word oldValue, Word newValue)
public static boolean attemptLong(Object object, Offset offset, long oldValue, long newValue)
public static void setObjectAddressRemapper(ObjectAddressRemapper x)
public static <T> Address objectAsAddress(T object)
object
- object reference
public static <T> T bootImageIntern(T object)
object
- to intern
public static int bootImageIdentityHashCode(Object object)
object
- to intern
public static Object addressAsObject(Address address)
address
- object reference as bits
public static Object codeArrayAsObject(ArchitectureSpecific.CodeArray code)
code
- the code array to convert
public static Object tibAsObject(TIB tib)
tib
- the tib to convert
public static TIB addressAsTIB(Address address)
address
- object array reference as bits
public static RVMType objectAsType(Object object)
object
- object reference
public static RVMThread objectAsThread(Object object)
object
- object reference
public static int floatAsIntBits(float number)
number
- A floating point number
number
as bitspublic static float intBitsAsFloat(int number)
number
- as bits
number
as a float
public static long doubleAsLongBits(double number)
number
- as double
public static double longBitsAsDouble(long number)
number
- as bits
public static byte[] addressAsByteArray(Address byte_array)
byte_array
- an address
Returned: byte array (byte[]) object referencepublic static short[] objectAsShortArray(Object object)
object
-
public static int[] objectAsIntArray(Object object)
object
-
public static RVMType getObjectType(Object object)
object
- object reference
public static int getArrayLength(Object object)
object
- object reference
public static void saveThreadState(ArchitectureSpecific.Registers registers)
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:
registers
- place to save register valuespublic static void threadSwitch(RVMThread currentThread, ArchitectureSpecific.Registers restoreRegs)
currentThread
- thread that is currently runningrestoreRegs
- registers from which we should restore
the saved hardware state of another thread.public static void restoreHardwareExceptionState(ArchitectureSpecific.Registers registers)
Restores virtually all registers (details vary by architecture). But, the following are _NOT_ restored
registers
- register values to be usedpublic static void returnToNewStack(Address fp)
fp
- value to place into FRAME_POINTER registerpublic static void dynamicBridgeTo(ArchitectureSpecific.CodeArray instructions)
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)
instructions
- target methodpublic static void invokeClassInitializer(ArchitectureSpecific.CodeArray clinit) throws Exception
Exception
public static void invokeMethodReturningVoid(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
public static int invokeMethodReturningInt(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
public static long invokeMethodReturningLong(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
public static float invokeMethodReturningFloat(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
public static double invokeMethodReturningDouble(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
public static Object invokeMethodReturningObject(ArchitectureSpecific.CodeArray code, WordArray gprs, double[] fprs, byte[] fprmeta, WordArray spills)
public static void readCeiling()
public static void writeFloor()
public static void fence()
public static void sync()
public static void isync()
public static void pause()
public static float sqrt(float value)
public static double sqrt(double value)
public static int getInlineDepth()
public static boolean isConstantParameter(int index)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |