Index: vm/jitrino/src/optimizer/deadcodeeliminator.cpp =================================================================== --- vm/jitrino/src/optimizer/deadcodeeliminator.cpp (revision 577141) +++ vm/jitrino/src/optimizer/deadcodeeliminator.cpp (working copy) @@ -1132,51 +1132,67 @@ const Nodes& loopNodes = loopNode->getNodesInLoop(); for (Nodes::const_iterator it = loopNodes.begin(), end = loopNodes.end(); it!=end; ++it) { Node* node = *it; + if (!node->isBlockNode()) continue; if (Log::isEnabled()) { Log::out() << "Analyzing Node ID: " << node->getId() << std::endl; } - if (!node->isBlockNode()) continue; - Edge* exceptionEdge = node->getExceptionEdge(); - while (exceptionEdge != NULL) { - Node* targetNode = exceptionEdge->getTargetNode(); - if (Log::isEnabled()) { - Log::out() << " inspecting dispatch edge to node: " << targetNode->getId() << std::endl; - } - if (!loopNode->inLoop(targetNode)) break; - exceptionEdge = targetNode->getExceptionEdge(); - } - if (exceptionEdge != NULL) { - if (Log::isEnabled()) { - Log::out() << " Loop exit exception edge detected: "; - } - if (((Inst*)node->getLastInst())->getOpcode() == Op_PseudoThrow) { - if (essentialNodes.getBit(node->getId())) { - // There is an essential PseudoThrow instruction in this loop + for(Edges::const_iterator ei = node->getOutEdges().begin(); ei != node->getOutEdges().end(); ++ei) { + Edge *cedge = *ei; + if (cedge->getKind() == Edge::Kind_Dispatch) { + while (cedge != NULL) { + Node* targetNode = cedge->getTargetNode(); if (Log::isEnabled()) { - Log::out() << " essential PseudoThrow inst" << std::endl; + Log::out() << " inspecting dispatch edge to node: " << targetNode->getId() << std::endl; } - return; - } else { - // A candidate to essential nodes + if (!loopNode->inLoop(targetNode)) break; + cedge = targetNode->getExceptionEdge(); + } + if (cedge != NULL) { if (Log::isEnabled()) { - Log::out() << " essential candidate" << std::endl; + Log::out() << " Loop exit exception edge detected: "; } - mbEssentialNode = node; + if (((Inst*)node->getLastInst())->getOpcode() == Op_PseudoThrow) { + if (essentialNodes.getBit(node->getId())) { + // There is an essential PseudoThrow instruction in this loop + if (Log::isEnabled()) { + Log::out() << " essential PseudoThrow inst" << std::endl; + } + return; + } else { + // A candidate to essential nodes + if (Log::isEnabled()) { + Log::out() << " essential candidate" << std::endl; + } + mbEssentialNode = node; + } + } else { + // No essential PseudoThrow insts in this loop + if (Log::isEnabled()) { + Log::out() << " PseudoThrow killer inst" << std::endl; + } + return; + } } } else { - // No essential PseudoThrow insts in this loop + Node* targetNode = cedge->getTargetNode(); if (Log::isEnabled()) { - Log::out() << " PseudoThrow killer inst" << std::endl; + Log::out() << " inspecting edge to node: " << targetNode->getId() << std::endl; } - return; + if (!loopNode->inLoop(targetNode)) { + if (Log::isEnabled()) { + Log::out() << " Loop exit" << std::endl; + } + return; + } } } } - assert(mbEssentialNode != NULL); - essentialNodes.setBit(mbEssentialNode->getId()); - if (Log::isEnabled()) { - Log::out() << "Found essential PseudoThrow in node ID: " - << mbEssentialNode->getId() << std::endl; + if (mbEssentialNode != NULL) { + essentialNodes.setBit(mbEssentialNode->getId()); + if (Log::isEnabled()) { + Log::out() << "Found essential PseudoThrow in node ID: " + << mbEssentialNode->getId() << std::endl; + } } return; } Index: vm/jitrino/src/shared/ControlFlowGraph.h =================================================================== --- vm/jitrino/src/shared/ControlFlowGraph.h (revision 577141) +++ vm/jitrino/src/shared/ControlFlowGraph.h (working copy) @@ -542,9 +542,9 @@ * @param[in] isForward - tells what kind of edges, incoming or outgoing, * to return * - * @return If the isForwarisForward parameter is TRUE, - * returns the collection of incoming edges; - * otherwise, the collection of outgoing ones. + * @return If the isForwaris parameter is TRUE, + * returns the collection of outgoing edges; + * otherwise, the collection of incoming ones. * * @note The ordering of edges in the collection is not specified. */