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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142377 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/dfg/DFGUnificationPhase.h b/Source/JavaScriptCore/dfg/DFGUnificationPhase.h
new file mode 100644
index 0000000..6713de7
--- /dev/null
+++ b/Source/JavaScriptCore/dfg/DFGUnificationPhase.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DFGUnificationPhase_h
+#define DFGUnificationPhase_h
+
+#include <wtf/Platform.h>
+
+#if ENABLE(DFG_JIT)
+
+namespace JSC { namespace DFG {
+
+class Graph;
+
+// Unification:
+//
+// Examines all Phi functions and ensures that the variable access datas are
+// unified. This creates our "live-range split" view of variables.
+
+bool performUnification(Graph&);
+
+} } // namespace JSC::DFG
+
+#endif // ENABLE(DFG_JIT)
+
+#endif // DFGUnificationPhase_h
+