Search in sources :

Example 1 with IR

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);
}
Also used : IR(org.jikesrvm.compilers.opt.ir.IR) Test(org.junit.Test)

Example 2 with IR

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);
}
Also used : IR(org.jikesrvm.compilers.opt.ir.IR) Test(org.junit.Test)

Example 3 with 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);
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) IR(org.jikesrvm.compilers.opt.ir.IR) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) Test(org.junit.Test)

Example 4 with IR

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;
    }
}
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 5 with IR

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);
}
Also used : BitVector(org.jikesrvm.util.BitVector) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) IR(org.jikesrvm.compilers.opt.ir.IR)

Aggregations

IR (org.jikesrvm.compilers.opt.ir.IR)15 Test (org.junit.Test)10 OptOptions (org.jikesrvm.compilers.opt.OptOptions)5 NormalMethod (org.jikesrvm.classloader.NormalMethod)3 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)2 MIRInfo (org.jikesrvm.compilers.opt.ir.MIRInfo)2 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)1 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)1 BitVector (org.jikesrvm.util.BitVector)1