public abstract class JNICompiler extends Object
JNIFunctions
Modifier and Type | Field and Description |
---|---|
private static Offset |
BP_ON_ENTRY_OFFSET
Location of a saved version of the field JNIEnvironment.basePointerOnEntryToNative
|
(package private) static Offset |
EBP_SAVE_OFFSET
Location of non-volatile EBP register when saved to stack
|
(package private) static Offset |
EBX_SAVE_OFFSET
Location of non-volatile EBX register when saved to stack
|
(package private) static Offset |
EDI_SAVE_OFFSET
Location of non-volatile EDI register when saved to stack
|
private static Offset |
JNI_ENV_OFFSET
Location of an extra copy of the RVMThread.jniEnv when saved to stack
|
private static int |
jniExternalFunctionsFieldOffset
Offset of external functions field in JNIEnvironment
|
static int |
SAVED_GPRS_FOR_JNI
The following is used in BaselineCompilerImpl to compute offset to first local.
|
private static Offset |
SAVED_JAVA_FP_OFFSET
Stack frame location for saved JNIEnvironment.JNITopJavaFP that
will be clobbered by a transition from Java to C.
|
private JNIExceptionDeliverer |
unused
Dummy field to force compilation of the exception deliverer
|
Constructor and Description |
---|
JNICompiler() |
Modifier and Type | Method and Description |
---|---|
static CompiledMethod |
compile(NativeMethod method)
Compiles a method to handle the Java to C transition and back
Transitioning from Java to C then back:
Set up stack frame and save non-volatile registers
Set up jniEnv - set up a register to hold JNIEnv and store
the Processor in the JNIEnv for easy access
Move all native method arguments on to stack (NB at this point all
non-volatile state is saved)
Record the frame pointer of the last Java frame (this) in the jniEnv
Call out to convert reference arguments to IDs
Set processor as being "in native"
Set up stack frame and registers for transition to C
Call out to C
Save result to stack
Transition back from "in native" to "in Java", take care that the
Processor isn't "blocked in native", ie other processors have decided to
start a GC and we're not permitted to execute Java code whilst this
occurs
Convert a reference result (currently a JNI ref) into a true reference
Release JNI refs
Restore stack and place result in register
|
static void |
generateEpilogForJNIMethod(Assembler asm,
RVMMethod method)
Handles the C to Java transition: JNI methods in JNIFunctions.java.
|
static void |
generateGlueCodeForJNIMethod(Assembler asm,
NormalMethod method,
int methodID)
Handles the C to Java transition: JNI methods in JNIFunctions.java.
|
private JNIExceptionDeliverer unused
private static final int jniExternalFunctionsFieldOffset
static final Offset EDI_SAVE_OFFSET
static final Offset EBX_SAVE_OFFSET
static final Offset EBP_SAVE_OFFSET
private static final Offset JNI_ENV_OFFSET
private static final Offset BP_ON_ENTRY_OFFSET
private static final Offset SAVED_JAVA_FP_OFFSET
public static final int SAVED_GPRS_FOR_JNI
public JNICompiler()
public static CompiledMethod compile(NativeMethod method)
method
- the method to compileJNICompiledMethod
)public static void generateGlueCodeForJNIMethod(Assembler asm, NormalMethod method, int methodID)
NOTE: -We need THREAD_REGISTER to access Java environment; we can get it from the JNIEnv* (which is an interior pointer to the JNIEnvironment) -Unlike the powerPC scheme which has a special prolog preceding the normal Java prolog, the Intel scheme replaces the Java prolog completely with the special prolog Stack on entry Stack at end of prolog after call high memory high memory | | | | EBP -> |saved FP | |saved FP | | ... | | ... | | | | | |arg n-1 | |arg n-1 | native | ... | | ... | caller |arg 0 | JNIEnv* |arg 0 | JNIEnvironment ESP -> |return addr | |return addr | | | EBP -> |saved FP | outer most native frame pointer | | |methodID | normal MethodID for JNI function | | |saved JavaFP| offset to preceeding java frame | | |saved nonvol| to be used for nonvolatile storage | | | ... | including ebp on entry | | |arg 0 | copied in reverse order (JNIEnvironment) | | | ... | | | ESP -> |arg n-1 | | | | | normally compiled Java code continue | | | | | | | | | | | | low memory low memory
asm
- the assembler to usemethod
- the method that's being compiled (i.e. the method which is a bridge
from native).methodID
- the id of the compiled methodpublic static void generateEpilogForJNIMethod(Assembler asm, RVMMethod method)
asm
- the assembler to usemethod
- the method that's being compiled