use of org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag in project JikesRVM by JikesRVM.
the class GenerationContextTest method basicChildContextsWorkCorrectly.
@Test
public void basicChildContextsWorkCorrectly() 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);
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();
int nodeNumber = 12345;
gc.getCfg().setNumberOfNodes(nodeNumber);
GenerationContext child = gc.createChildContext(ebag, callee, callInstr);
RegisterOperand expectedLocalForObjectParam = child.makeLocal(0, objectParam);
assertThatStateIsCopiedFromParentToChild(gc, callee, child, ebag);
InlineSequence expectedInlineSequence = new InlineSequence(callee, callInstr.position(), callInstr);
assertEquals(expectedInlineSequence, child.getInlineSequence());
RegisterOperand firstArg = child.getArguments()[0].asRegister();
assertTrue(firstArg.sameRegisterPropertiesAs(expectedLocalForObjectParam));
assertSame(result.getRegister(), child.getResultReg());
assertTrue(child.getResultReg().spansBasicBlock());
assertThatPrologueAndEpilogueAreWiredCorrectlyForChildContext(ebag, nodeNumber, child);
Enumeration<Instruction> prologueRealInstr = child.getPrologue().forwardRealInstrEnumerator();
Instruction move = prologueRealInstr.nextElement();
RegisterOperand objectParamInChild = objectParam.copy().asRegister();
assertMoveOperationIsCorrect(callInstr, REF_MOVE, expectedLocalForObjectParam, objectParamInChild, move);
assertThatNoMoreInstructionsExist(prologueRealInstr);
Enumeration<Instruction> epilogueRealInstr = child.getEpilogue().forwardRealInstrEnumerator();
assertThatNoMoreInstructionsExist(epilogueRealInstr);
assertThatNoRethrowBlockExists(child);
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag in project JikesRVM by JikesRVM.
the class GenerationContextTest method childContextsSaveOSRBarrierInformationInOutermostParent.
@Test
public void childContextsSaveOSRBarrierInformationInOutermostParent() 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));
GenerationContext child2 = child.createChildContext(ebag, callee, callInstr);
Instruction osrBarrier2 = createMockOSRBarrier();
Instruction call2 = createMockCall();
child2.saveOSRBarrierForInst(osrBarrier2, call2);
assertThat(outermost.getOSRBarrierFromInst(call2), is(osrBarrier2));
}
use of org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag in project JikesRVM by JikesRVM.
the class GenerationContextTest method transferStateUpdatesFieldsInParentFromChild.
@Test
public void transferStateUpdatesFieldsInParentFromChild() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithoutAnnotations");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext parent = new GenerationContext(nm, null, cm, opts, io);
int targetNumberOfNodes = 23456789;
assertThatContextIsInExpectedState(parent, targetNumberOfNodes);
NormalMethod interruptibleCallee = getNormalMethodForTest("emptyStaticMethodWithoutAnnotations");
Instruction callInstr = buildCallInstructionForStaticMethodWithoutReturn(interruptibleCallee, nm);
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
GenerationContext child = parent.createChildContext(ebag, interruptibleCallee, callInstr);
setTransferableProperties(targetNumberOfNodes, child);
child.transferStateToParent();
assertThatStateWasTransferedToOtherContext(parent, targetNumberOfNodes);
}
use of org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag in project JikesRVM by JikesRVM.
the class GenerationContextTest method rethrowBlockIsCorrectForSynchronizedMethodInlinedIntoSynchronizedMethod.
@Test
public void rethrowBlockIsCorrectForSynchronizedMethodInlinedIntoSynchronizedMethod() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptySynchronizedStaticMethod");
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("emptySynchronizedStaticMethod");
Instruction callInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
ExceptionHandlerBasicBlockBag ebag = gc.getEnclosingHandlers();
GenerationContext childContext = gc.createChildContext(ebag, callee, callInstr);
assertThatExceptionHandlersWereGenerated(childContext);
Operand expectedLockObject = buildLockObjectForStaticMethod(callee);
assertThatUnlockAndRethrowBlockIsCorrectForInlinedMethod(gc, childContext, childContext.getInlineSequence(), childContext.getPrologue(), expectedLockObject, childContext.getEpilogue());
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag in project JikesRVM by JikesRVM.
the class GenerationContextTest method assertThatUnlockAndRethrowBlockIsCorrect.
private void assertThatUnlockAndRethrowBlockIsCorrect(GenerationContext gc, InlineSequence inlineSequence, BasicBlock prologue, Operand lockObject, BasicBlock epilogue) {
ExceptionHandlerBasicBlockBag ehbb = gc.getEnclosingHandlers();
Enumeration<BasicBlock> enumerator = ehbb.enumerator();
ExceptionHandlerBasicBlock rethrow = (ExceptionHandlerBasicBlock) enumerator.nextElement();
assertThat(enumerator.hasMoreElements(), is(false));
assertThatRethrowBlockIsCorrect(inlineSequence, lockObject, rethrow);
checkCodeOrderForRethrowBlock(gc, prologue, epilogue, rethrow);
assertTrue(rethrow.mayThrowUncaughtException());
assertTrue(rethrow.canThrowExceptions());
OutEdgeEnumeration outEdges = rethrow.outEdges();
boolean leadsToExit = false;
while (outEdges.hasMoreElements()) {
GraphEdge nextElement = outEdges.nextElement();
BasicBlock target = (BasicBlock) nextElement.to();
if (target == gc.getCfg().exit()) {
leadsToExit = true;
}
}
assertTrue(leadsToExit);
assertSame(rethrow, gc.getUnlockAndRethrow());
ExceptionHandlerBasicBlockBag ehbbb = gc.getEnclosingHandlers();
assertNull(ehbbb.getCaller());
assertThatEnclosingHandlersContainRethrow(rethrow, ehbbb);
}
Aggregations