Search in sources :

Example 1 with OutEdgeEnumeration

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);
}
Also used : OutEdgeEnumeration(org.jikesrvm.compilers.opt.util.SpaceEffGraphNode.OutEdgeEnumeration) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) HashSet(java.util.HashSet)

Example 2 with OutEdgeEnumeration

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);
}
Also used : OutEdgeEnumeration(org.jikesrvm.compilers.opt.util.SpaceEffGraphNode.OutEdgeEnumeration) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) GraphEdge(org.jikesrvm.compilers.opt.util.GraphEdge) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)

Aggregations

BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)2 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)2 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)2 OutEdgeEnumeration (org.jikesrvm.compilers.opt.util.SpaceEffGraphNode.OutEdgeEnumeration)2 HashSet (java.util.HashSet)1 GraphEdge (org.jikesrvm.compilers.opt.util.GraphEdge)1