|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jikesrvm.jni.JNIGenericHelpers
org.jikesrvm.jni.ia32.JNIHelpers
public abstract class JNIHelpers
Platform dependent utility functions called from JNIFunctions (cannot be placed in JNIFunctions because methods there are specially compiled to be called from native).
JNIFunctions
Constructor Summary | |
---|---|
JNIHelpers()
|
Method Summary | |
---|---|
private static Address |
getVarArgAddress(boolean skip4Args)
This method supports var args passed from C. |
static Object |
invokeInitializer(Class<?> cls,
int methodID,
Address argAddress,
boolean isJvalue,
boolean isDotDotStyle)
Common code shared by the JNI functions NewObjectA, NewObjectV, NewObject (object creation) |
static Object |
invokeWithDotDotVarArg(int methodID,
TypeReference expectReturnType)
Common code shared by the JNI functions CallStatic |
static Object |
invokeWithDotDotVarArg(Object obj,
int methodID,
TypeReference expectReturnType,
boolean skip4Args)
Common code shared by the JNI functions Call |
static Object |
invokeWithJValue(int methodID,
Address argAddress,
TypeReference expectReturnType)
Common code shared by the JNI functions CallStatic |
static Object |
invokeWithJValue(Object obj,
int methodID,
Address argAddress,
TypeReference expectReturnType,
boolean skip4Args)
Common code shared by the JNI functions Call |
static Object |
invokeWithVarArg(int methodID,
Address argAddress,
TypeReference expectReturnType)
Common code shared by the JNI functions CallStatic |
static Object |
invokeWithVarArg(Object obj,
int methodID,
Address argAddress,
TypeReference expectReturnType,
boolean skip4Args)
Common code shared by the JNI functions Call |
(package private) static Object |
packageAndInvoke(Object obj,
int methodID,
Address argAddress,
TypeReference expectReturnType,
boolean skip4Args,
boolean isVarArg)
Common code shared by invokeWithJValue, invokeWithVarArg and invokeWithDotDotVarArg |
(package private) static Object[] |
packageParameterFromJValue(RVMMethod targetMethod,
Address argAddress)
Repackage the arguments passed as an array of jvalue into an array of Object, used by the JNI functions CallStatic |
(package private) static Object[] |
packageParameterFromVarArg(RVMMethod targetMethod,
Address argAddress)
Repackage the arguments passed as a variable argument list into an array of Object, used by the JNI functions CallStatic |
Methods inherited from class org.jikesrvm.jni.JNIGenericHelpers |
---|
createByteArrayFromC, createStringFromC, createUTFForCFromString, createUTFStringFromC, strlen |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JNIHelpers()
Method Detail |
---|
public static Object invokeInitializer(Class<?> cls, int methodID, Address argAddress, boolean isJvalue, boolean isDotDotStyle) throws Exception
methodID
- the method ID for a constructor
Exception
public static Object invokeWithDotDotVarArg(int methodID, TypeReference expectReturnType) throws Exception
methodID
- the method IDexpectReturnType
- the return type of the method to be invoked
Exception
public static Object invokeWithDotDotVarArg(Object obj, int methodID, TypeReference expectReturnType, boolean skip4Args) throws Exception
obj
- the object instancemethodID
- the method IDexpectReturnType
- the return type for checking purposeskip4Args
- true if the calling JNI Function takes 4 args before the vararg
false if the calling JNI Function takes 3 args before the vararg
Exception
private static Address getVarArgAddress(boolean skip4Args)
In the Linux Intel C convention, the caller places the args immediately above the
saved return address, starting with the first arg.
For the JNI functions that takes var args, their prolog code will save the
var arg in the glue frame because the values in the register may be lost by
subsequent calls.
This method copies the var arg values that were saved earlier in glue frame into
the spill area of the original caller, thereby doing the work that the callee
normally performs in the AIX C convention.
NOTE: This method contains internal stack pointer.
For now we assume that the stack will not be relocatable while native code is running
because native code can hold an address into the stack, so this code is OK,
but this is an issue to be resolved later.
NOTE: this method assumes that it is immediately above the
invokeWithDotDotVarArg frame, the JNI frame, the glue frame and
the C caller frame in the respective order.
Therefore, this method will not work if called from anywhere else.
low address | fp | <- JNIEnvironment.getVarArgAddress | mid | | | | | |------| | fp | <- JNIEnvironment.invokeWithDotDotVarArg frame | mid | | ... | | | | | |------| | fp | <- JNI method frame | mid | | ... | | arg 0| args copied by JNI prolog (3 for static, nonvirtual, | arg 1| or 4 for virtual) | arg 2| | | | | |------| | fp | <- Native C caller frame |return| | arg 0| | arg 1| | arg 2| | arg 3| | arg 4| | arg 5| | arg 6| | arg 7| | arg 8| | arg 9| | | | | | | high address
skip4Args
- if true, the calling JNI function has 4 args before the vararg
if false, the calling JNI function has 3 args before the vararg
public static Object invokeWithVarArg(int methodID, Address argAddress, TypeReference expectReturnType) throws Exception
methodID
- the method IDargAddress
- a raw address for the variable argument list
Exception
public static Object invokeWithVarArg(Object obj, int methodID, Address argAddress, TypeReference expectReturnType, boolean skip4Args) throws Exception
obj
- the object instancemethodID
- the method IDargAddress
- a raw address for the variable argument listexpectReturnType
- the return type for checking purposeskip4Args
- received from the JNI function, passed on to Reflection.invoke()
Exception
public static Object invokeWithJValue(int methodID, Address argAddress, TypeReference expectReturnType) throws Exception
methodID
- id of MemberReferenceargAddress
- a raw address for the argument array
Exception
public static Object invokeWithJValue(Object obj, int methodID, Address argAddress, TypeReference expectReturnType, boolean skip4Args) throws Exception
obj
- the object instancemethodID
- id of MemberReferenceargAddress
- a raw address for the argument arrayexpectReturnType
- the return type for checking purposeskip4Args
- received from the JNI function, passed on to Reflection.invoke()
Exception
static Object packageAndInvoke(Object obj, int methodID, Address argAddress, TypeReference expectReturnType, boolean skip4Args, boolean isVarArg) throws Exception
obj
- the object instancemethodID
- id of MemberReferenceargAddress
- a raw address for the argument arrayexpectReturnType
- the return type for checking purposeskip4Args
- This flag is received from the JNI function and passed directly to
Reflection.invoke().
It is true if the actual method is to be invoked, which could be
from the superclass.
It is false if the method from the real class of the object
is to be invoked, which may not be the actual method specified by methodIDisVarArg
- This flag describes whether the array of parameters is in var arg format or
jvalue format
Exception
static Object[] packageParameterFromVarArg(RVMMethod targetMethod, Address argAddress)
targetMethod
- The target RVMMethod
argAddress
- an address into the C space for the array of jvalue unions;
each element is 2-word and holds the argument of the appropriate type
static Object[] packageParameterFromJValue(RVMMethod targetMethod, Address argAddress)
targetMethod
- The target RVMMethod
argAddress
- an address into the C space for the array of jvalue unions;
each element is 2-word and holds the argument of the appropriate type
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |