Changeset 170907 in webkit


Ignore:
Timestamp:
Jul 8, 2014, 8:00:27 PM (11 years ago)
Author:
fpizlo@apple.com
Message:

[ftlopt] Phantom simplification should be in its own phase
https://bugs.webkit.org/show_bug.cgi?id=134742

Reviewed by Geoffrey Garen.

This moves Phantom simplification out of CSE, which greatly simplifies CSE and gives it
more focus. Also this finally adds a phase that removes empty Phantoms. We sort of had
this in CPSRethreading, but that phase runs too infrequently and doesn't run at all for
SSA.

  • CMakeLists.txt:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • dfg/DFGAdjacencyList.h:
  • dfg/DFGCSEPhase.cpp:

(JSC::DFG::CSEPhase::run):
(JSC::DFG::CSEPhase::setReplacement):
(JSC::DFG::CSEPhase::eliminate):
(JSC::DFG::CSEPhase::performNodeCSE):
(JSC::DFG::CSEPhase::eliminateIrrelevantPhantomChildren): Deleted.

  • dfg/DFGPhantomRemovalPhase.cpp: Added.

(JSC::DFG::PhantomRemovalPhase::PhantomRemovalPhase):
(JSC::DFG::PhantomRemovalPhase::run):
(JSC::DFG::performCleanUp):

  • dfg/DFGPhantomRemovalPhase.h: Added.
  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::compileInThreadImpl):

