Search in sources :

Example 66 with Operand

use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.

the class GenerationContextTest method invalidReceiverCausesException.

@Test(expected = OptimizingCompilerException.class)
public void invalidReceiverCausesException() throws Exception {
    NormalMethod nm = getNormalMethodForTest("methodForInliningTests");
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
    NormalMethod callee = getNormalMethodForTest("emptyInstanceMethodWithoutAnnotations");
    MethodOperand methOp = MethodOperand.VIRTUAL(callee.getMemberRef().asMethodReference(), callee);
    Instruction callInstr = Call.create(CALL, null, null, methOp, 1);
    Operand receiver = new InvalidReceiverOperand();
    Call.setParam(callInstr, 0, receiver);
    callInstr.setPosition(new InlineSequence(nm));
    ExceptionHandlerBasicBlockBag ebag = getMockEbag();
    gc.createChildContext(ebag, callee, callInstr);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) ClassConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) Test(org.junit.Test)

Example 67 with Operand

use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.

the class GenerationContextTest method assertThatGuardIsCorrectForMonitorEnter.

private void assertThatGuardIsCorrectForMonitorEnter(Instruction inst) {
    Operand guard = MonitorOp.getGuard(inst);
    assertTrue(guard.similar(new TrueGuardOperand()));
}
Also used : MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) ClassConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)

Example 68 with Operand

use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.

the class OperandStackTest method getFromTopWithXReturnsItemAtPlaceXFromTheTopOfTheStack.

@Test
public void getFromTopWithXReturnsItemAtPlaceXFromTheTopOfTheStack() throws Exception {
    createOperandStackWithSize(3);
    Operand bottom = mockOperand();
    stack.push(bottom);
    Operand middle = mockOperand();
    stack.push(middle);
    Operand top = mockOperand();
    stack.push(top);
    Operand topFromStack = stack.getFromTop(0);
    assertThat(topFromStack, sameInstance(top));
    Operand midldeFromStack = stack.getFromTop(1);
    assertThat(midldeFromStack, sameInstance(middle));
    Operand bottomFromStack = stack.getFromTop(2);
    assertThat(bottomFromStack, sameInstance(bottom));
}
Also used : Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Test(org.junit.Test)

Example 69 with Operand

use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.

the class OperandStackTest method getFromBottomOnEmptyStackReturnsNull.

@Test
public void getFromBottomOnEmptyStackReturnsNull() throws Exception {
    createOperandStackWithSize(1);
    Operand fromStack = stack.getFromBottom(0);
    assertNull(fromStack);
}
Also used : Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Test(org.junit.Test)

Example 70 with Operand

use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.

the class ConvertToLowLevelIR method lookup.

/**
 * Expand a lookupswitch.
 * @param switchInstr  The instruction to expand
 * @param ir           The containing IR
 * @return the next {@link Instruction} after the generated LIR sequence.
 */
static Instruction lookup(Instruction switchInstr, IR ir) {
    Instruction bbend = switchInstr.nextInstructionInCodeOrder();
    BasicBlock thisBB = bbend.getBasicBlock();
    BasicBlock nextBB = thisBB.nextBasicBlockInCodeOrder();
    // Blow away the old Normal ControlFlowGraph edges to prepare for new links
    thisBB.deleteNormalOut();
    switchInstr.remove();
    BranchOperand defTarget = LookupSwitch.getClearDefault(switchInstr);
    BasicBlock defaultBB = defTarget.target.getBasicBlock();
    int high = LookupSwitch.getNumberOfTargets(switchInstr) - 1;
    if (high < 0) {
        // no cases in switch; just jump to defaultBB
        thisBB.appendInstruction(Goto.create(GOTO, defTarget));
        thisBB.insertOut(defaultBB);
    } else {
        Operand match = LookupSwitch.getValue(switchInstr);
        if (match.isConstant()) {
            // switch on a constant
            int value = match.asIntConstant().value;
            int numMatches = LookupSwitch.getNumberOfMatches(switchInstr);
            BranchOperand target = LookupSwitch.getDefault(switchInstr);
            for (int i = 0; i < numMatches; i++) {
                if (value == LookupSwitch.getMatch(switchInstr, i).value) {
                    target = LookupSwitch.getTarget(switchInstr, i);
                    break;
                }
            }
            thisBB.appendInstruction(Goto.create(GOTO, target));
            thisBB.insertOut(target.target.getBasicBlock());
        } else {
            RegisterOperand reg = match.asRegister();
            // If you're not already at the end of the code order
            if (nextBB != null) {
                ir.cfg.breakCodeOrder(thisBB, nextBB);
            }
            // generate the binary search tree into thisBB
            BasicBlock lastNewBB = _lookupswitchHelper(switchInstr, reg, defaultBB, ir, thisBB, 0, high, Integer.MIN_VALUE, Integer.MAX_VALUE);
            if (nextBB != null) {
                ir.cfg.linkInCodeOrder(lastNewBB, nextBB);
            }
        }
    }
    // skip all the instrs just inserted by _lookupswitchHelper
    if (nextBB != null) {
        return nextBB.firstInstruction();
    } else {
        return thisBB.lastInstruction();
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand)

Aggregations

Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)355 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)328 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)242 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)217 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)212 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)210 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)207 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)185 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)174 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)165 TypeOperand (org.jikesrvm.compilers.opt.ir.operand.TypeOperand)153 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)144 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)143 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)141 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)128 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)121 UnreachableOperand (org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand)117 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)102 CodeConstantOperand (org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand)98 Register (org.jikesrvm.compilers.opt.ir.Register)82