Search in sources :

Example 11 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method GetStaticObjectField.

/**
 * GetStaticObjectField: read a static field of type Object
 * @param env A JREF index for the JNI environment object
 * @param classJREF a JREF index for the RVMClass object
 * @param fieldID the id for the RVMField that describes this field
 * @return the value of the Object field, converted to a JREF index
 *         or 0 if the fieldID is incorrect
 */
private static int GetStaticObjectField(JNIEnvironment env, int classJREF, int fieldID) {
    if (traceJNI)
        VM.sysWriteln("JNI called: GetStaticObjectField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        Object value = field.getObjectUnchecked(null);
        return env.pushJNIRef(value);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 12 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method SetStaticBooleanField.

/**
 * SetStaticBooleanField:  set a static field of type boolean
 * @param env A JREF index for the JNI environment object
 * @param classJREF A JREF index for the RVMClass object
 * @param fieldID the id for the RVMField that describes this field
 * @param fieldValue  The value to assign
 */
private static void SetStaticBooleanField(JNIEnvironment env, int classJREF, int fieldID, boolean fieldValue) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetStaticBooleanField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setBooleanValueUnchecked(null, fieldValue);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 13 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method SetStaticFloatField.

/**
 * SetStaticFloatField:  set a static field of type float
 * @param env A JREF index for the JNI environment object
 * @param classJREF a JREF index for the RVMClass object
 * @param fieldID the id for the RVMField that describes this field
 * @param fieldValue  The value to assign
 */
private static void SetStaticFloatField(JNIEnvironment env, int classJREF, int fieldID, float fieldValue) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetStaticFloatField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setFloatValueUnchecked(null, fieldValue);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 14 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method SetStaticShortField.

/**
 * SetStaticShortField:  set a static field of type short
 * @param env A JREF index for the JNI environment object
 * @param classJREF a JREF index for the RVMClass object
 * @param fieldID the id for the RVMField that describes this field
 * @param fieldValue  The value to assign
 */
private static void SetStaticShortField(JNIEnvironment env, int classJREF, int fieldID, short fieldValue) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetStaticShortField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setShortValueUnchecked(null, fieldValue);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 15 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method GetBooleanField.

/**
 * GetBooleanField: read an instance field of type boolean
 * @param env A JREF index for the JNI environment object
 * @param objJREF a JREF index for the target object
 * @param fieldID the id for the RVMField that describes this field
 * @return the value of the boolean field, or 0 if the fieldID is incorrect
 */
private static int GetBooleanField(JNIEnvironment env, int objJREF, int fieldID) {
    if (traceJNI)
        VM.sysWriteln("JNI called: GetBooleanField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        return field.getBooleanValueUnchecked(obj) ? 1 : 0;
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Aggregations

RVMField (org.jikesrvm.classloader.RVMField)80 TypeReference (org.jikesrvm.classloader.TypeReference)21 Offset (org.vmmagic.unboxed.Offset)14 RVMClass (org.jikesrvm.classloader.RVMClass)12 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)9 Field (java.lang.reflect.Field)8 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)8 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)8 Atom (org.jikesrvm.classloader.Atom)7 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)6 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)6 RVMType (org.jikesrvm.classloader.RVMType)5 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)5 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)5 Address (org.vmmagic.unboxed.Address)5 FieldReference (org.jikesrvm.classloader.FieldReference)4 RVMMethod (org.jikesrvm.classloader.RVMMethod)4 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)4 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)4 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)4