|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jikesrvm.jni.JNIEnvironment
public final class JNIEnvironment
A JNIEnvironment is created for each Java thread.
| Field Summary | |
|---|---|
protected 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. |
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. |
int |
JNIRefsTop
Offset of current top ref in JNIRefs array |
protected 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 PowerOpenABI we need a linkage triple instead of just a function pointer. |
protected JNIEnvironment |
next
We allocate JNIEnvironments in the immortal heap (so we can hand them directly to C code). |
protected Throwable |
pendingException
Currently pending exception (null if none) |
protected static JNIEnvironment |
pool
Pool of available JNIEnvironments. |
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 Summary | |
|---|---|
JNIEnvironment()
|
|
| Method Summary | |
|---|---|
static JNIEnvironment |
allocateEnvironment()
Create a thread specific JNI environment. |
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 |
static void |
deallocateEnvironment(JNIEnvironment env)
Return a thread-specific JNI environment; must be called as part of terminating a thread that has a JNI environment allocated to it. |
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. |
protected void |
initializeState()
Initialize a thread specific JNI environment. |
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()
|
int |
savedRefsFP()
|
Address |
topJavaFP()
|
private int |
uninterruptiblePushJNIRef(Address ref,
boolean isRef)
Push a JNI ref, used on entry to JNI NB only used for Intel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
protected Address JNITopJavaFP
protected Throwable pendingException
protected JNIEnvironment next
protected static JNIEnvironment pool
protected boolean alwaysHasNativeFrame
public AddressArray JNIRefs
public int JNIRefsTop
protected int JNIRefsMax
public int JNIRefsSavedFP
| Constructor Detail |
|---|
public JNIEnvironment()
| Method Detail |
|---|
protected void initializeState()
public static JNIEnvironment allocateEnvironment()
public static void deallocateEnvironment(JNIEnvironment env)
env - the JNIEnvironment to deallocatepublic boolean hasNativeStackFrame()
public Address topJavaFP()
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 stack
private 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 result
public Object getJNIRef(int offset)
offset - in JNIRefs stack
public void deleteJNIRef(int offset)
offset - in JNIRefs stackpublic void dumpJniRefsStack()
public void recordException(Throwable e)
e - An exception or errorpublic Throwable getException()
public static void initFunctionTable(FunctionTable functions)
public static void boot()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||