Ignore:
Timestamp:
Feb 9, 2013, 11:33:00 AM (13 years ago)
Author:
[email protected]
Message:

DFG should allow phases to break Phi's and then have one phase to rebuild them
https://bugs.webkit.org/show_bug.cgi?id=108414

Reviewed by Mark Hahnenberg.

Introduces two new DFG forms: LoadStore and ThreadedCPS. These are described in
detail in DFGCommon.h.

Consequently, DFG phases no longer have to worry about preserving data flow
links between basic blocks. It is generally always safe to request that the
graph be dethreaded (Graph::dethread), which brings it into LoadStore form, where
the data flow is implicit. In this form, only liveness-at-head needs to be
preserved.

All of the machinery for "threading" the graph to introduce data flow between
blocks is now moved out of the bytecode parser and into the CPSRethreadingPhase.
All phases that previously did this maintenance themselves now just rely on
being able to dethread the graph. The one exception is the structure check
hoising phase, which operates over a threaded graph and preserves it, for the
sake of performance.

Also moved two other things into their own phases: unification (previously found
in the parser) and prediction injection (previously found in various places).

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/Operands.h:

(Operands):
(JSC::Operands::sizeFor):
(JSC::Operands::atFor):

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::execute):
(JSC::DFG::AbstractState::mergeStateAtTail):

  • dfg/DFGAllocator.h:

(JSC::DFG::::allocateSlow):

  • dfg/DFGArgumentsSimplificationPhase.cpp:

(JSC::DFG::ArgumentsSimplificationPhase::run):

  • dfg/DFGBasicBlockInlines.h:

(DFG):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::getLocal):
(JSC::DFG::ByteCodeParser::getArgument):
(JSC::DFG::ByteCodeParser::flushDirect):
(JSC::DFG::ByteCodeParser::parseBlock):
(DFG):
(JSC::DFG::ByteCodeParser::parse):

  • dfg/DFGCFGSimplificationPhase.cpp:

(JSC::DFG::CFGSimplificationPhase::run):
(JSC::DFG::CFGSimplificationPhase::killUnreachable):
(JSC::DFG::CFGSimplificationPhase::keepOperandAlive):
(CFGSimplificationPhase):
(JSC::DFG::CFGSimplificationPhase::fixJettisonedPredecessors):
(JSC::DFG::CFGSimplificationPhase::mergeBlocks):

  • dfg/DFGCPSRethreadingPhase.cpp: Added.

(DFG):
(CPSRethreadingPhase):
(JSC::DFG::CPSRethreadingPhase::CPSRethreadingPhase):
(JSC::DFG::CPSRethreadingPhase::run):
(JSC::DFG::CPSRethreadingPhase::freeUnnecessaryNodes):
(JSC::DFG::CPSRethreadingPhase::clearVariablesAtHeadAndTail):
(JSC::DFG::CPSRethreadingPhase::addPhiSilently):
(JSC::DFG::CPSRethreadingPhase::addPhi):
(JSC::DFG::CPSRethreadingPhase::canonicalizeGetLocalFor):
(JSC::DFG::CPSRethreadingPhase::canonicalizeGetLocal):
(JSC::DFG::CPSRethreadingPhase::canonicalizeSetLocal):
(JSC::DFG::CPSRethreadingPhase::canonicalizeFlushOrPhantomLocalFor):
(JSC::DFG::CPSRethreadingPhase::canonicalizeFlushOrPhantomLocal):
(JSC::DFG::CPSRethreadingPhase::canonicalizeSetArgument):
(JSC::DFG::CPSRethreadingPhase::canonicalizeLocalsInBlock):
(JSC::DFG::CPSRethreadingPhase::canonicalizeLocalsInBlocks):
(JSC::DFG::CPSRethreadingPhase::propagatePhis):
(JSC::DFG::CPSRethreadingPhase::PhiStackEntry::PhiStackEntry):
(PhiStackEntry):
(JSC::DFG::CPSRethreadingPhase::phiStackFor):
(JSC::DFG::performCPSRethreading):

  • dfg/DFGCPSRethreadingPhase.h: Added.

(DFG):

  • dfg/DFGCSEPhase.cpp:

(CSEPhase):
(JSC::DFG::CSEPhase::performNodeCSE):

  • dfg/DFGCommon.cpp:

(WTF):
(WTF::printInternal):

  • dfg/DFGCommon.h:

(JSC::DFG::logCompilationChanges):
(DFG):
(WTF):

  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::foldConstants):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::Graph):
(JSC::DFG::Graph::dump):
(JSC::DFG::Graph::dethread):
(JSC::DFG::Graph::collectGarbage):

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::performSubstitution):
(Graph):
(JSC::DFG::Graph::performSubstitutionForEdge):
(JSC::DFG::Graph::convertToConstant):

  • dfg/DFGNode.h:

(JSC::DFG::Node::convertToPhantomLocal):
(Node):
(JSC::DFG::Node::convertToGetLocal):
(JSC::DFG::Node::hasVariableAccessData):

  • dfg/DFGNodeType.h:

(DFG):

  • dfg/DFGPhase.cpp:

