use of org.jikesrvm.compilers.opt.util.SpaceEffGraphNode.OutEdgeEnumeration in project JikesRVM by JikesRVM.
the class GenerationContextTest method assertThatUnlockAndRethrowBlockIsCorrectForInlinedMethod.
private void assertThatUnlockAndRethrowBlockIsCorrectForInlinedMethod(GenerationContext parentContext, GenerationContext childContext, InlineSequence inlineSequence, BasicBlock prologue, Operand lockObject, BasicBlock epilogue) {
ExceptionHandlerBasicBlockBag ehbb = childContext.getEnclosingHandlers();
Enumeration<BasicBlock> enumerator = ehbb.enumerator();
assertThat(childContext.getUnlockAndRethrow().exceptionHandlers(), is(parentContext.getEnclosingHandlers()));
ExceptionHandlerBasicBlock rethrow = (ExceptionHandlerBasicBlock) enumerator.nextElement();
assertSame(rethrow, childContext.getUnlockAndRethrow());
assertThatRethrowBlockIsCorrect(inlineSequence, lockObject, rethrow);
checkCodeOrderForRethrowBlock(childContext, prologue, epilogue, rethrow);
ExceptionHandlerBasicBlockBag parentHandlers = parentContext.getEnclosingHandlers();
Enumeration<BasicBlock> parentHandlerBBEnum = parentHandlers.enumerator();
HashSet<BasicBlock> parentHandlerBBs = new HashSet<BasicBlock>();
while (parentHandlerBBEnum.hasMoreElements()) {
parentHandlerBBs.add(parentHandlerBBEnum.nextElement());
}
BasicBlock childRethrow = childContext.getUnlockAndRethrow();
OutEdgeEnumeration outEdges = childRethrow.outEdges();
boolean linkedToAllBlocksFromParentHandler = true;
while (outEdges.hasMoreElements()) {
BasicBlock target = (BasicBlock) outEdges.nextElement().to();
if (!parentHandlerBBs.contains(target) && target != childContext.getExit()) {
linkedToAllBlocksFromParentHandler = false;
break;
}
}
assertTrue(linkedToAllBlocksFromParentHandler);
ExceptionHandlerBasicBlockBag ehbbb = childContext.getEnclosingHandlers();
assertSame(parentContext.getEnclosingHandlers(), ehbbb.getCaller());
assertThatEnclosingHandlersContainRethrow(rethrow, ehbbb);
}
use of org.jikesrvm.compilers.opt.util.SpaceEffGraphNode.OutEdgeEnumeration 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