use of org.jikesrvm.compilers.opt.ir.IR in project JikesRVM by JikesRVM.
the class SplitBasicBlockTest method doesNotCreateNewBlocksWhenNumberOfInstructionsMatchesLimit.
@Test
public void doesNotCreateNewBlocksWhenNumberOfInstructionsMatchesLimit() {
int maxInstPerBlock = 2;
IR ir = createIRWithEmptyCFG(maxInstPerBlock);
int nodeNumberBefore = ir.cfg.numberOfNodes();
addNumberOfInstructionsToBlock(ir, 2);
splitPhase.perform(ir);
int nodeNumberAfter = ir.cfg.numberOfNodes();
assertThat(nodeNumberAfter, is(nodeNumberBefore));
assertThatInstructionCountForEachBlockIsAtMost(ir, maxInstPerBlock);
}
use of org.jikesrvm.compilers.opt.ir.IR in project JikesRVM by JikesRVM.
the class SplitBasicBlockTest method throwsOptimizingCompilerExceptionWhenLimitIsInvalid.
@Test(expected = OptimizingCompilerException.class)
public void throwsOptimizingCompilerExceptionWhenLimitIsInvalid() {
int maxInstPerBlock = 0;
IR ir = createIRWithEmptyCFG(maxInstPerBlock);
addNumberOfInstructionsToBlock(ir, 1);
splitPhase.perform(ir);
}
use of org.jikesrvm.compilers.opt.ir.IR in project JikesRVM by JikesRVM.
the class SplitBasicBlockTest method branchesAtTheEndOfTheBlockDoNotCountAsIntructions.
@Test
public void branchesAtTheEndOfTheBlockDoNotCountAsIntructions() {
int maxInstPerBlock = 3;
IR ir = createIRWithEmptyCFG(maxInstPerBlock);
int nodeNumberBefore = ir.cfg.numberOfNodes();
Enumeration<BasicBlock> blocks = ir.getBasicBlocks();
while (blocks.hasMoreElements()) {
BasicBlock bb = blocks.nextElement();
bb.appendInstruction(Empty.create(FENCE));
bb.appendInstruction(Empty.create(FENCE));
Instruction i = IfCmp.create(INT_IFCMP, null, null, null, null, null, null);
bb.appendInstruction(i);
}
splitPhase.perform(ir);
int nodeNumberAfter = ir.cfg.numberOfNodes();
assertThat(nodeNumberAfter, is(nodeNumberBefore));
assertThatInstructionCountForEachBlockIsAtMost(ir, maxInstPerBlock);
}
use of org.jikesrvm.compilers.opt.ir.IR 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.ir.IR in project JikesRVM by JikesRVM.
the class DominatorOperator method evaluate.
/**
* Evaluate an equation with the MEET operation
* @param operands the lhs(operands[0]) and rhs(operands[1])
* of the equation.
* @return {@code true} if the value of the lhs changes. {@code false} otherwise
*/
@Override
public boolean evaluate(DF_LatticeCell[] operands) {
DominatorCell lhs = (DominatorCell) operands[0];
IR ir = lhs.ir;
BasicBlock bb = lhs.block;
BitVector oldSet = lhs.dominators.dup();
BitVector newDominators = new BitVector(ir.getMaxBasicBlockNumber() + 1);
if (operands.length > 1) {
if (operands[1] != null) {
newDominators.or(((DominatorCell) operands[1]).dominators);
}
}
for (int i = 2; i < operands.length; i++) {
newDominators.and(((DominatorCell) operands[i]).dominators);
}
newDominators.set(bb.getNumber());
lhs.dominators = newDominators;
return !lhs.dominators.equals(oldSet);
}
Aggregations