(JSC::DFG::Phase::beginPhase):

  • dfg/DFGPhase.h:

(JSC::DFG::runAndLog):

  • dfg/DFGPredictionInjectionPhase.cpp: Added.

(DFG):
(PredictionInjectionPhase):
(JSC::DFG::PredictionInjectionPhase::PredictionInjectionPhase):
(JSC::DFG::PredictionInjectionPhase::run):
(JSC::DFG::performPredictionInjection):

  • dfg/DFGPredictionInjectionPhase.h: Added.

(DFG):

  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::run):
(JSC::DFG::PredictionPropagationPhase::propagate):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGStructureCheckHoistingPhase.cpp:

(JSC::DFG::StructureCheckHoistingPhase::run):

  • dfg/DFGUnificationPhase.cpp: Added.

(DFG):
(UnificationPhase):
(JSC::DFG::UnificationPhase::UnificationPhase):
(JSC::DFG::UnificationPhase::run):
(JSC::DFG::performUnification):

  • dfg/DFGUnificationPhase.h: Added.

(DFG):

  • dfg/DFGValidate.cpp:

(JSC::DFG::Validate::validate):
(JSC::DFG::Validate::dumpGraphIfAppropriate):

  • dfg/DFGVirtualRegisterAllocationPhase.cpp:

(JSC::DFG::VirtualRegisterAllocationPhase::run):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::setUpCall):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::dump):

  • runtime/JSString.h:

(JSString):

  • runtime/Options.h:

(JSC):

File:
1 edited

Legend:

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

    r141069 r142377  
    2828
    2929#include "CodeBlock.h"
     30#include "CodeBlockWithJITType.h"
    3031#include "DFGVariableAccessDataDump.h"
    3132#include "FunctionExecutableDump.h"
     
    5455    , m_mustHandleValues(mustHandleValues)
    5556    , m_fixpointState(BeforeFixpoint)
     57    , m_form(LoadStore)
     58    , m_unificationState(LocallyUnified)
    5659{
    5760    ASSERT(m_profiledBlock);
     
    196199    if (node->hasFunction()) {
    197200        out.print(comma, "function(", RawPointer(node->function()), ", ");
    198         if (node->function()->inherits(&JSFunction::s_info))
    199             out.print(FunctionExecutableDump(jsCast<JSFunction*>(node->function())->jsExecutable()));
    200         else
     201        if (node->function()->inherits(&JSFunction::s_info)) {
     202            JSFunction* function = jsCast<JSFunction*>(node->function());
     203            if (function->isHostFunction())
     204                out.print("<host function>");
     205            else
     206                out.print(FunctionExecutableDump(function->jsExecutable()));
     207        } else
    201208            out.print("<not JSFunction>");
    202209        out.print(")");
     
    305312void Graph::dump(PrintStream& out)
    306313{
     314    dataLog("DFG for ", CodeBlockWithJITType(m_codeBlock, JITCode::DFGJIT), ":\n");
     315    dataLog("  Fixpoint state: ", m_fixpointState, "; Form: ", m_form, "; Unification state: ", m_unificationState, "\n");
     316   
    307317    Node* lastNode = 0;
    308318    for (size_t b = 0; b < m_blocks.size(); ++b) {
     
    378388}
    379389
    380 void Graph::predictArgumentTypes()
    381 {
    382     ASSERT(m_codeBlock->numParameters() >= 1);
    383     for (size_t arg = 0; arg < static_cast<size_t>(m_codeBlock->numParameters()); ++arg) {
    384         ValueProfile* profile = m_profiledBlock->valueProfileForArgument(arg);
    385         if (!profile)
    386             continue;
    387        
    388         m_arguments[arg]->variableAccessData()->predict(profile->computeUpdatedPrediction());
    389        
    390 #if DFG_ENABLE(DEBUG_VERBOSE)
    391         dataLog(
    392             "Argument [", arg, "] prediction: ",
    393             SpeculationDump(m_arguments[arg]->variableAccessData()->prediction()), "\n");
    394 #endif
    395     }
     390void Graph::dethread()
     391{
     392    if (m_form == LoadStore)
     393        return;
     394   
     395    if (logCompilationChanges())
     396        dataLog("Dethreading DFG graph.\n");
     397   
     398    SamplingRegion samplingRegion("DFG Dethreading");
     399   
     400    for (BlockIndex blockIndex = m_blocks.size(); blockIndex--;) {
     401        BasicBlock* block = m_blocks[blockIndex].get();
     402        if (!block)
     403            continue;
     404        for (unsigned phiIndex = block->phis.size(); phiIndex--;) {
     405            Node* phi = block->phis[phiIndex];
     406            phi->children.reset();
     407        }
     408    }
     409   
     410    m_form = LoadStore;
    396411}
    397412
     
    409424void Graph::collectGarbage()
    410425{
     426    SamplingRegion samplingRegion("DFG Garbage Collection");
     427   
    411428    // First reset the counts to 0 for all nodes.
    412429    for (BlockIndex blockIndex = 0; blockIndex < m_blocks.size(); ++blockIndex) {
Note: See TracChangeset for help on using the changeset viewer.