DFG::NodeOrigin should have a flag determining if exiting is OK right now
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 20:48:59 +0000 (20:48 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 20:48:59 +0000 (20:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148323

Reviewed by Saam Barati.

* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::currentNodeOrigin):
(JSC::DFG::ByteCodeParser::branchData):
* dfg/DFGInsertionSet.h:
(JSC::DFG::InsertionSet::insertConstant):
(JSC::DFG::InsertionSet::insertConstantForUse):
(JSC::DFG::InsertionSet::insertBottomConstantForUse):
* dfg/DFGIntegerCheckCombiningPhase.cpp:
(JSC::DFG::IntegerCheckCombiningPhase::handleBlock):
* dfg/DFGLICMPhase.cpp:
(JSC::DFG::LICMPhase::attemptHoist):
* dfg/DFGNodeOrigin.h:
(JSC::DFG::NodeOrigin::NodeOrigin):
(JSC::DFG::NodeOrigin::isSet):
(JSC::DFG::NodeOrigin::withSemantic):
* dfg/DFGObjectAllocationSinkingPhase.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188771 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGInsertionSet.h
Source/JavaScriptCore/dfg/DFGIntegerCheckCombiningPhase.cpp
Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
Source/JavaScriptCore/dfg/DFGNodeOrigin.h
Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp

index 661754c..56b9287 100644 (file)
@@ -1,3 +1,27 @@
+2015-08-21  Filip Pizlo  <fpizlo@apple.com>
+
+        DFG::NodeOrigin should have a flag determining if exiting is OK right now
+        https://bugs.webkit.org/show_bug.cgi?id=148323
+
+        Reviewed by Saam Barati.
+
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::currentNodeOrigin):
+        (JSC::DFG::ByteCodeParser::branchData):
+        * dfg/DFGInsertionSet.h:
+        (JSC::DFG::InsertionSet::insertConstant):
+        (JSC::DFG::InsertionSet::insertConstantForUse):
+        (JSC::DFG::InsertionSet::insertBottomConstantForUse):
+        * dfg/DFGIntegerCheckCombiningPhase.cpp:
+        (JSC::DFG::IntegerCheckCombiningPhase::handleBlock):
+        * dfg/DFGLICMPhase.cpp:
+        (JSC::DFG::LICMPhase::attemptHoist):
+        * dfg/DFGNodeOrigin.h:
+        (JSC::DFG::NodeOrigin::NodeOrigin):
+        (JSC::DFG::NodeOrigin::isSet):
+        (JSC::DFG::NodeOrigin::withSemantic):
+        * dfg/DFGObjectAllocationSinkingPhase.cpp:
+
 2015-08-21  Saam barati  <sbarati@apple.com>
 
         DFG callOperations should not implicitly emit an exception check. At callOperation call sites, we should explicitly emit exception checks
index a25356f..25d0abd 100644 (file)
@@ -653,9 +653,13 @@ private:
     {
         // FIXME: We should set the forExit origin only on those nodes that can exit.
         // https://bugs.webkit.org/show_bug.cgi?id=145204
+        CodeOrigin semantic;
         if (m_currentSemanticOrigin.isSet())
-            return NodeOrigin(m_currentSemanticOrigin, currentCodeOrigin());
-        return NodeOrigin(currentCodeOrigin());
+            semantic = m_currentSemanticOrigin;
+        else
+            semantic = currentCodeOrigin();
+        
+        return NodeOrigin(semantic, currentCodeOrigin(), true);
     }
     
     BranchData* branchData(unsigned taken, unsigned notTaken)
index c5ed4c2..966c086 100644 (file)
@@ -71,12 +71,6 @@ public:
             index, speculationFromValue(value->value()), op, origin, OpInfo(value));
     }
     
-    Node* insertConstant(
-        size_t index, CodeOrigin origin, FrozenValue* value, NodeType op = JSConstant)
-    {
-        return insertConstant(index, NodeOrigin(origin), value, op);
-    }
-    
     Edge insertConstantForUse(
         size_t index, NodeOrigin origin, FrozenValue* value, UseKind useKind)
     {
@@ -90,32 +84,16 @@ public:
         return Edge(insertConstant(index, origin, value, op), useKind);
     }
     
