Search in sources :

Example 26 with RVMMethod

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

the class MethodCountData method report.

/**
 *  Print the counted (nonzero) methods.
 *  To get a sorted list, pipe the output through sort -n -r.
 */
@Override
public synchronized void report() {
    RVMThread.dumpLock.lockNoHandshake();
    VM.sysWriteln("Method counts: A total of " + totalCountsTaken + " samples");
    for (int i = 1; i < nextIndex; i++) {
        double percent = 100 * countsToHotness(counts[i]);
        CompiledMethod cm = CompiledMethods.getCompiledMethod(cmids[i]);
        VM.sysWrite(counts[i] + " (" + percent + "%) ");
        if (cm == null) {
            // Compiled Method Obsolete
            VM.sysWriteln("OBSOLETE");
        } else {
            if (cm.getCompilerType() == CompiledMethod.TRAP) {
                VM.sysWriteln("<Hardware Trap Frame>");
            } else {
                RVMMethod m = cm.getMethod();
                VM.sysWrite(m);
                if (m.getDeclaringClass().isInBootImage()) {
                    VM.sysWrite("\tBOOT");
                }
            }
            VM.sysWriteln();
        }
    }
    RVMThread.dumpLock.unlock();
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 27 with RVMMethod

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

the class DynamicCallFileInfoReader method readOneCallSiteAttribute.

private static void readOneCallSiteAttribute(StringTokenizer parser, boolean boot) {
    String firstToken = parser.nextToken();
    if (firstToken.equals("CallSite")) {
        try {
            MemberReference callerKey = MemberReference.parse(parser, boot);
            if (callerKey == null)
                return;
            MethodReference callerRef = callerKey.asMethodReference();
            RVMMethod caller, callee;
            caller = getMethod(callerRef);
            // serves as doco - token skipped
            @SuppressWarnings("unused") int callerSize = Integer.parseInt(parser.nextToken());
            int bci = Integer.parseInt(parser.nextToken());
            MemberReference calleeKey = MemberReference.parse(parser, boot);
            if (calleeKey == null)
                return;
            MethodReference calleeRef = calleeKey.asMethodReference();
            callee = getMethod(calleeRef);
            // serves as doco - token skipped
            @SuppressWarnings("unused") int calleeSize = Integer.parseInt(parser.nextToken());
            // skip "weight:"
            parser.nextToken();
            float weight = Float.parseFloat(parser.nextToken());
            if ((caller == null) || (callee == null)) {
                Controller.dcg.incrementUnResolvedEdge(callerRef, bci, calleeRef, weight);
            } else {
                Controller.dcg.incrementEdge(caller, bci, callee, weight);
            }
        } catch (Exception e) {
            VM.sysWriteln("Caught exception: " + e);
        }
    } else {
        VM.sysFail("Format error in dynamic call graph file");
    }
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) MemberReference(org.jikesrvm.classloader.MemberReference) MethodReference(org.jikesrvm.classloader.MethodReference) IOException(java.io.IOException)

Example 28 with RVMMethod

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

the class TailRecursionEliminationTest method callsWithNoTailCallEliminationAnnotationArentSubjectToOptimization.

@Test
public void callsWithNoTailCallEliminationAnnotationArentSubjectToOptimization() throws Exception {
    Class<?>[] types = {};
    RVMMethod m = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithNoTailCallEliminationAnnotation", types);
    MethodOperand methOp = MethodOperand.STATIC(m);
    Instruction call = Call.create(CALL, null, null, methOp, 0);
    assertFalse(tailRecursionElimination.allowedToOptimize(call));
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) Test(org.junit.Test)

Example 29 with RVMMethod

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

the class OptTestHarness method findDeclaredOrFirstMethod.

/**
 * Finds a method, either one with a given descriptor or the first matching
 * one in in the given class.
 * @param klass the class to search
 * @param methname the method's name
 * @param methdesc a descriptor of the method's signature if a specific
 *  method is desired or "-" to find the first method with the given name
 * @return the method or {@code null} if no method was found
 */
RVMMethod findDeclaredOrFirstMethod(RVMClass klass, String methname, String methdesc) {
    if (klass == null)
        return null;
    Atom methodName = Atom.findOrCreateAsciiAtom(methname);
    Atom methodDesc = "-".equals(methdesc) ? null : Atom.findOrCreateAsciiAtom(methdesc);
    for (RVMMethod method : klass.getDeclaredMethods()) {
        if (method.getName() == methodName && ((methodDesc == null) || (methodDesc == method.getDescriptor()))) {
            return method;
        }
    }
    if (methodDesc == null) {
        output.sysErrPrintln("No method named " + methodName + " found in class " + klass);
    } else {
        output.sysErrPrintln("No method matching " + methodName + " " + methodDesc + " found in class " + klass);
    }
    return null;
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) Atom(org.jikesrvm.classloader.Atom)

Example 30 with RVMMethod

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

the class OptTestHarness method processOptionString.

private void processOptionString(String[] args) {
    for (int i = 0, n = args.length; i < n; i++) {
        try {
            String arg = args[i];
            if (arg.startsWith("-oc:") && options.processAsOption("-X:irc:", arg.substring(4))) {
            // handled in processAsOption
            } else if ("-useBootOptions".equals(arg)) {
                OptimizingCompiler.setBootOptions(options);
            } else if ("-longcommandline".equals(arg)) {
                // the -longcommandline option reads options from a file.
                String fileName = args[++i];
                String[] optionString = fileAccess.readOptionStringFromFile(fileName);
                processOptionString(optionString);
            } else if ("+baseline".equals(arg)) {
                useBaselineCompiler = true;
            } else if ("-baseline".equals(arg)) {
                useBaselineCompiler = false;
            } else if ("-load".equals(arg)) {
                loadClass(args[++i]);
            } else if ("-class".equals(arg)) {
                RVMClass klass = loadClass(args[++i]);
                processClass(klass, options);
                duplicateOptions();
            } else if ("-method".equals(arg) || "-methodOpt".equals(arg) || "-methodBase".equals(arg)) {
                // Default for this method is determined by BASELINE var
                boolean isBaseline = useBaselineCompiler;
                // Unless specified by these options
                if ("-methodOpt".equals(arg)) {
                    isBaseline = false;
                }
                if ("-methodBase".equals(arg)) {
                    isBaseline = true;
                }
                RVMClass klass = null;
                try {
                    klass = loadClass(args[++i]);
                } catch (Exception e) {
                    output.sysErrPrintln("WARNING: Skipping method from " + args[i]);
                }
                if (klass == null)
                    continue;
                String name = args[++i];
                String desc = args[++i];
                RVMMethod method = findDeclaredOrFirstMethod(klass, name, desc);
                if (method == null || method.isAbstract() || method.isNative()) {
                    output.sysErrPrintln("WARNING: Skipping method " + args[i - 2] + "." + name);
                } else {
                    processMethod(method, options, isBaseline);
                }
                duplicateOptions();
            } else if ("-performance".equals(arg)) {
                perf = new Performance(output);
            } else if ("-disableClassLoading".equals(arg)) {
                disableClassloading = true;
            } else if ("-er".equals(arg)) {
                executeWithReflection = true;
                RVMClass klass = loadClass(args[++i]);
                String name = args[++i];
                String desc = args[++i];
                NormalMethod method = (NormalMethod) findDeclaredOrFirstMethod(klass, name, desc);
                CompiledMethod cm = null;
                if (method == null) {
                    output.sysErrPrintln("Canceling further option processing to prevent assertion failures.");
                    return;
                }
                if (useBaselineCompiler) {
                    cm = BaselineCompiler.compile(method);
                } else {
                    CompilationPlan cp = new CompilationPlan(method, OptimizationPlanner.createOptimizationPlan(options), null, options);
                    try {
                        cm = OptimizingCompiler.compile(cp);
                    } catch (Throwable e) {
                        output.sysErrPrintln("SKIPPING method:" + method + "Due to exception: " + e);
                    }
                }
                if (cm != null) {
                    method.replaceCompiledMethod(cm);
                    if (printCodeAddress) {
                        output.sysOutPrintln(compiledMethodMessage(method));
                    }
                }
                TypeReference[] argDesc = method.getDescriptor().parseForParameterTypes(klass.getClassLoader());
                Object[] reflectMethodArgs = new Object[argDesc.length];
                i = parseMethodArgs(argDesc, args, i, reflectMethodArgs);
                java.lang.reflect.Method reflectoid = java.lang.reflect.JikesRVMSupport.createMethod(method);
                reflectoidVector.add(reflectoid);
                reflectMethodVector.add(method);
                reflectMethodArgsVector.add(reflectMethodArgs);
                duplicateOptions();
            } else if ("-main".equals(arg)) {
                executeMainMethod = true;
                i++;
                mainClass = loadClass(args[i]);
                i++;
                mainArgs = new String[args.length - i];
                for (int j = 0, z = mainArgs.length; j < z; j++) {
                    mainArgs[j] = args[i + j];
                }
                break;
            } else {
                output.sysErrPrintln("Unrecognized argument: " + arg + " - ignored");
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            output.sysErrPrintln("Uncaught ArrayIndexOutOfBoundsException, possibly" + " not enough command-line arguments - aborting");
            printFormatString();
            e.printStackTrace(output.getSystemErr());
            break;
        } catch (Exception e) {
            output.sysErrPrintln(e.toString());
            e.printStackTrace(output.getSystemErr());
            break;
        }
    }
}
Also used : CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) InvocationTargetException(java.lang.reflect.InvocationTargetException) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) RVMClass(org.jikesrvm.classloader.RVMClass) RVMMethod(org.jikesrvm.classloader.RVMMethod) NormalMethod(org.jikesrvm.classloader.NormalMethod) TypeReference(org.jikesrvm.classloader.TypeReference) Method(java.lang.reflect.Method)

Aggregations

RVMMethod (org.jikesrvm.classloader.RVMMethod)86 RVMClass (org.jikesrvm.classloader.RVMClass)29 TypeReference (org.jikesrvm.classloader.TypeReference)17 RVMType (org.jikesrvm.classloader.RVMType)15 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)14 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 Atom (org.jikesrvm.classloader.Atom)11 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)11 Offset (org.vmmagic.unboxed.Offset)11 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)10 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)10 Address (org.vmmagic.unboxed.Address)9 MethodReference (org.jikesrvm.classloader.MethodReference)8 NormalMethod (org.jikesrvm.classloader.NormalMethod)8 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8 Method (java.lang.reflect.Method)7 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)7 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)7 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)7