Ignore:
Timestamp:
Nov 3, 2016, 9:38:58 PM (9 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r208364.
https://bugs.webkit.org/show_bug.cgi?id=164402

broke the build (Requested by smfr on #webkit).

Reverted changeset:

"DFG plays fast and loose with the shadow values of a Phi"
https://bugs.webkit.org/show_bug.cgi?id=164309
http://trac.webkit.org/changeset/208364

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGLivenessAnalysisPhase.cpp

    r208364 r208367  
    3131#include "DFGBasicBlockInlines.h"
    3232#include "DFGBlockMapInlines.h"
    33 #include "DFGFlowIndexing.h"
    3433#include "DFGGraph.h"
    3534#include "DFGInsertionSet.h"
     
    4645        : Phase(graph, "liveness analysis")
    4746        , m_dirtyBlocks(m_graph.numBlocks())
    48         , m_indexing(*m_graph.m_indexingCache)
    4947        , m_liveAtHead(m_graph)
    5048        , m_liveAtTail(m_graph)
    51     {
    52         m_graph.m_indexingCache->recompute();
    53         m_workset = std::make_unique<IndexSparseSet<UnsafeVectorOverflow>>(m_graph.m_indexingCache->numIndices());
     49        , m_workset(graph.maxNodeCount() - 1)
     50    {
    5451    }
    5552
     
    8481
    8582            {
    86                 const Vector<unsigned, 0, UnsafeVectorOverflow, 1>& liveAtHeadIndices = m_liveAtHead[blockIndex];
    87                 Vector<NodeFlowProjection>& liveAtHead = block->ssa->liveAtHead;
     83                const auto& liveAtHeadIndices = m_liveAtHead[blockIndex];
     84                Vector<Node*>& liveAtHead = block->ssa->liveAtHead;
    8885                liveAtHead.resize(0);
    8986                liveAtHead.reserveCapacity(liveAtHeadIndices.size());
    9087                for (unsigned index : liveAtHeadIndices)
    91                     liveAtHead.uncheckedAppend(m_indexing.nodeProjection(index));
     88                    liveAtHead.uncheckedAppend(m_graph.nodeAt(index));
    9289            }
    9390            {
    94                 const HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>& liveAtTailIndices = m_liveAtTail[blockIndex];
    95                 Vector<NodeFlowProjection>& liveAtTail = block->ssa->liveAtTail;
     91                const auto& liveAtTailIndices = m_liveAtTail[blockIndex];
     92                Vector<Node*>& liveAtTail = block->ssa->liveAtTail;
    9693                liveAtTail.resize(0);
    9794                liveAtTail.reserveCapacity(liveAtTailIndices.size());
    9895                for (unsigned index : m_liveAtTail[blockIndex])
    99                     liveAtTail.uncheckedAppend(m_indexing.nodeProjection(index));
     96                    liveAtTail.uncheckedAppend(m_graph.nodeAt(index));
    10097            }
    10198        }
     
    110107        ASSERT_WITH_MESSAGE(block, "Only dirty blocks needs updates. A null block should never be dirty.");
    111108
    112         m_workset->clear();
     109        m_workset.clear();
    113110        for (unsigned index : m_liveAtTail[blockIndex])
    114             m_workset->add(index);
     111            m_workset.add(index);
    115112
    116113        for (unsigned nodeIndex = block->size(); nodeIndex--;) {
    117114            Node* node = block->at(nodeIndex);
    118115
    119             auto handleEdge = [&] (Edge& edge) {
    120                 bool newEntry = m_workset->add(m_indexing.index(edge.node()));
    121                 edge.setKillStatus(newEntry ? DoesKill : DoesNotKill);
    122             };
     116            // Given an Upsilon:
     117            //
     118            //    n: Upsilon(@x, ^p)
     119            //
     120            // We say that it def's @p and @n and uses @x.
     121            //
     122            // Given a Phi:
     123            //
     124            //    p: Phi()
     125            //
     126            // We say nothing. It's neither a use nor a def.
     127            //
     128            // Given a node:
     129            //
     130            //    n: Thingy(@a, @b, @c)
     131            //
     132            // We say that it def's @n and uses @a, @b, @c.
    123133           
    124134            switch (node->op()) {
    125135            case Upsilon: {
    126                 ASSERT_WITH_MESSAGE(!m_workset->contains(node->index()), "Upsilon should not be used as defs by other nodes.");
     136                ASSERT_WITH_MESSAGE(!m_workset.contains(node->index()), "Upsilon should not be used as defs by other nodes.");
    127137
    128138                Node* phi = node->phi();
    129                 m_workset->remove(m_indexing.shadowIndex(phi));
    130                 handleEdge(node->child1());
     139                m_workset.remove(phi->index());
     140                m_workset.add(node->child1()->index());
    131141                break;
    132142            }
    133143            case Phi: {
    134                 m_workset->remove(m_indexing.index(node));
    135                 m_workset->add(m_indexing.shadowIndex(node));
    136144                break;
    137145            }
    138146            default:
    139                 m_workset->remove(m_indexing.index(node));
    140                 m_graph.doToChildren(node, handleEdge);
     147                m_workset.remove(node->index());
     148                DFG_NODE_DO_TO_CHILDREN(m_graph, node, addChildUse);
    141149                break;
    142150            }
     
    144152
    145153        // Update live at head.
    146         Vector<unsigned, 0, UnsafeVectorOverflow, 1>& liveAtHead = m_liveAtHead[blockIndex];
    147         if (m_workset->size() == liveAtHead.size())
     154        auto& liveAtHead = m_liveAtHead[blockIndex];
     155        if (m_workset.size() == liveAtHead.size())
    148156            return false;
    149157
    150158        for (unsigned liveIndexAtHead : liveAtHead)
    151             m_workset->remove(liveIndexAtHead);
    152         ASSERT(!m_workset->isEmpty());
    153 
    154         liveAtHead.reserveCapacity(liveAtHead.size() + m_workset->size());
    155         for (unsigned newValue : *m_workset)
     159            m_workset.remove(liveIndexAtHead);
     160        ASSERT(!m_workset.isEmpty());
     161
     162        liveAtHead.reserveCapacity(liveAtHead.size() + m_workset.size());
     163        for (unsigned newValue : m_workset)
    156164            liveAtHead.uncheckedAppend(newValue);
    157165
    158166        bool changedPredecessor = false;
    159167        for (BasicBlock* predecessor : block->predecessors) {
    160             HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>&
    161                 liveAtTail = m_liveAtTail[predecessor];
    162             for (unsigned newValue : *m_workset) {
     168            auto& liveAtTail = m_liveAtTail[predecessor];
     169            for (unsigned newValue : m_workset) {
    163170                if (liveAtTail.add(newValue)) {
    164171                    if (!m_dirtyBlocks.quickSet(predecessor->index))
     
    170177    }
    171178
     179    ALWAYS_INLINE void addChildUse(Node*, Edge& edge)
     180    {
     181        bool newEntry = m_workset.add(edge->index());
     182        edge.setKillStatus(newEntry ? DoesKill : DoesNotKill);
     183    }
     184
    172185    // Blocks with new live values at tail.
    173186    BitVector m_dirtyBlocks;
    174    
    175     FlowIndexing& m_indexing;
    176187
    177188    // Live values per block edge.
     
    180191
    181192    // Single sparse set allocated once and used by every basic block.
    182     std::unique_ptr<IndexSparseSet<UnsafeVectorOverflow>> m_workset;
     193    IndexSparseSet<UnsafeVectorOverflow> m_workset;
    183194};
    184195
Note: See TracChangeset for help on using the changeset viewer.