-    Edge insertConstantForUse(
-        size_t index, CodeOrigin origin, FrozenValue* value, UseKind useKind)
-    {
-        return insertConstantForUse(index, NodeOrigin(origin), value, useKind);
-    }
-
     Node* insertConstant(size_t index, NodeOrigin origin, JSValue value, NodeType op = JSConstant)
     {
         return insertConstant(index, origin, m_graph.freeze(value), op);
     }
     
-    Node* insertConstant(size_t index, CodeOrigin origin, JSValue value, NodeType op = JSConstant)
-    {
-        return insertConstant(index, origin, m_graph.freeze(value), op);
-    }
-    
     Edge insertConstantForUse(size_t index, NodeOrigin origin, JSValue value, UseKind useKind)
     {
         return insertConstantForUse(index, origin, m_graph.freeze(value), useKind);
     }
     
-    Edge insertConstantForUse(size_t index, CodeOrigin origin, JSValue value, UseKind useKind)
-    {
-        return insertConstantForUse(index, NodeOrigin(origin), value, useKind);
-    }
-    
     Edge insertBottomConstantForUse(size_t index, NodeOrigin origin, UseKind useKind)
     {
         if (isDouble(useKind))
index 5ddda08..b9f1eba 100644 (file)
@@ -233,18 +233,15 @@ private:
             
             // Do the hoisting.
             if (!range.m_hoisted) {
+                NodeOrigin minOrigin = node->origin.withSemantic(range.m_minOrigin);
+                NodeOrigin maxOrigin = node->origin.withSemantic(range.m_maxOrigin);
+                
                 switch (data.m_key.m_kind) {
                 case Addition: {
-                    if (range.m_minBound < 0) {
-                        insertAdd(
-                            nodeIndex, NodeOrigin(range.m_minOrigin, node->origin.forExit),
-                            data.m_key.m_source, range.m_minBound);
-                    }
-                    if (range.m_maxBound > 0) {
-                        insertAdd(
-                            nodeIndex, NodeOrigin(range.m_maxOrigin, node->origin.forExit),
-                            data.m_key.m_source, range.m_maxBound);
-                    }
+                    if (range.m_minBound < 0)
+                        insertAdd(nodeIndex, minOrigin, data.m_key.m_source, range.m_minBound);
+                    if (range.m_maxBound > 0)
+                        insertAdd(nodeIndex, maxOrigin, data.m_key.m_source, range.m_maxBound);
                     break;
                 }
                 
@@ -255,14 +252,14 @@ private:
                     if (!data.m_key.m_source) {
                         minNode = 0;
                         maxNode = m_insertionSet.insertConstant(
-                            nodeIndex, range.m_maxOrigin, jsNumber(range.m_maxBound));
+                            nodeIndex, maxOrigin, jsNumber(range.m_maxBound));
                     } else {
                         minNode = insertAdd(
-                            nodeIndex, NodeOrigin(range.m_minOrigin, node->origin.forExit),
-                            data.m_key.m_source, range.m_minBound, Arith::Unchecked);
+                            nodeIndex, minOrigin, data.m_key.m_source, range.m_minBound,
+                            Arith::Unchecked);
                         maxNode = insertAdd(
-                            nodeIndex, NodeOrigin(range.m_maxOrigin, node->origin.forExit),
-                            data.m_key.m_source, range.m_maxBound, Arith::Unchecked);
+                            nodeIndex, maxOrigin, data.m_key.m_source, range.m_maxBound,
+                            Arith::Unchecked);
                     }
                     
                     if (minNode) {
index 62cde8a..66f5742 100644 (file)
@@ -287,9 +287,7 @@ private:
         data.preHeader->insertBeforeTerminal(node);
         node->owner = data.preHeader;
         NodeOrigin originalOrigin = node->origin;
-        node->origin.forExit = data.preHeader->terminal()->origin.forExit;
-        if (!node->origin.semantic.isSet())
-            node->origin.semantic = node->origin.forExit;
+        node->origin = data.preHeader->terminal()->origin.withSemantic(node->origin.semantic);
         
         // Modify the states at the end of the preHeader of the loop we hoisted to,
         // and all pre-headers inside the loop.
index 12cc064..40d9bca 100644 (file)
@@ -35,29 +35,37 @@ namespace JSC { namespace DFG {
 struct NodeOrigin {
     NodeOrigin() { }
     
-    explicit NodeOrigin(CodeOrigin codeOrigin)
-        : semantic(codeOrigin)
-        , forExit(codeOrigin)
-    {
-    }
-    
-    NodeOrigin(CodeOrigin semantic, CodeOrigin forExit)
+    NodeOrigin(CodeOrigin semantic, CodeOrigin forExit, bool exitOK)
         : semantic(semantic)
         , forExit(forExit)
+        , exitOK(exitOK)
     {
     }
-    
+
     bool isSet() const
     {
         ASSERT(semantic.isSet() == forExit.isSet());
         return semantic.isSet();
     }
     
+    NodeOrigin withSemantic(CodeOrigin semantic)
+    {
+        if (!isSet())
+            return NodeOrigin();
+        
+        NodeOrigin result = *this;
+        if (semantic.isSet())
+            result.semantic = semantic;
+        return result;
+    }
+    
     // Used for determining what bytecode this came from. This is important for
     // debugging, exceptions, and even basic execution semantics.
     CodeOrigin semantic;
     // Code origin for where the node exits to.
     CodeOrigin forExit;
+    // Whether or not it is legal to exit here.
+    bool exitOK { false };
 };
 
 } } // namespace JSC::DFG
index f6f4919..6fc307a 100644 (file)
@@ -1483,9 +1483,7 @@ private:
 
             return m_graph.addNode(
                 allocation.identifier()->prediction(), Node::VarArg, MaterializeNewObject,
-                NodeOrigin(
-                    allocation.identifier()->origin.semantic,
-                    where->origin.forExit),
+                where->origin.withSemantic(allocation.identifier()->origin.semantic),
                 OpInfo(set), OpInfo(data), 0, 0);
         }
 
