Ignore:
Timestamp:
Sep 11, 2013, 10:46:49 PM (12 years ago)
Author:
[email protected]
Message:

FixupPhase should always call fixEdge() exactly once for every edge
https://bugs.webkit.org/show_bug.cgi?id=121211

Reviewed by Geoffrey Garen.

Previously we only call fixEdge() on edges that we want to make typed. UntypedUse
edges don't get fixEdge() called. This makes it difficult to add functionality in
fixEdge() that runs for UntypedUses. It's difficult to remember to call fixEdge()
for every edge that we don't want to turn into a typed edge; in an alternative
universe where we did this, it would mean that every case in FixupPhase would
have to make a fixEdge() call for *every* edge even ones that it doesn't want to
modify.

This patch takes a different path. fixEdge() must never be called explicitly with
UntypedUse. fixEdge() should be used to set the UseKind of edges. Consequently,
all that FixupPhase has to do is call fixEdge<UntypedUse>(edge) for every edge
that was still UntypedUse after we are done processing a node.

This is cheap and easy to implement and ought to be easy to maintain. We won't
have a need to call fixEdge<UntypedUse>(edge) explicitly, so depending on that is
only natural.

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):
(JSC::DFG::FixupPhase::observeUntypedEdge):
(JSC::DFG::FixupPhase::observeUseKindOnNode):

File:
1 edited

Legend:

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

    r155590 r155593  
    908908#endif
    909909        }
     910       
     911        DFG_NODE_DO_TO_CHILDREN(m_graph, node, observeUntypedEdge);
    910912
    911913#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
     
    916918        dataLogF("\n");
    917919#endif
     920    }
     921   
     922    void observeUntypedEdge(Node*, Edge& edge)
     923    {
     924        if (edge.useKind() != UntypedUse)
     925            return;
     926        fixEdge<UntypedUse>(edge);
    918927    }
    919928   
     
    12811290    void observeUseKindOnNode(Node* node)
    12821291    {
     1292        if (useKind == UntypedUse)
     1293            return;
    12831294        observeUseKindOnNode(node, useKind);
    12841295    }
     
    13271338    }
    13281339   
    1329     // Set the use kind of the edge. In the future (https://bugs.webkit.org/show_bug.cgi?id=110433),
    1330     // this can be used to notify the GetLocal that the variable is profitable to unbox.
     1340    // Set the use kind of the edge and perform any actions that need to be done for
     1341    // that use kind, like inserting intermediate conversion nodes. Never call this
     1342    // with useKind = UntypedUse explicitly; edges have UntypedUse implicitly and any
     1343    // edge that survives fixup and still has UntypedUse will have this method called
     1344    // from observeUntypedEdge(). Also, make sure that if you do change the type of an
     1345    // edge, you either call fixEdge() or perform the equivalent functionality
     1346    // yourself. Obviously, you should have a really good reason if you do the latter.
    13311347    template<UseKind useKind>
    13321348    void fixEdge(Edge& edge, SpeculationDirection direction = BackwardSpeculation)
Note: See TracChangeset for help on using the changeset viewer.