• fpizlo@apple.com's avatar
    Inserting a node into the DFG graph should not require five lines of code · f45e88b5
    fpizlo@apple.com authored
    Reviewed by Sam Weinig.
    This adds fairly comprehensive support for inserting a node into a DFG graph in one
    method call. A common example of this is:
    m_insertionSet.insertNode(indexInBlock, DontRefChildren, DontRefNode, SpecNone, ForceOSRExit, codeOrigin);
    The arguments to insert() specify what reference counting you need to have happen
    (RefChildren => recursively refs all children, RefNode => non-recursively refs the node
    that was created), the prediction to set (SpecNone is a common default), followed by
    the arguments to the Node() constructor. InsertionSet::insertNode() and similar methods
    (Graph::addNode() and BasicBlock::appendNode()) all use a common variadic template
    function macro from DFGVariadicFunction.h. Also, all of these methods will automatically
    non-recursively ref() the node being created if the flags say NodeMustGenerate.
    In all, this new mechanism retains the flexibility of the old approach (you get to
    manage ref counts yourself, albeit in less code) while ensuring that most code that adds
    nodes to the graph now needs less code to do it.
    In the future, we should revisit the reference counting methodology in the DFG: we could
    do like most compilers and get rid of it entirely, or we could make it automatic. This
    patch doesn't attempt to make any such major changes, and only seeks to simplify the
    technique we were already using (manual ref counting).
    * GNUmakefile.list.am:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * bytecode/Operands.h:
    * dfg/DFGAdjacencyList.h:
    * dfg/DFGArgumentsSimplificationPhase.cpp:
    * dfg/DFGBasicBlock.h:
    * dfg/DFGBasicBlockInlines.h: Added.
    * dfg/DFGCFGSimplificationPhase.cpp:
    * dfg/DFGCommon.h:
    * dfg/DFGConstantFoldingPhase.cpp:
    * dfg/DFGFixupPhase.cpp:
    * dfg/DFGGraph.h:
    * dfg/DFGInsertionSet.h:
    * dfg/DFGNode.h:
    * dfg/DFGStructureCheckHoistingPhase.cpp:
    * dfg/DFGVariadicFunction.h: Added.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140275 268f45cc-cd09-0410-ab3c-d52691b4dbfc