Location:
branches/ftlopt/Source/JavaScriptCore
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/ftlopt/Source/JavaScriptCore/CMakeLists.txt

    r170672 r170907  
    182182    dfg/DFGOSRExitPreparation.cpp
    183183    dfg/DFGOperations.cpp
     184    dfg/DFGPhantomRemovalPhase.cpp
    184185    dfg/DFGPhase.cpp
    185186    dfg/DFGPlan.cpp
  • branches/ftlopt/Source/JavaScriptCore/ChangeLog

    r170890 r170907  
     12014-07-08  Filip Pizlo  <fpizlo@apple.com>
     2
     3        [ftlopt] Phantom simplification should be in its own phase
     4        https://bugs.webkit.org/show_bug.cgi?id=134742
     5
     6        Reviewed by Geoffrey Garen.
     7       
     8        This moves Phantom simplification out of CSE, which greatly simplifies CSE and gives it
     9        more focus. Also this finally adds a phase that removes empty Phantoms. We sort of had
     10        this in CPSRethreading, but that phase runs too infrequently and doesn't run at all for
     11        SSA.
     12
     13        * CMakeLists.txt:
     14        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     15        * JavaScriptCore.xcodeproj/project.pbxproj:
     16        * dfg/DFGAdjacencyList.h:
     17        * dfg/DFGCSEPhase.cpp:
     18        (JSC::DFG::CSEPhase::run):
     19        (JSC::DFG::CSEPhase::setReplacement):
     20        (JSC::DFG::CSEPhase::eliminate):
     21        (JSC::DFG::CSEPhase::performNodeCSE):
     22        (JSC::DFG::CSEPhase::eliminateIrrelevantPhantomChildren): Deleted.
     23        * dfg/DFGPhantomRemovalPhase.cpp: Added.
     24        (JSC::DFG::PhantomRemovalPhase::PhantomRemovalPhase):
     25        (JSC::DFG::PhantomRemovalPhase::run):
     26        (JSC::DFG::performCleanUp):
     27        * dfg/DFGPhantomRemovalPhase.h: Added.
     28        * dfg/DFGPlan.cpp:
     29        (JSC::DFG::Plan::compileInThreadImpl):
     30
    1312014-07-08  Filip Pizlo  <fpizlo@apple.com>
    232
  • branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r170672 r170907  
    433433    <ClCompile Include="..\dfg\DFGOSRExitJumpPlaceholder.cpp" />
    434434    <ClCompile Include="..\dfg\DFGOSRExitPreparation.cpp" />
     435    <ClCompile Include="..\dfg\DFGPhantomRemovalPhase.cpp" />
    435436    <ClCompile Include="..\dfg\DFGPhase.cpp" />
    436437    <ClCompile Include="..\dfg\DFGPlan.cpp" />
     
    10101011    <ClInclude Include="..\dfg\DFGOSRExitJumpPlaceholder.h" />
    10111012    <ClInclude Include="..\dfg\DFGOSRExitPreparation.h" />
     1013    <ClInclude Include="..\dfg\DFGPhantomRemovalPhase.h" />
    10121014    <ClInclude Include="..\dfg\DFGPhase.h" />
    10131015    <ClInclude Include="..\dfg\DFGPlan.h" />
  • branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r170672 r170907  
    457457                0FBE0F7616C1DB0F0082C5E8 /* DFGUnificationPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE0F6F16C1DB010082C5E8 /* DFGUnificationPhase.cpp */; };
    458458                0FBE0F7716C1DB120082C5E8 /* DFGUnificationPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FBE0F7016C1DB010082C5E8 /* DFGUnificationPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
     459                0FBFDD04196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBFDD02196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp */; };
     460                0FBFDD05196C92BF007A5BFA /* DFGPhantomRemovalPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FBFDD03196C92BF007A5BFA /* DFGPhantomRemovalPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    459461                0FC0976A1468A6F700CF2442 /* DFGOSRExit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC097681468A6EF00CF2442 /* DFGOSRExit.h */; settings = {ATTRIBUTES = (Private, ); }; };
    460462                0FC0977114693AF500CF2442 /* DFGOSRExitCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC0976F14693AEF00CF2442 /* DFGOSRExitCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    26422644                0FBE0F6F16C1DB010082C5E8 /* DFGUnificationPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGUnificationPhase.cpp; path = dfg/DFGUnificationPhase.cpp; sourceTree = "<group>"; };
    26432645                0FBE0F7016C1DB010082C5E8 /* DFGUnificationPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGUnificationPhase.h; path = dfg/DFGUnificationPhase.h; sourceTree = "<group>"; };
     2646                0FBFDD02196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGPhantomRemovalPhase.cpp; path = dfg/DFGPhantomRemovalPhase.cpp; sourceTree = "<group>"; };
     2647                0FBFDD03196C92BF007A5BFA /* DFGPhantomRemovalPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGPhantomRemovalPhase.h; path = dfg/DFGPhantomRemovalPhase.h; sourceTree = "<group>"; };
    26442648                0FC097681468A6EF00CF2442 /* DFGOSRExit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSRExit.h; path = dfg/DFGOSRExit.h; sourceTree = "<group>"; };
    26452649                0FC0976F14693AEF00CF2442 /* DFGOSRExitCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSRExitCompiler.h; path = dfg/DFGOSRExitCompiler.h; sourceTree = "<group>"; };
     
    51775181                                0F235BE917178E7300690C7F /* DFGOSRExitPreparation.cpp */,
    51785182                                0F235BEA17178E7300690C7F /* DFGOSRExitPreparation.h */,
     5183                                0FBFDD02196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp */,
     5184                                0FBFDD03196C92BF007A5BFA /* DFGPhantomRemovalPhase.h */,
    51795185                                0FFFC94F14EF909500C72532 /* DFGPhase.cpp */,
    51805186                                0FFFC95014EF909500C72532 /* DFGPhase.h */,
     
    63156321                                A532438C18568335002ED692 /* InspectorJSTypeBuilders.h in Headers */,
    63166322                                A50E4B6218809DD50068A46D /* InspectorRuntimeAgent.h in Headers */,
     6323                                0FBFDD05196C92BF007A5BFA /* DFGPhantomRemovalPhase.h in Headers */,
    63176324                                A55D93AC18514F7900400DED /* InspectorTypeBuilder.h in Headers */,
    63186325                                A593CF831840377100BFCE27 /* InspectorValues.h in Headers */,
     
    80688075                                9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
    80698076                                0F8F2B9E17306C8D007DBDA5 /* SourceCode.cpp in Sources */,
     8077                                0FBFDD04196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp in Sources */,
    80708078                                0F493AFA16D0CAD30084508B /* SourceProvider.cpp in Sources */,
    80718079                                E49DC16B12EF293E00184A1F /* SourceProviderCache.cpp in Sources */,
  • branches/ftlopt/Source/JavaScriptCore/dfg/DFGAdjacencyList.h

    r170064 r170907  
    133133        setChild(Size - 1, Edge());
    134134    }
    135 
     135   
    136136    unsigned firstChild() const
    137137    {
  • branches/ftlopt/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp

    r170890 r170907  
    5555        m_graph.clearReplacements();
    5656       
    57         for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
    58             BasicBlock* block = m_graph.block(blockIndex);
    59             if (!block)
    60                 continue;
    61            
    62             // All Phis need to already be marked as relevant to OSR.
    63             if (!ASSERT_DISABLED) {
    64                 for (unsigned i = 0; i < block->phis.size(); ++i)
    65                     ASSERT(block->phis[i]->flags() & NodeRelevantToOSR);
    66             }
    67            
    68             for (unsigned i = block->size(); i--;) {
    69                 Node* node = block->at(i);
    70                
    71                 switch (node->op()) {
    72                 case SetLocal:
    73                 case GetLocal: // FIXME: The GetLocal case is only necessary until we do https://bugs.webkit.org/show_bug.cgi?id=106707.
    74                     node->mergeFlags(NodeRelevantToOSR);
    75                     break;
    76                 default:
    77                     node->clearFlags(NodeRelevantToOSR);
    78                     break;
    79                 }
    80             }
    81         }
    82        
    83         for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
    84             BasicBlock* block = m_graph.block(blockIndex);
    85             if (!block)
    86                 continue;
    87            
    88             for (unsigned i = block->size(); i--;) {
    89                 Node* node = block->at(i);
    90                 if (!node->containsMovHint())
    91                     continue;
    92                
    93                 ASSERT(node->op() != ZombieHint);
    94                 node->child1()->mergeFlags(NodeRelevantToOSR);
    95             }
    96         }
    97        
    9857        if (m_graph.m_form == SSA) {
    9958            Vector<BasicBlock*> depthFirst;
     
    832791    }
    833792
    834     void eliminateIrrelevantPhantomChildren(Node* node)
    835     {
    836         ASSERT(node->op() == Phantom);
    837         for (unsigned i = 0; i < AdjacencyList::Size; ++i) {
    838             Edge edge = node->children.child(i);
    839             if (!edge)
    840                 continue;
    841             if (edge.useKind() != UntypedUse)
    842                 continue; // Keep the type check.
    843             if (edge->flags() & NodeRelevantToOSR)
    844                 continue;
    845            
    846             node->children.removeEdge(i--);
    847             m_changed = true;
    848         }
    849     }
    850    
    851793    bool setReplacement(Node* replacement)
    852794    {
     
    855797       
    856798        m_currentNode->convertToPhantom();
    857         eliminateIrrelevantPhantomChildren(m_currentNode);
    858799       
    859800        // At this point we will eliminate all references to this node.
     
    869810        ASSERT(m_currentNode->mustGenerate());
    870811        m_currentNode->convertToPhantom();
    871         eliminateIrrelevantPhantomChildren(m_currentNode);
    872812       
    873813        m_changed = true;
     
    880820        ASSERT(node->mustGenerate());
    881821        node->setOpAndDefaultFlags(phantomType);
    882         if (phantomType == Phantom)
    883             eliminateIrrelevantPhantomChildren(node);
    884822       
    885823        m_changed = true;
     
    11111049            break;
    11121050           
    1113         case Phantom:
    1114             // FIXME: we ought to remove Phantom's that have no children.
    1115             // NB. It would be incorrect to do this for HardPhantom. In fact, the whole point
    1116             // of HardPhantom is that we *don't* do this for HardPhantoms, since they signify
    1117             // a more strict kind of liveness than the Phantom bytecode liveness.
    1118             eliminateIrrelevantPhantomChildren(node);
    1119             break;
    1120            
    11211051        case Flush:
    11221052            // This is needed for arguments simplification to work. We need to eliminate the
  • branches/ftlopt/Source/JavaScriptCore/dfg/DFGPlan.cpp

    r170060 r170907  
    5050#include "DFGOSRAvailabilityAnalysisPhase.h"
    5151#include "DFGOSREntrypointCreationPhase.h"
     52#include "DFGPhantomRemovalPhase.h"
    5253#include "DFGPredictionInjectionPhase.h"
    5354#include "DFGPredictionPropagationPhase.h"
     
    261262    if (validationEnabled())
    262263        validate(dfg);
    263 
     264   
    264265    performCPSRethreading(dfg);
    265266    if (changed) {
     
    282283
    283284        performStoreBarrierElision(dfg);
     285        performPhantomRemoval(dfg);
    284286        performCPSRethreading(dfg);
    285287        performDCE(dfg);
     
    309311        }
    310312       
     313        performPhantomRemoval(dfg);
    311314        performCriticalEdgeBreaking(dfg);
    312315        performLoopPreHeaderCreation(dfg);
     
    325328        }
    326329        performLICM(dfg);
     330        performPhantomRemoval(dfg);
    327331        performIntegerCheckCombining(dfg);
    328332        performCSE(dfg);
     
    333337       
    334338        performStoreBarrierElision(dfg);
     339        performPhantomRemoval(dfg);
    335340        performLivenessAnalysis(dfg);
    336341        performCFA(dfg);
Note: See TracChangeset for help on using the changeset viewer.