GetScopedVar should have value profiling
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 06:59:38 +0000 (06:59 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 06:59:38 +0000 (06:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68676

Reviewed by Oliver Hunt.

Added GetScopedVar value profiling and predictin propagation.
Added GetScopeChain to CSE.

* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::predict):
* dfg/DFGNode.h:
(JSC::DFG::Node::hasPrediction):
* dfg/DFGPropagator.cpp:
(JSC::DFG::Propagator::propagateNodePredictions):
(JSC::DFG::Propagator::getScopeChainLoadElimination):
(JSC::DFG::Propagator::performNodeCSE):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_scoped_var):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGGraph.h
Source/JavaScriptCore/dfg/DFGNode.h
Source/JavaScriptCore/dfg/DFGPropagator.cpp
Source/JavaScriptCore/jit/JITPropertyAccess.cpp

index a01ea98..3d5f6f9 100644 (file)
@@ -1,5 +1,28 @@
 2011-09-22  Filip Pizlo  <fpizlo@apple.com>
 
+        GetScopedVar should have value profiling
+        https://bugs.webkit.org/show_bug.cgi?id=68676
+
+        Reviewed by Oliver Hunt.
+        
+        Added GetScopedVar value profiling and predictin propagation.
+        Added GetScopeChain to CSE.
+
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::parseBlock):
+        * dfg/DFGGraph.h:
+        (JSC::DFG::Graph::predict):
+        * dfg/DFGNode.h:
+        (JSC::DFG::Node::hasPrediction):
+        * dfg/DFGPropagator.cpp:
+        (JSC::DFG::Propagator::propagateNodePredictions):
+        (JSC::DFG::Propagator::getScopeChainLoadElimination):
+        (JSC::DFG::Propagator::performNodeCSE):
+        * jit/JITPropertyAccess.cpp:
+        (JSC::JIT::emit_op_get_scoped_var):
+
+2011-09-22  Filip Pizlo  <fpizlo@apple.com>
+
         PPC build fix, part 3.
 
         * runtime/Executable.cpp:
index 885765e..44a9436 100644 (file)
@@ -1119,8 +1119,9 @@ bool ByteCodeParser::parseBlock(unsigned limit)
             int slot = currentInstruction[2].u.operand;
             int depth = currentInstruction[3].u.operand;
             NodeIndex getScopeChain = addToGraph(GetScopeChain, OpInfo(depth));
-            NodeIndex getScopedVar = addToGraph(GetScopedVar, OpInfo(slot), getScopeChain);
+            NodeIndex getScopedVar = addToGraph(GetScopedVar, OpInfo(slot), OpInfo(PredictNone), getScopeChain);
             set(dst, getScopedVar);
+            stronglyPredict(getScopedVar);
             NEXT_OPCODE(op_get_scoped_var);
         }
         case op_put_scoped_var: {
index d69d671..3c8ab23 100644 (file)
@@ -196,6 +196,7 @@ public:
         case Call:
         case Construct:
         case GetByOffset:
+        case GetScopedVar:
             return node.predict(prediction, source);
         default:
             return false;
index b5a1081..123a7fb 100644 (file)
@@ -624,6 +624,7 @@ struct Node {
         case Call:
         case Construct:
         case GetByOffset:
+        case GetScopedVar:
             return true;
         default:
             return false;
index b3feeb3..50452ac 100644 (file)
@@ -471,7 +471,7 @@ private:
             changed |= mergeUse(node.child1(), PredictObjectUnknown | StrongPredictionTag);
             changed |= node.predict(m_uses[m_compileIndex] & ~PredictionTagMask, StrongPrediction);
             if (isStrongPrediction(node.getPrediction()))
-                changed |= setPrediction(node.getPrediction());
+                changed |= mergePrediction(node.getPrediction());
             break;
         }
             
@@ -489,7 +489,7 @@ private:
         case GetByOffset: {
             changed |= node.predict(m_uses[m_compileIndex] & ~PredictionTagMask, StrongPrediction);
             if (isStrongPrediction(node.getPrediction()))
-                changed |= setPrediction(node.getPrediction());
+                changed |= mergePrediction(node.getPrediction());
             break;
         }
             
@@ -504,7 +504,7 @@ private:
             changed |= mergeUse(m_graph.m_varArgChildren[node.firstChild()], PredictObjectUnknown | StrongPredictionTag);
             changed |= node.predict(m_uses[m_compileIndex] & ~PredictionTagMask, StrongPrediction);
             if (isStrongPrediction(node.getPrediction()))
-                changed |= setPrediction(node.getPrediction());
+                changed |= mergePrediction(node.getPrediction());
             break;
         }
             
@@ -527,6 +527,19 @@ private:
             break;
         }
             
+        case GetScopedVar: {
+            changed |= node.predict(m_uses[m_compileIndex] & ~PredictionTagMask, StrongPrediction);
+            PredictedType prediction = node.getPrediction();
+            if (isStrongPrediction(prediction))
+                changed |= mergePrediction(prediction);
+            break;
+        }
+            
+        case GetScopeChain: {
+            changed |= setPrediction(makePrediction(PredictCellOther, StrongPrediction));
+            break;
+        }
+            
         case PutByVal:
         case PutByValAlias:
         case PutById:
@@ -535,7 +548,6 @@ private:
             break;
         }
 
-        case GetScopeChain:
         case GetCallee: {
             changed |= setPrediction(makePrediction(PredictObjectOther, StrongPrediction));
             break;
@@ -587,7 +599,6 @@ private:
         case Resolve:
         case ResolveBase:
         case ResolveBaseStrictPut:
-        case GetScopedVar:
             break;
             
         // This gets ignored because it doesn't do anything.
@@ -976,6 +987,18 @@ private:
         return NoNode;
     }
     
+    NodeIndex getScopeChainLoadElimination(unsigned depth)
+    {
+        NodeIndex start = startIndexForChildren();
+        for (NodeIndex index = endIndexForPureCSE(); index-- > start;) {
+            Node& node = m_graph[index];
+            if (node.op == GetScopeChain
+                && node.scopeChainDepth() == depth)
+                return index;
+        }
+        return NoNode;
+    }
+    
     void performSubstitution(NodeIndex& child)
     {
         // Check if this operand is actually unused.
@@ -1067,6 +1090,10 @@ private:
             setReplacement(pureCSE(node));
             break;
             
+        case GetScopeChain:
+            setReplacement(getScopeChainLoadElimination(node.scopeChainDepth()));
+            break;
+
         // Handle nodes that are conditionally pure: these are pure, and can
         // be CSE'd, so long as the prediction is the one we want.
         case ValueAdd:
index 4fa4919..eb50608 100644 (file)
@@ -965,6 +965,7 @@ void JIT::emit_op_get_scoped_var(Instruction* currentInstruction)
     loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, object)), regT0);
     loadPtr(Address(regT0, JSVariableObject::offsetOfRegisters()), regT0);
     loadPtr(Address(regT0, currentInstruction[2].u.operand * sizeof(Register)), regT0);
+    emitValueProfilingSite(FirstProfilingSite);
     emitPutVirtualRegister(currentInstruction[1].u.operand);
 }