|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.runtime.RuntimeEntrypoints
public class RuntimeEntrypoints
Entrypoints into the runtime of the virtual machine.
These are "helper functions" called from machine code emitted by BaselineCompilerImpl. They implement functionality that cannot be mapped directly into a small inline sequence of machine instructions. See also: Linker.
Note #1: If you add, remove, or change the signature of any of these methods you may need to change Entrypoints to match.
Note #2: Code here must be carefully written to be gc-safe while manipulating stackframe and instruction addresses.
Any time we are holding interior pointers to objects that could be moved by a garbage collection cycle we must either avoid passing through gc-sites (by writing straight line code with no "non-magic" method invocations) or we must turn off the collector (so that a gc request initiated by another thread will not run until we're done manipulating the bare pointers). Furthermore, while the collector is turned off, we must be careful not to make any allocation requests ("new").
The interior pointers that we must worry about are:
Field Summary | |
---|---|
(package private) static int |
allocationCountDownToGC
Number of allocations left before a GC is forced. |
(package private) static int |
jniCountDownToGC
Number of c-to-java jni calls left before a GC is forced. |
private static boolean |
traceAthrow
|
static int |
TRAP_ARRAY_BOUNDS
|
static int |
TRAP_CHECKCAST
|
static int |
TRAP_DIVIDE_BY_ZERO
|
static int |
TRAP_JNI_STACK
|
static int |
TRAP_MUST_IMPLEMENT
|
static int |
TRAP_NULL_POINTER
|
static int |
TRAP_REGENERATE
|
static int |
TRAP_STACK_OVERFLOW
|
static int |
TRAP_STACK_OVERFLOW_FATAL
|
static int |
TRAP_STORE_CHECK
|
static int |
TRAP_UNKNOWN
|
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.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 | |
---|---|
RuntimeEntrypoints()
|
Method Summary | |
---|---|
(package private) static void |
aastore(Object[] arrayRef,
int index,
Object value)
Perform aastore bytecode |
(package private) static void |
aastoreUninterruptible(Object[] arrayRef,
int index,
Object value)
Perform uninterruptible aastore bytecode |
static void |
athrow(Throwable exceptionObject)
Deliver a software exception to current java thread. |
static Object |
buildMDAHelper(RVMMethod method,
int[] numElements,
int dimIndex,
RVMArray arrayType)
|
static Object |
buildMultiDimensionalArray(int methodId,
int[] numElements,
RVMArray arrayType)
Build a multi-dimensional array. |
static Object |
buildTwoDimensionalArray(int methodId,
int dim0,
int dim1,
RVMArray arrayType)
Build a two-dimensional array. |
private static boolean |
canForceGC()
Return true if we are stress testing garbage collector and the system is in state where we
can force a garbage collection. |
private static void |
checkAllocationCountDownToGC()
Check to see if we are stress testing garbage collector and if another allocation should trigger a GC then do so. |
(package private) static void |
checkcast(Object object,
int id)
Throw exception unless object is instance of target class/array or implements target interface. |
static void |
checkJNICountDownToGC()
Check to see if we are stress testing garbage collector and if another JNI call should trigger a gc then do so. |
(package private) static void |
checkstore(Object array,
Object arrayElement)
Throw exception iff array assignment is illegal. |
static Object |
clone(Object obj)
Clone a Scalar or Array Object. |
private static Object |
cloneArray(Object obj,
RVMType type)
Clone an array |
private static Object |
cloneClass(Object obj,
RVMType type)
Clone an object implementing a class - check that the class is cloneable (we make this a small method with just a test so that the inliner will inline it and hopefully eliminate the instanceof test). |
private static Object |
cloneClass2(Object obj,
RVMType type)
Clone an object implementing a class - the actual clone |
private static void |
deliverException(Throwable exceptionObject,
ArchitectureSpecific.Registers exceptionRegisters)
Deliver an exception to current java thread. |
(package private) static void |
deliverHardwareException(int trapCode,
int trapInfo)
Deliver a hardware exception to current java thread. |
static int |
getObjectHashCode(Object object)
Get an object's "hashcode" value. |
private static void |
handleUncaughtException(Throwable exceptionObject)
|
static void |
init()
|
static void |
initializeClassForDynamicLink(RVMClass cls)
Prepare a class for use prior to first allocation, field access, or method invocation. |
(package private) static boolean |
instanceOf(Object object,
int targetID)
Test if object is instance of target class/array or implements target interface. |
static boolean |
isAssignableWith(RVMType lhs,
RVMType rhs)
May a variable of type "lhs" be assigned a value of type "rhs"? |
(package private) static void |
raiseAbstractMethodError()
Create and throw a java.lang.AbstractMethodError. |
(package private) static void |
raiseArithmeticException()
Create and throw a java.lang.ArithmeticException. |
(package private) static void |
raiseArrayIndexOutOfBoundsException()
Create and throw a java.lang.ArrayIndexOutOfBoundsException. |
(package private) static void |
raiseArrayIndexOutOfBoundsException(int index)
Create and throw a java.lang.ArrayIndexOutOfBoundsException. |
static void |
raiseArrayStoreException()
Create and throw a java.lang.ArrayStoreException. |
(package private) static void |
raiseIllegalAccessError()
Create and throw a java.lang.IllegalAccessError. |
private static void |
raiseNegativeArraySizeException()
Helper function to actually throw the required exception. |
static void |
raiseNullPointerException()
Create and throw a java.lang.NullPointerException. |
static Object |
resolvedNewArray(int numElements,
int logElementSize,
int headerSize,
TIB tib,
int allocator,
int align,
int offset,
int site)
Allocate something like "new int[cnt]" or "new Foo[cnt]". |
static Object |
resolvedNewArray(int numElements,
RVMArray array)
Allocate something like "new Foo[]". |
static Object |
resolvedNewArray(int numElements,
RVMArray array,
int site)
|
static Object |
resolvedNewScalar(int size,
TIB tib,
boolean hasFinalizer,
int allocator,
int align,
int offset,
int site)
Allocate something like "new Foo()". |
static Object |
resolvedNewScalar(RVMClass cls)
Allocate something like "new Foo()". |
(package private) static void |
unexpectedAbstractMethodCall()
Report unexpected method call: abstract method (verification error). |
(package private) static void |
unexpectedInterfaceMethodCall()
Report unexpected method call: interface method (virtual machine dispatching error, shouldn't happen). |
(package private) static void |
unlockAndThrow(Object objToUnlock,
Throwable objToThrow)
Unlock an object and then deliver a software exception to current java thread. |
static Object |
unresolvedNewArray(int numElements,
int id,
int site)
Allocate something like "new Foo[]". |
(package private) static Object |
unresolvedNewScalar(int id,
int site)
Allocate something like "new Foo()". |
private static void |
unwindInvisibleStackFrame(ArchitectureSpecific.Registers registers)
Unwind stack frame for an |
static Address |
unwindNativeStackFrame(Address currfp)
Skip over all frames below currfp with saved code pointers outside of heap (C frames), stopping at the native frame immediately preceding the glue frame which contains the method ID of the native method (this is necessary to allow retrieving the return address of the glue frame). |
static Address |
unwindNativeStackFrameForGC(Address currfp)
The current frame is expected to be one of the JNI functions called from C, below which is one or more native stack frames. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean traceAthrow
public static final int TRAP_UNKNOWN
public static final int TRAP_NULL_POINTER
public static final int TRAP_ARRAY_BOUNDS
public static final int TRAP_DIVIDE_BY_ZERO
public static final int TRAP_STACK_OVERFLOW
public static final int TRAP_CHECKCAST
public static final int TRAP_REGENERATE
public static final int TRAP_JNI_STACK
public static final int TRAP_MUST_IMPLEMENT
public static final int TRAP_STORE_CHECK
public static final int TRAP_STACK_OVERFLOW_FATAL
static int allocationCountDownToGC
static int jniCountDownToGC
Constructor Detail |
---|
public RuntimeEntrypoints()
Method Detail |
---|
static boolean instanceOf(Object object, int targetID) throws NoClassDefFoundError
object
- object to be testedtargetID
- type reference id corresponding to target
class/array/interface
NoClassDefFoundError
static void checkcast(Object object, int id) throws ClassCastException, NoClassDefFoundError
object
- object to be testedid
- of type reference corresponding to target class/array/interface
ClassCastException
NoClassDefFoundError
static void aastore(Object[] arrayRef, int index, Object value) throws ArrayStoreException, ArrayIndexOutOfBoundsException
ArrayStoreException
ArrayIndexOutOfBoundsException
static void aastoreUninterruptible(Object[] arrayRef, int index, Object value)
static void checkstore(Object array, Object arrayElement) throws ArrayStoreException
ArrayStoreException
public static boolean isAssignableWith(RVMType lhs, RVMType rhs)
lhs
- type of variablerhs
- type of value
static Object unresolvedNewScalar(int id, int site) throws NoClassDefFoundError, OutOfMemoryError
id
- id of type reference of class to create.
NoClassDefFoundError
OutOfMemoryError
public static Object resolvedNewScalar(RVMClass cls)
cls
- RVMClass of array to create
public static Object resolvedNewScalar(int size, TIB tib, boolean hasFinalizer, int allocator, int align, int offset, int site) throws OutOfMemoryError
size
- size of object (including header), in bytestib
- type information block for objecthasFinalizer
- does this type have a finalizer?allocator
- int that encodes which allocator should be usedalign
- the alignment requested; must be a power of 2.offset
- the offset at which the alignment is desired.site
- the site id of the calling allocation site
OutOfMemoryError
public static Object unresolvedNewArray(int numElements, int id, int site) throws NoClassDefFoundError, OutOfMemoryError, NegativeArraySizeException
numElements
- number of array elementsid
- id of type reference of array to create.site
- the site id of the calling allocation site
NoClassDefFoundError
OutOfMemoryError
NegativeArraySizeException
public static Object resolvedNewArray(int numElements, RVMArray array) throws OutOfMemoryError, NegativeArraySizeException
numElements
- number of array elementsarray
- RVMArray of array to create
OutOfMemoryError
NegativeArraySizeException
public static Object resolvedNewArray(int numElements, RVMArray array, int site) throws OutOfMemoryError, NegativeArraySizeException
OutOfMemoryError
NegativeArraySizeException
public static Object resolvedNewArray(int numElements, int logElementSize, int headerSize, TIB tib, int allocator, int align, int offset, int site) throws OutOfMemoryError, NegativeArraySizeException
numElements
- number of array elementslogElementSize
- size in bytes of an array element, log base 2.headerSize
- size in bytes of array headertib
- type information block for array objectallocator
- int that encodes which allocator should be usedalign
- the alignment requested; must be a power of 2.offset
- the offset at which the alignment is desired.
OutOfMemoryError
NegativeArraySizeException
public static Object clone(Object obj) throws OutOfMemoryError, CloneNotSupportedException
For simplicity, we just code this more or less in Java using internal reflective operations and some magic. This is inefficient for large scalar objects, but until that is proven to be a performance problem, we won't worry about it. By keeping this in Java instead of dropping into Memory.copy, we avoid having to add special case code to deal with write barriers, and other such things.
This method calls specific cloning routines based on type to help guide the inliner (which won't inline a single large method).
obj
- the object to clone
OutOfMemoryError
CloneNotSupportedException
private static Object cloneArray(Object obj, RVMType type) throws OutOfMemoryError
obj
- the array to clonetype
- the type information for the array
OutOfMemoryError
private static Object cloneClass(Object obj, RVMType type) throws OutOfMemoryError, CloneNotSupportedException
obj
- the object to clonetype
- the type information for the class
OutOfMemoryError
CloneNotSupportedException
private static Object cloneClass2(Object obj, RVMType type) throws OutOfMemoryError
obj
- the object to clonetype
- the type information for the class
OutOfMemoryError
private static void raiseNegativeArraySizeException() throws NegativeArraySizeException
NegativeArraySizeException
public static int getObjectHashCode(Object object)
Object.hashCode().
public static void initializeClassForDynamicLink(RVMClass cls)
MemberReference.needsDynamicLink(org.jikesrvm.classloader.RVMMethod)
static void unexpectedInterfaceMethodCall()
static void unexpectedAbstractMethodCall()
public static void athrow(Throwable exceptionObject)
exceptionObject
- exception object to deliver
(null --> deliver NullPointerException).
does not return
(stack is unwound and execution resumes in a catch block)
This method is public so that it can be invoked by java.lang.VMClass.static void deliverHardwareException(int trapCode, int trapInfo)
Does not return. (stack is unwound, starting at trap site, and execution resumes in a catch block somewhere up the stack) /or/ execution resumes at instruction following trap (for TRAP_STACK_OVERFLOW)
Note: Control reaches here by the actions of an
external "C" signal handler
which saves the register state of the trap site into the
"exceptionRegisters" field of the current
Thread object.
The signal handler also inserts a
trapCode
- code indicating kind of exception that was trapped
(see TRAP_xxx, above)trapInfo
- array subscript (for array bounds trap, only)
static void unlockAndThrow(Object objToUnlock, Throwable objToThrow)
Does not return (stack is unwound and execution resumes in a catch block).
objToUnlock
- object to unlockobjToThrow
- exception object to deliver
(null
--> deliver NullPointerException).static void raiseArrayIndexOutOfBoundsException(int index)
static void raiseArrayIndexOutOfBoundsException()
public static void raiseNullPointerException()
public static void raiseArrayStoreException()
static void raiseArithmeticException()
static void raiseAbstractMethodError()
static void raiseIllegalAccessError()
public static void init()
public static Object buildMultiDimensionalArray(int methodId, int[] numElements, RVMArray arrayType)
methodId
- TODO document menumElements
- number of elements to allocate for each dimensionarrayType
- type of array that will result
public static Object buildTwoDimensionalArray(int methodId, int dim0, int dim1, RVMArray arrayType)
methodId
- TODO document medim0
- the arraylength for arrays in dimension 0dim1
- the arraylength for arrays in dimension 1arrayType
- type of array that will result
public static Object buildMDAHelper(RVMMethod method, int[] numElements, int dimIndex, RVMArray arrayType)
method
- Apparently unused (!)numElements
- Number of elements to allocate for each dimensiondimIndex
- Current dimension to buildarrayType
- type of array that will resultprivate static void deliverException(Throwable exceptionObject, ArchitectureSpecific.Registers exceptionRegisters)
Does not return:
exceptionObject
- exception object to deliverexceptionRegisters
- register state corresponding to exception siteprivate static void handleUncaughtException(Throwable exceptionObject)
public static Address unwindNativeStackFrame(Address currfp)
currfp
- The current frame is expected to be one of the JNI functions
called from C, below which is one or more native stack framespublic static Address unwindNativeStackFrameForGC(Address currfp)
private static void unwindInvisibleStackFrame(ArchitectureSpecific.Registers registers)
!!TODO: Could be a reflective method invoker frame. Does it clobber any non-volatiles? If so, how do we restore them? (I don't think our current implementations of reflective method invokers save/restore any nonvolatiles, so we're probably ok. --dave 6/29/01
public static void checkJNICountDownToGC()
private static void checkAllocationCountDownToGC()
private static boolean canForceGC()
true
if we are stress testing garbage collector and the system is in state where we
can force a garbage collection.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |