public final class JNIEnvironment extends Object
Modifier and Type | Field and Description |
---|---|
private boolean |
alwaysHasNativeFrame
true if the bottom stack frame is native,
such as thread for CreateJVM or AttachCurrentThread
|
private Address |
basePointerOnEntryToNative
When native code doesn't maintain a base pointer we can't chain
through the base pointers when walking the stack.
|
private Address |
externalJNIFunctions
This is the pointer to the shared JNIFunction table.
|
private int |
hasPendingException |
static FunctionTable |
JNIFunctions
This is the shared JNI function table used by native code
to invoke methods in @link{JNIFunctions}.
|
AddressArray |
JNIRefs
references passed to native code
|
protected static int |
JNIREFS_ARRAY_LENGTH
initial size for JNI refs, later grow as needed
|
protected static int |
JNIREFS_FUDGE_LENGTH
sometimes we put stuff onto the jnirefs array bypassing the code
that makes sure that it does not overflow (evil assembly code in the
jni stubs that would be painful to fix).
|
protected int |
JNIRefsMax
Offset of end (last entry) of JNIRefs array
|
int |
JNIRefsSavedFP
Previous frame boundary in JNIRefs array.
|
private AddressArray |
JNIRefsShadow |
int |
JNIRefsTop
Offset of current top ref in JNIRefs array
|
private Address |
JNITopJavaFP
When transitioning between Java and C and back, we may want to stop a thread
returning into Java and executing mutator code when a GC is in progress.
|
static LinkageTripletTable |
linkageTriplets
For the 64-bit PowerPC ELF ABI we need a linkage triple instead of just
a function pointer.
|
private Throwable |
pendingException
Currently pending exception (null if none)
|
private Address |
savedJTOC
For saving JTOC register on entry to native,
to be restored on JNI call from native (only used on PowerPC)
|
protected RVMThread |
savedTRreg
For saving processor register on entry to native,
to be restored on JNI call from native
|
Constructor and Description |
---|
JNIEnvironment()
Initialize a thread specific JNI environment.
|
Modifier and Type | Method and Description |
---|---|
static void |
boot()
Initialization required during VM booting; only does something if
we are on a platform that needs linkage triplets.
|
private void |
checkPush(Object ref,
boolean canGrow)
Check push of reference can succeed
|
void |
deleteJNIRef(int offset)
Remove a reference from the JNIRefs stack.
|
void |
dumpJniRefsStack()
Dump the JNIRefs stack to the sysWrite stream
|
void |
entryToJNI(int encodedReferenceOffsets)
Save data and perform necessary conversions for entry into JNI.
|
Object |
exitFromJNI(int offset)
Restore data, throw pending exceptions or convert return value for exit
from JNI.
|
Throwable |
getException() |
Object |
getJNIRef(int offset)
Get a reference from the JNIRefs stack.
|
boolean |
hasNativeStackFrame() |
static void |
initFunctionTable(FunctionTable functions)
Initialize the array of JNI functions.
|
int |
pushJNIRef(Object ref)
Push a reference onto thread local JNIRefs stack.
|
void |
recordException(Throwable e)
Record an exception as pending so that it will be delivered on the return
to the Java caller; clear the exception by recording null
|
AddressArray |
refsArray() |
int |
refsTop() |
private void |
replaceJNIRefs(AddressArray newrefs)
Atomically copies and installs a new JNIRefArray.
|
int |
savedRefsFP() |
static void |
throwPendingException()
Return and clear the (known to be non-null) pending exception.
|
Address |
topJavaFP() |
private int |
uninterruptiblePushJNIRef(Address ref,
boolean isRef)
Push a JNI ref, used on entry to JNI
NB only used for Intel
|
protected static final int JNIREFS_ARRAY_LENGTH
protected static final int JNIREFS_FUDGE_LENGTH
public static FunctionTable JNIFunctions
public static LinkageTripletTable linkageTriplets
private final Address externalJNIFunctions
protected RVMThread savedTRreg
private final Address savedJTOC
private Address basePointerOnEntryToNative
private Address JNITopJavaFP
private Throwable pendingException
private int hasPendingException
private final boolean alwaysHasNativeFrame
public AddressArray JNIRefs
private AddressArray JNIRefsShadow
public int JNIRefsTop
protected int JNIRefsMax
public int JNIRefsSavedFP
public JNIEnvironment()
public boolean hasNativeStackFrame()
public AddressArray refsArray()
public int refsTop()
public int savedRefsFP()
private void checkPush(Object ref, boolean canGrow)
ref
- object to be pushedcanGrow
- can the JNI reference array be grown?public int pushJNIRef(Object ref)
ref
- the object to put on stackprivate void replaceJNIRefs(AddressArray newrefs)
newrefs
- the new JNIRefArrayprivate int uninterruptiblePushJNIRef(Address ref, boolean isRef)
ref
- reference to place on stack or value of saved frame pointerisRef
- false if the reference isn't a frame pointerpublic void entryToJNI(int encodedReferenceOffsets)
encodedReferenceOffsets
- bit mask marking which elements on the stack hold objects that need
encoding as JNI ref identifierspublic Object exitFromJNI(int offset)
offset
- offset into JNI reference tables of resultpublic Object getJNIRef(int offset)
offset
- in JNIRefs stackpublic void deleteJNIRef(int offset)
offset
- in JNIRefs stackpublic void dumpJniRefsStack()
public void recordException(Throwable e)
e
- An exception or errorpublic static void throwPendingException()
public Throwable getException()
public static void initFunctionTable(FunctionTable functions)
functions
- the function table to initializepublic static void boot()