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