Search in sources :

Example 1 with MagicNotImplementedException

use of org.jikesrvm.compilers.opt.MagicNotImplementedException in project JikesRVM by JikesRVM.

the class OptimizingBootImageCompiler method compileMethod.

@Override
protected CompiledMethod compileMethod(NormalMethod method, TypeReference[] params) {
    if (method.hasNoOptCompileAnnotation()) {
        return baselineCompile(method);
    } else {
        CompiledMethod cm = null;
        OptimizingCompilerException escape = new OptimizingCompilerException(false);
        try {
            Callbacks.notifyMethodCompile(method, CompiledMethod.OPT);
            boolean include = match(method);
            if (!include) {
                throw escape;
            }
            int freeOptimizationPlan = getFreeOptimizationPlan();
            OptimizationPlanElement[] optimizationPlan = optimizationPlans.get(freeOptimizationPlan);
            CompilationPlan cp = new CompilationPlan(method, params, optimizationPlan, null, options.get(freeOptimizationPlan));
            cm = OptimizingCompiler.compile(cp);
            if (VM.BuildForAdaptiveSystem) {
                /* We can't accurately measure compilation time on Host JVM, so just approximate with DNA */
                int compilerId = CompilerDNA.getCompilerConstant(cp.options.getOptLevel());
                cm.setCompilationTime((float) CompilerDNA.estimateCompileTime(compilerId, method));
            }
            releaseOptimizationPlan(freeOptimizationPlan);
            return cm;
        } catch (OptimizingCompilerException e) {
            if (e.isFatal) {
                // An unexpected error when building the opt boot image should be fatal
                VM.sysWriteln("Error compiling method: " + method);
                e.printStackTrace();
                System.exit(EXIT_STATUS_OPT_COMPILER_FAILED);
            } else {
                boolean printMsg = true;
                boolean expected = false;
                if (e instanceof MagicNotImplementedException) {
                    printMsg = !((MagicNotImplementedException) e).isExpected;
                    expected = ((MagicNotImplementedException) e).isExpected;
                }
                if (e == escape) {
                    printMsg = false;
                }
                if (printMsg) {
                    if (e.toString().indexOf("method excluded") >= 0) {
                        String msg = "BootImageCompiler: " + method + " excluded from opt-compilation\n";
                        VM.sysWrite(msg);
                    } else {
                        String msg = "BootImageCompiler: can't optimize \"" + method + "\" (error was: " + e + ")\n";
                        VM.sysWrite(msg);
                    }
                } else if (!expected && e != escape) {
                    // when compiling the boot image as fatal.
                    throw new Error(e);
                }
            }
            return baselineCompile(method);
        }
    }
}
Also used : OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) MagicNotImplementedException(org.jikesrvm.compilers.opt.MagicNotImplementedException) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 2 with MagicNotImplementedException

use of org.jikesrvm.compilers.opt.MagicNotImplementedException in project JikesRVM by JikesRVM.

the class SimpleEscape method performSimpleEscapeAnalysis.

private static void performSimpleEscapeAnalysis(RVMMethod m, OptOptions options) {
    if (!options.ESCAPE_SIMPLE_IPA) {
        return;
    }
    // do not perform for unloaded methods
    MethodSummary summ = SummaryDatabase.findMethodSummary(m);
    if (summ != null) {
        // do not attempt to perform escape analysis recursively
        if (summ.inProgress()) {
            return;
        }
    }
    CompilationPlan plan = new CompilationPlan((NormalMethod) m, escapePlan, null, options);
    plan.analyzeOnly = true;
    try {
        OptimizingCompiler.compile(plan);
    } catch (MagicNotImplementedException e) {
        // summary stays at bottom
        summ.setInProgress(false);
    }
}
Also used : CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) MagicNotImplementedException(org.jikesrvm.compilers.opt.MagicNotImplementedException)

Aggregations

MagicNotImplementedException (org.jikesrvm.compilers.opt.MagicNotImplementedException)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)1 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)1 CompilationPlan (org.jikesrvm.compilers.opt.driver.CompilationPlan)1