@@ -1497,9 +1495,8 @@ private:
             
             return m_graph.addNode(
                 allocation.identifier()->prediction(), nodeType,
-                NodeOrigin(
-                    allocation.identifier()->origin.semantic,
-                    where->origin.forExit),
+                where->origin.withSemantic(
+                    allocation.identifier()->origin.semantic),
                 OpInfo(executable));
             break;
         }
@@ -1510,9 +1507,8 @@ private:
 
             return m_graph.addNode(
                 allocation.identifier()->prediction(), Node::VarArg, MaterializeCreateActivation,
-                NodeOrigin(
-                    allocation.identifier()->origin.semantic,
-                    where->origin.forExit),
+                where->origin.withSemantic(
+                    allocation.identifier()->origin.semantic),
                 OpInfo(symbolTable), OpInfo(data), 0, 0);
         }
 
@@ -2093,11 +2089,7 @@ private:
 
         if (base->isPhantomAllocation()) {
             return PromotedHeapLocation(base, location.descriptor()).createHint(
-                m_graph,
-                NodeOrigin(
-                    base->origin.semantic,
-                    where->origin.forExit),
-                value);
+                m_graph, where->origin.withSemantic(base->origin.semantic), value);
         }
 
         switch (location.kind()) {
@@ -2160,9 +2152,7 @@ private:
             return m_graph.addNode(
                 SpecNone,
                 MultiPutByOffset,
-                NodeOrigin(
-                    base->origin.semantic,
-                    where->origin.forExit),
+                where->origin.withSemantic(base->origin.semantic),
                 OpInfo(data),
                 Edge(base, KnownCellUse),
                 value->defaultEdge());
@@ -2173,9 +2163,7 @@ private:
             return m_graph.addNode(
                 SpecNone,
                 PutClosureVar,
-                NodeOrigin(
-                    base->origin.semantic,
-                    where->origin.forExit),
+                where->origin.withSemantic(base->origin.semantic),
                 OpInfo(location.info()),
                 Edge(base, KnownCellUse),
                 value->defaultEdge());