use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.
the class CounterArrayManager method createEventCounterInstruction.
/**
* Create a place holder instruction to represent the counted event.
*
* @param handle The handle of the array for the method
* @param index Index within that array
* @param incrementValue The value to add to the counter
* @return The counter instruction
*/
@Override
public Instruction createEventCounterInstruction(int handle, int index, double incrementValue) {
// Now create the instruction to be returned.
Instruction c = InstrumentedCounter.create(INSTRUMENTED_EVENT_COUNTER, new IntConstantOperand(handle), new IntConstantOperand(index), new DoubleConstantOperand(incrementValue, Offset.zero()));
c.setBytecodeIndex(INSTRUMENTATION_BCI);
return c;
}
use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.
the class CounterArrayManager method InsertALoadOffset.
/**
* Insert array load off before s in the instruction stream.
* @param s the instruction to insert before
* @param ir the containing IR
* @param operator the operator to insert
* @param type the type of the result
* @param reg2 the base to load from
* @param offset the offset to load at
* @return the result operand of the inserted instruction
*/
static RegisterOperand InsertALoadOffset(Instruction s, IR ir, Operator operator, TypeReference type, Operand reg2, int offset) {
RegisterOperand regTarget = ir.regpool.makeTemp(type);
Instruction s2 = ALoad.create(operator, regTarget, reg2, IRTools.IC(offset), null, null);
s.insertBefore(s2);
return regTarget.copyD2U();
}
use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.
the class GenerationContextTest method childContextsQueryOSRBarrierInformationViaOutermostParent.
@Test
public void childContextsQueryOSRBarrierInformationViaOutermostParent() throws Exception {
NormalMethod nm = getNormalMethodForTest("methodForInliningTests");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext outermost = new GenerationContext(nm, null, cm, opts, io);
Class<?>[] classArgs = { Object.class };
NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithObjectParamAndReturnValue", classArgs);
MethodOperand methOp = MethodOperand.STATIC(callee);
RegisterOperand result = createMockRegisterOperand(TypeReference.JavaLangObject);
Instruction callInstr = Call.create(CALL, result, null, methOp, 1);
RegisterOperand objectParam = createMockRegisterOperand(TypeReference.JavaLangObject);
Call.setParam(callInstr, 0, objectParam);
callInstr.setPosition(new InlineSequence(nm));
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
GenerationContext child = outermost.createChildContext(ebag, callee, callInstr);
Instruction osrBarrier = createMockOSRBarrier();
Instruction call = createMockCall();
child.saveOSRBarrierForInst(osrBarrier, call);
assertThat(outermost.getOSRBarrierFromInst(call), is(osrBarrier));
assertThat(child.getOSRBarrierFromInst(call), is(osrBarrier));
GenerationContext child2 = outermost.createChildContext(ebag, callee, callInstr);
assertThat(child2.getOSRBarrierFromInst(call), is(osrBarrier));
}
use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.
the class GenerationContextTest method savingNoLongerWorksAfterOSRBarrierInformationWasDiscarded.
@Test(expected = NullPointerException.class)
public void savingNoLongerWorksAfterOSRBarrierInformationWasDiscarded() throws Exception {
GenerationContext gc = createMostlyEmptyContext("methodForInliningTests");
gc.discardOSRBarrierInformation();
Instruction osrBarrier = createMockOSRBarrier();
Instruction call = createMockCall();
gc.saveOSRBarrierForInst(osrBarrier, call);
}
use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.
the class GenerationContextTest method assertThatRethrowBlockIsCorrect.
private void assertThatRethrowBlockIsCorrect(InlineSequence inlineSequence, Operand lockObject, ExceptionHandlerBasicBlock rethrow) {
Enumeration<TypeOperand> exceptionTypes = rethrow.getExceptionTypes();
TypeOperand firstHandledException = exceptionTypes.nextElement();
assertThat(exceptionTypes.hasMoreElements(), is(false));
assertTrue(firstHandledException.similar(new TypeOperand(RVMType.JavaLangThrowableType)));
Enumeration<Instruction> rethrowInstructions = rethrow.forwardRealInstrEnumerator();
Instruction firstInstructionInRethrow = rethrowInstructions.nextElement();
assertThat(firstInstructionInRethrow.operator(), is(GET_CAUGHT_EXCEPTION));
assertThat(firstInstructionInRethrow.getBytecodeIndex(), is(SYNTH_CATCH_BCI));
assertTrue(firstInstructionInRethrow.position().equals(inlineSequence));
RegisterOperand catchExceptionObject = Nullary.getResult(firstInstructionInRethrow);
assertThat(catchExceptionObject.getType(), is(TypeReference.JavaLangThrowable));
Instruction secondInstructionInRethrow = rethrowInstructions.nextElement();
assertThatNoMoreInstructionsExist(rethrowInstructions);
assertThat(secondInstructionInRethrow.operator(), is(CALL));
MethodOperand methodOp = Call.getMethod(secondInstructionInRethrow);
assertTrue(methodOp.getTarget().equals(Entrypoints.unlockAndThrowMethod));
assertTrue(methodOp.isNonReturningCall());
Operand callAddress = Call.getAddress(secondInstructionInRethrow);
Address actualAddress = callAddress.asAddressConstant().value;
Address expectedAddress = Entrypoints.unlockAndThrowMethod.getOffset().toWord().toAddress();
assertTrue(actualAddress.EQ(expectedAddress));
Operand lockObjectFromRethrow = Call.getParam(secondInstructionInRethrow, 0);
assertTrue(lockObjectFromRethrow.similar(lockObject));
RegisterOperand catchOperand = Call.getParam(secondInstructionInRethrow, 1).asRegister();
assertTrue(catchOperand.sameRegisterPropertiesAs(catchExceptionObject));
assertTrue(rethrow.mayThrowUncaughtException());
assertTrue(rethrow.canThrowExceptions());
}
Aggregations