static CompiledMethod |
JNICompiler.compile(NativeMethod method)
Compile 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
|