Search in sources :

Example 16 with MethodReference

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

the class PartialCallGraph method getCallTargets.

/**
 * @param caller caller method
 * @param bcIndex bytecode index in caller method
 * @return the WeightedCallTargets currently associated with the
 *         given caller bytecodeIndex pair.
 */
public WeightedCallTargets getCallTargets(RVMMethod caller, int bcIndex) {
    MethodReference callerRef = caller.getMemberRef().asMethodReference();
    UnResolvedWeightedCallTargets unresolvedTargets = unresolvedCallGraph.get(new UnResolvedCallSite(callerRef, bcIndex));
    if (unresolvedTargets != null) {
        final RVMMethod fCaller = caller;
        final int fBcIndex = bcIndex;
        final PartialCallGraph pg = this;
        unresolvedTargets.visitTargets(new UnResolvedWeightedCallTargets.Visitor() {

            @Override
            public void visit(MethodReference calleeRef, double weight) {
                RVMMethod callee = calleeRef.getResolvedMember();
                if (callee != null) {
                    pg.incrementEdge(fCaller, fBcIndex, callee, (float) weight);
                }
            }
        });
    }
    return getCallTargets(new CallSite(caller, bcIndex));
}
Also used : UnResolvedWeightedCallTargets(org.jikesrvm.adaptive.util.UnResolvedWeightedCallTargets) RVMMethod(org.jikesrvm.classloader.RVMMethod) MethodReference(org.jikesrvm.classloader.MethodReference) UnResolvedCallSite(org.jikesrvm.adaptive.util.UnResolvedCallSite) UnResolvedCallSite(org.jikesrvm.adaptive.util.UnResolvedCallSite)

Example 17 with MethodReference

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

the class Class method getEnclosingConstructor.

public Constructor<?> getEnclosingConstructor() {
    if (!(isAnonymousClass() || isLocalClass())) {
        return null;
    }
    MethodReference enclosingMethodRef = type.asClass().getEnclosingMethod();
    if (enclosingMethodRef == null) {
        return null;
    }
    RVMMethod method = enclosingMethodRef.resolve();
    if (!method.isObjectInitializer()) {
        return null;
    }
    return JikesRVMSupport.createConstructor(method);
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) MethodReference(org.jikesrvm.classloader.MethodReference)

Example 18 with MethodReference

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

the class Barriers method arrayStoreBarrierHelper.

/**
 * Helper function for primitive array stores
 *
 * @param asm the assembler to generate the code in
 * @param compiler the compiler instance to ensure correct parameter passing
 * @param barrier the designated barrier
 */
private static void arrayStoreBarrierHelper(Assembler asm, BaselineCompilerImpl compiler, NormalMethod barrier) {
    // on entry java stack contains ...|target_array_ref|array_index|value_to_store|
    // Use the correct calling convention to pass parameters by register and the stack
    // (size of value_to_store varies by type of array store)
    MethodReference method = barrier.getMemberRef().asMethodReference();
    compiler.genParameterRegisterLoad(method, false);
    // call the actual write barrier
    asm.generateJTOCcall(barrier.getOffset());
}
Also used : MethodReference(org.jikesrvm.classloader.MethodReference)

Example 19 with MethodReference

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

the class Barriers method putfieldStoreBarrierHelper.

/**
 * Private helper method for primitive putfields
 *
 * @param asm the assembler to generate the code in
 * @param compiler the compiler instance to ensure correct parameter passing
 * @param fieldOffset offset of the field
 * @param locationMetadata meta-data about the location
 * @param barrier the barrier method to call
 */
@Inline
private static void putfieldStoreBarrierHelper(Assembler asm, BaselineCompilerImpl compiler, Offset fieldOffset, int locationMetadata, NormalMethod barrier) {
    // on entry the java stack contains... |object|value|
    asm.emitPUSH_Imm(fieldOffset.toInt());
    asm.emitPUSH_Imm(locationMetadata);
    // Use the correct calling convention to pass parameters by register and the stack
    // (size of value varies by type of putfield)
    MethodReference method = barrier.getMemberRef().asMethodReference();
    compiler.genParameterRegisterLoad(method, false);
    genNullCheck(asm, T0);
    asm.generateJTOCcall(barrier.getOffset());
}
Also used : MethodReference(org.jikesrvm.classloader.MethodReference) Inline(org.vmmagic.pragma.Inline)

Example 20 with MethodReference

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

the class JNIGenericHelpers method callMethodJValuePtr.

/**
 * Dispatch method call, arguments in jvalue*
 * @param env the JNI environemnt for the thread
 * @param objJREF a JREF index for the object
 * @param methodID id of a MethodReference
 * @param argAddress address of an array of jvalues (jvalue*)
 * @param expectedReturnType a type reference for the expected return type
 * @param nonVirtual should invocation be of the given method or should we use virtual dispatch on the object?
 * @return return value of the method (boxed if primitive)
 * @throws InvocationTargetException when reflective invocation fails
 */
protected static Object callMethodJValuePtr(JNIEnvironment env, int objJREF, int methodID, Address argAddress, TypeReference expectedReturnType, boolean nonVirtual) throws InvocationTargetException {
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        MethodReference mr = MemberReference.getMethodRef(methodID);
        Object[] args = packageParametersFromJValuePtr(mr, argAddress);
        return callMethod(obj, mr, args, expectedReturnType, nonVirtual);
    } catch (Throwable unexpected) {
        if (JNIFunctions.traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : MethodReference(org.jikesrvm.classloader.MethodReference)

Aggregations

MethodReference (org.jikesrvm.classloader.MethodReference)23 RVMMethod (org.jikesrvm.classloader.RVMMethod)8 Address (org.vmmagic.unboxed.Address)7 TypeReference (org.jikesrvm.classloader.TypeReference)6 NoInline (org.vmmagic.pragma.NoInline)4 FieldReference (org.jikesrvm.classloader.FieldReference)3 MemberReference (org.jikesrvm.classloader.MemberReference)3 RVMClass (org.jikesrvm.classloader.RVMClass)3 Offset (org.vmmagic.unboxed.Offset)3 RVMType (org.jikesrvm.classloader.RVMType)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 ExecutionState (org.jikesrvm.osr.ExecutionState)2 OSRMapIterator (org.jikesrvm.osr.OSRMapIterator)2 VariableElement (org.jikesrvm.osr.VariableElement)2 NoOptCompile (org.vmmagic.pragma.NoOptCompile)2 IOException (java.io.IOException)1 UnResolvedCallSite (org.jikesrvm.adaptive.util.UnResolvedCallSite)1 UnResolvedWeightedCallTargets (org.jikesrvm.adaptive.util.UnResolvedWeightedCallTargets)1 BytecodeStream (org.jikesrvm.classloader.BytecodeStream)1 ExceptionHandlerMap (org.jikesrvm.classloader.ExceptionHandlerMap)1