Index: vm/jitrino/src/optimizer/FlowGraph.cpp =================================================================== --- vm/jitrino/src/optimizer/FlowGraph.cpp (revision 603211) +++ vm/jitrino/src/optimizer/FlowGraph.cpp (working copy) @@ -908,7 +908,7 @@ Edges backedges(tmpMM); Edges edgesToRemove(tmpMM); for (Nodes::const_iterator it = nodes.begin(), end = nodes.end(); it!=end; ++it) { - Node* node = *it; + Node* node = *it; Node* head = lt->getLoopHeader(node, false); if (head == NULL) { continue; @@ -929,12 +929,20 @@ i->unlink(); Edge* exceptionEdge = node->getExceptionEdge(); Node* dispatch = exceptionEdge->getTargetNode(); - while (lt->getLoopHeader(dispatch, false) == head) { //select dispatch that is out of the loop. Otherwise loop structure will be invalid - dispatch = dispatch->getExceptionEdgeTarget(); - assert(dispatch); + edgesToRemove.push_back(exceptionEdge); + + //propagate dispatch mapping to parent loops too + for (Node* parentHead = head; parentHead; parentHead = lt->getLoopHeader(parentHead, true)) { + if (loopHeadToDispatchMap.find(parentHead) == loopHeadToDispatchMap.end()) { + while (lt->getLoopHeader(dispatch, false) == parentHead) { //select dispatch that is out of the loop. Otherwise loop structure will be invalid + dispatch = dispatch->getExceptionEdgeTarget(); + assert(dispatch); + } + loopHeadToDispatchMap[parentHead] = dispatch; + } else { + break; + } } - loopHeadToDispatchMap[head] = dispatch; - edgesToRemove.push_back(exceptionEdge); } }