Exemplo n.º 1
0
 bool run()
 {
     ASSERT(m_graph.m_form == ThreadedCPS || m_graph.m_form == SSA);
     
     // First reset the counts to 0 for all nodes.
     for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
         BasicBlock* block = m_graph.block(blockIndex);
         if (!block)
             continue;
         for (unsigned indexInBlock = block->size(); indexInBlock--;)
             block->at(indexInBlock)->setRefCount(0);
         for (unsigned phiIndex = block->phis.size(); phiIndex--;)
             block->phis[phiIndex]->setRefCount(0);
     }
 
     // Now find the roots:
     // - Nodes that are must-generate.
     // - Nodes that are reachable from type checks.
     // Set their ref counts to 1 and put them on the worklist.
     for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
         BasicBlock* block = m_graph.block(blockIndex);
         if (!block)
             continue;
         for (unsigned indexInBlock = block->size(); indexInBlock--;) {
             Node* node = block->at(indexInBlock);
             DFG_NODE_DO_TO_CHILDREN(m_graph, node, findTypeCheckRoot);
             if (!(node->flags() & NodeMustGenerate))
                 continue;
             if (!node->postfixRef())
                 m_worklist.append(node);
         }
     }
     
     while (!m_worklist.isEmpty()) {
         while (!m_worklist.isEmpty()) {
             Node* node = m_worklist.last();
             m_worklist.removeLast();
             ASSERT(node->shouldGenerate()); // It should not be on the worklist unless it's ref'ed.
             DFG_NODE_DO_TO_CHILDREN(m_graph, node, countEdge);
         }
         
         if (m_graph.m_form == SSA) {
             // Find Phi->Upsilon edges, which are represented as meta-data in the
             // Upsilon.
             for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
                 BasicBlock* block = m_graph.block(blockIndex);
                 if (!block)
                     continue;
                 for (unsigned nodeIndex = block->size(); nodeIndex--;) {
                     Node* node = block->at(nodeIndex);
                     if (node->op() != Upsilon)
                         continue;
                     if (node->shouldGenerate())
                         continue;
                     if (node->phi()->shouldGenerate())
                         countNode(node);
                 }
             }
         }
     }
     
     if (m_graph.m_form == SSA) {
         // Need to process the graph in reverse DFS order, so that we get to the uses
         // of a node before we get to the node itself.
         Vector<BasicBlock*> depthFirst;
         m_graph.getBlocksInDepthFirstOrder(depthFirst);
         for (unsigned i = depthFirst.size(); i--;)
             fixupBlock(depthFirst[i]);
     } else {
         RELEASE_ASSERT(m_graph.m_form == ThreadedCPS);
         
         for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex)
             fixupBlock(m_graph.block(blockIndex));
         
         cleanVariables(m_graph.m_arguments);
     }
     
     m_graph.m_refCountState = ExactRefCount;
     
     return true;
 }
Exemplo n.º 2
0
 bool run()
 {
     for (BlockIndex blockIndex = 0; blockIndex < m_graph.m_blocks.size(); ++blockIndex)
         fixupBlock(m_graph.m_blocks[blockIndex].get());
     return true;
 }
Exemplo n.º 3
0
 void run()
 {
     for (BlockIndex blockIndex = 0; blockIndex < m_graph.m_blocks.size(); ++blockIndex)
         fixupBlock(m_graph.m_blocks[blockIndex].get());
 }