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();
}
}
}
}
}
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());
}
}
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;
}
}
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;
}
}
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());
}
Aggregations