Search in sources :

Example 41 with OptOptions

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

the class OptTestHarness method compileMethodsInVector.

private void compileMethodsInVector() {
    // Compile all baseline methods first
    int size = baselineMethodVector.size();
    output.sysOutPrintln("Compiling " + size + " methods baseline");
    // Compile all methods in baseline vector
    for (int i = 0; i < size; i++) {
        NormalMethod method = (NormalMethod) baselineMethodVector.get(i);
        CompiledMethod cm = null;
        cm = BaselineCompiler.compile(method);
        method.replaceCompiledMethod(cm);
        if (printCodeAddress) {
            output.sysOutPrintln(compiledMethodMessage(method));
        }
    }
    // Now compile all methods in opt vector
    size = optMethodVector.size();
    output.sysOutPrintln("Compiling " + size + " methods opt");
    for (int i = 0; i < size; i++) {
        NormalMethod method = (NormalMethod) optMethodVector.get(i);
        OptOptions opts = optOptionsVector.get(i);
        try {
            CompiledMethod cm = null;
            CompilationPlan cp = new CompilationPlan(method, OptimizationPlanner.createOptimizationPlan(opts), null, opts);
            cm = OptimizingCompiler.compile(cp);
            method.replaceCompiledMethod(cm);
            if (printCodeAddress) {
                output.sysOutPrintln(compiledMethodMessage(method));
            }
        } catch (OptimizingCompilerException e) {
            if (e.isFatal && VM.ErrorsFatal) {
                e.printStackTrace();
                VM.sysFail("Internal vm error: " + e);
            } else {
                output.sysErrPrintln("SKIPPING opt-compilation of " + method + ":\n  " + e.getMessage());
                if (opts.PRINT_METHOD) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 42 with OptOptions

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

the class OptimizationPlanner method HIROptimizations.

/**
 * This method defines the optimization plan elements that
 * are to be performed on the HIR.
 *
 * @param p the plan under construction
 */
private static void HIROptimizations(ArrayList<OptimizationPlanElement> p) {
    // Various large-scale CFG transformations.
    // Do these very early in the pipe so that all HIR opts can benefit.
    composeComponents(p, "CFG Transformations", new Object[] { // tail recursion elimination
    new TailRecursionElimination(), // Assumption: none of these are active at O0.
    new OptimizationPlanCompositeElement("Basic Block Frequency Estimation", new Object[] { new BuildLST(), new EstimateBlockFrequencies() }) {

        @Override
        public boolean shouldPerform(OptOptions options) {
            return options.getOptLevel() >= 1;
        }
    }, // CFG splitting
    new StaticSplitting(), // restructure loops
    new CFGTransformations(), // Loop unrolling
    new LoopUnrolling(), new BranchOptimizations(1, true, true) });
    // Use the LST to insert yieldpoints and estimate
    // basic block frequency from branch probabilities
    composeComponents(p, "CFG Structural Analysis", new Object[] { new BuildLST(), new YieldPoints(), new EstimateBlockFrequencies() });
    // Simple flow-insensitive optimizations
    addComponent(p, new Simple(1, true, true, false, false));
    // Simple escape analysis and related transformations
    addComponent(p, new EscapeTransformations());
    // Perform peephole branch optimizations to clean-up before SSA stuff
    addComponent(p, new BranchOptimizations(1, true, true));
    // SSA meta-phase
    SSAinHIR(p);
    // Perform local copy propagation for a factored basic block.
    addComponent(p, new LocalCopyProp());
    // Perform local constant propagation for a factored basic block.
    addComponent(p, new LocalConstantProp());
    // Perform local common-subexpression elimination for a
    // factored basic block.
    addComponent(p, new LocalCSE(true));
    // Flow-insensitive field analysis
    addComponent(p, new FieldAnalysis());
    if (VM.BuildForAdaptiveSystem) {
        // Insert counter on each method prologue
        // Insert yieldpoint counters
        addComponent(p, new InsertYieldpointCounters());
        // Insert counter on each HIR instruction
        addComponent(p, new InsertInstructionCounters());
        // Insert method invocation counters
        addComponent(p, new InsertMethodInvocationCounter());
    }
}
Also used : CFGTransformations(org.jikesrvm.compilers.opt.controlflow.CFGTransformations) LocalCopyProp(org.jikesrvm.compilers.opt.LocalCopyProp) EstimateBlockFrequencies(org.jikesrvm.compilers.opt.controlflow.EstimateBlockFrequencies) InsertMethodInvocationCounter(org.jikesrvm.adaptive.recompilation.instrumentation.InsertMethodInvocationCounter) OptOptions(org.jikesrvm.compilers.opt.OptOptions) BuildLST(org.jikesrvm.compilers.opt.controlflow.BuildLST) EscapeTransformations(org.jikesrvm.compilers.opt.escape.EscapeTransformations) LoopUnrolling(org.jikesrvm.compilers.opt.controlflow.LoopUnrolling) StaticSplitting(org.jikesrvm.compilers.opt.controlflow.StaticSplitting) Simple(org.jikesrvm.compilers.opt.Simple) LocalCSE(org.jikesrvm.compilers.opt.LocalCSE) InsertYieldpointCounters(org.jikesrvm.adaptive.recompilation.instrumentation.InsertYieldpointCounters) YieldPoints(org.jikesrvm.compilers.opt.controlflow.YieldPoints) FieldAnalysis(org.jikesrvm.compilers.opt.FieldAnalysis) TailRecursionElimination(org.jikesrvm.compilers.opt.controlflow.TailRecursionElimination) LocalConstantProp(org.jikesrvm.compilers.opt.LocalConstantProp) InsertInstructionCounters(org.jikesrvm.adaptive.recompilation.instrumentation.InsertInstructionCounters) BranchOptimizations(org.jikesrvm.compilers.opt.controlflow.BranchOptimizations)

Example 43 with OptOptions

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

the class OptimizingBootImageCompiler method getFreeOptimizationPlan.

/**
 * Return an optimization plan that isn't in use
 * @return optimization plan
 */
private int getFreeOptimizationPlan() {
    // Find plan
    synchronized (optimizationPlanLocks) {
        for (int i = 0; i < optimizationPlanLocks.size(); i++) {
            if (!optimizationPlanLocks.get(i)) {
                optimizationPlanLocks.set(i, Boolean.TRUE);
                return i;
            }
        }
        // Find failed, so create new plan
        OptimizationPlanElement[] optimizationPlan;
        OptOptions cloneOptions = masterOptions.dup();
        optimizationPlan = OptimizationPlanner.createOptimizationPlan(cloneOptions);
        optimizationPlans.add(optimizationPlan);
        optimizationPlanLocks.add(Boolean.TRUE);
        options.add(cloneOptions);
        return optimizationPlanLocks.size() - 1;
    }
}
Also used : OptOptions(org.jikesrvm.compilers.opt.OptOptions)

Example 44 with OptOptions

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

the class OptimizingCompiler method compile.

// //////////////////////////////////////////
// Public interface for compiling a method
// //////////////////////////////////////////
/**
 * Invoke the opt compiler to execute a compilation plan.
 *
 * @param cp the compilation plan to be executed
 * @return the CompiledMethod object that is the result of compilation
 */
public static CompiledMethod compile(CompilationPlan cp) {
    NormalMethod method = cp.method;
    OptOptions options = cp.options;
    checkSupported(method, options);
    try {
        printMethodMessage(method, options);
        IR ir = cp.execute();
        // if doing analysis only, don't try to return an object
        if (cp.analyzeOnly || cp.irGeneration) {
            return null;
        }
        // now that we're done compiling, give the specialization
        // system a chance to eagerly compile any specialized version
        // that are pending.  TODO: use lazy compilation with specialization.
        SpecializationDatabase.doDeferredSpecializations();
        ir.compiledMethod.compileComplete(ir.MIRInfo.machinecode);
        return ir.compiledMethod;
    } catch (OptimizingCompilerException e) {
        throw e;
    } catch (Throwable e) {
        fail(e, method);
        return null;
    }
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) IR(org.jikesrvm.compilers.opt.ir.IR) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException)

Example 45 with OptOptions

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

the class MIROptimizationPlanner method MIR2MC.

/**
 * This method defines the optimization plan elements that
 * are to be performed to convert PowerPC MIR into
 * ready-to-execute machinecode (and associated mapping tables).
 *
 * @param p the plan under construction
 */
private static void MIR2MC(ArrayList<OptimizationPlanElement> p) {
    // MANDATORY: Final assembly
    addComponent(p, new IRPrinter("Final MIR") {

        @Override
        public boolean shouldPerform(OptOptions options) {
            return options.PRINT_FINAL_MIR;
        }
    });
    addComponent(p, new ConvertMIRtoMC());
}
Also used : ConvertMIRtoMC(org.jikesrvm.compilers.opt.mir2mc.ConvertMIRtoMC) OptOptions(org.jikesrvm.compilers.opt.OptOptions) IRPrinter(org.jikesrvm.compilers.opt.driver.IRPrinter)

Aggregations

OptOptions (org.jikesrvm.compilers.opt.OptOptions)70 Test (org.junit.Test)48 NormalMethod (org.jikesrvm.classloader.NormalMethod)45 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)32 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)29 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)27 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)19 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)14 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 TypeReference (org.jikesrvm.classloader.TypeReference)12 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)12 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)12 Register (org.jikesrvm.compilers.opt.ir.Register)12 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8 ClassConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand)7 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)7