Global variable predictions should not be coalesced unnecessarily
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 20:51:21 +0000 (20:51 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 20:51:21 +0000 (20:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83678

Reviewed by Geoff Garen.

Removed the PredictionTracker and everyone who used it. Converted GetGlobalVar
to have a heapPrediction like a civilized DFG opcode ought to.

No performance effect.

* GNUmakefile.list.am:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.h:
* bytecode/PredictionTracker.h: Removed.
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGGenerationInfo.h:
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dump):
* dfg/DFGGraph.h:
(Graph):
* dfg/DFGNode.h:
(JSC::DFG::Node::hasHeapPrediction):
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/bytecode/PredictionTracker.h [deleted file]
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGGenerationInfo.h
Source/JavaScriptCore/dfg/DFGGraph.cpp
Source/JavaScriptCore/dfg/DFGGraph.h
Source/JavaScriptCore/dfg/DFGNode.h
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

index 9248b4c..ca5c8dd 100644 (file)
@@ -1,3 +1,31 @@
+2012-04-11  Filip Pizlo  <fpizlo@apple.com>
+
+        Global variable predictions should not be coalesced unnecessarily
+        https://bugs.webkit.org/show_bug.cgi?id=83678
+
+        Reviewed by Geoff Garen.
+        
+        Removed the PredictionTracker and everyone who used it. Converted GetGlobalVar
+        to have a heapPrediction like a civilized DFG opcode ought to.
+        
+        No performance effect.
+
+        * GNUmakefile.list.am:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * bytecode/CodeBlock.h:
+        * bytecode/PredictionTracker.h: Removed.
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::parseBlock):
+        * dfg/DFGGenerationInfo.h:
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::dump):
+        * dfg/DFGGraph.h:
+        (Graph):
+        * dfg/DFGNode.h:
+        (JSC::DFG::Node::hasHeapPrediction):
+        * dfg/DFGPredictionPropagationPhase.cpp:
+        (JSC::DFG::PredictionPropagationPhase::propagate):
+
 2012-04-11  Benjamin Poulain  <bpoulain@apple.com>
 
         Optimize String.split() for 1 character separator
index a980b39..198b6a3 100644 (file)
@@ -122,7 +122,6 @@ javascriptcore_sources += \
        Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.h \
        Source/JavaScriptCore/bytecode/PredictedType.cpp \
        Source/JavaScriptCore/bytecode/PredictedType.h \
-       Source/JavaScriptCore/bytecode/PredictionTracker.h \
        Source/JavaScriptCore/bytecode/PutByIdStatus.cpp \
        Source/JavaScriptCore/bytecode/PutByIdStatus.h \
        Source/JavaScriptCore/bytecode/PutKind.h \
index de5f846..32dcd6f 100644 (file)
                0FD82E2114172CE300179C94 /* DFGCapabilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E1E14172C2F00179C94 /* DFGCapabilities.cpp */; };
                0FD82E39141AB14D00179C94 /* CompactJITCodeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E37141AB14200179C94 /* CompactJITCodeMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FD82E54141DAEEE00179C94 /* PredictedType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E4F141DAEA100179C94 /* PredictedType.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               0FD82E55141DAEEE00179C94 /* PredictionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E50141DAEA100179C94 /* PredictionTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FD82E56141DAF0800179C94 /* DFGOSREntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E52141DAEDE00179C94 /* DFGOSREntry.cpp */; };
                0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FD82E86141F3FF100179C94 /* PredictedType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E84141F3FDA00179C94 /* PredictedType.cpp */; };
                0FD82E1F14172C2F00179C94 /* DFGCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGCapabilities.h; path = dfg/DFGCapabilities.h; sourceTree = "<group>"; };
                0FD82E37141AB14200179C94 /* CompactJITCodeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactJITCodeMap.h; sourceTree = "<group>"; };
                0FD82E4F141DAEA100179C94 /* PredictedType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PredictedType.h; sourceTree = "<group>"; };
-               0FD82E50141DAEA100179C94 /* PredictionTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PredictionTracker.h; sourceTree = "<group>"; };
                0FD82E52141DAEDE00179C94 /* DFGOSREntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGOSREntry.cpp; path = dfg/DFGOSREntry.cpp; sourceTree = "<group>"; };
                0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSREntry.h; path = dfg/DFGOSREntry.h; sourceTree = "<group>"; };
                0FD82E84141F3FDA00179C94 /* PredictedType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PredictedType.cpp; sourceTree = "<group>"; };
                                969A07950ED1D3AE00F1F681 /* Opcode.h */,
                                0FD82E84141F3FDA00179C94 /* PredictedType.cpp */,
                                0FD82E4F141DAEA100179C94 /* PredictedType.h */,
-                               0FD82E50141DAEA100179C94 /* PredictionTracker.h */,
                                1429D8830ED21C3D00B89619 /* SamplingTool.cpp */,
                                1429D8840ED21C3D00B89619 /* SamplingTool.h */,
                                BCCF0D0B0EF0B8A500413C8F /* StructureStubInfo.cpp */,
                                93052C350FB792190048FDC3 /* ParserArena.h in Headers */,
                                65303D641447B9E100D3F904 /* ParserTokens.h in Headers */,
                                0FD82E54141DAEEE00179C94 /* PredictedType.h in Headers */,
-                               0FD82E55141DAEEE00179C94 /* PredictionTracker.h in Headers */,
                                BC18C4500E16F5CD00B34460 /* Profile.h in Headers */,
                                BC18C4510E16F5CD00B34460 /* ProfileNode.h in Headers */,
                                BC18C4520E16F5CD00B34460 /* Profiler.h in Headers */,
index d57d489..778376f 100644 (file)
@@ -56,7 +56,6 @@
 #include "LazyOperandValueProfile.h"
 #include "LineInfo.h"
 #include "Nodes.h"
-#include "PredictionTracker.h"
 #include "RegExpObject.h"
 #include "StructureStubInfo.h"
 #include "UString.h"
diff --git a/Source/JavaScriptCore/bytecode/PredictionTracker.h b/Source/JavaScriptCore/bytecode/PredictionTracker.h
deleted file mode 100644 (file)
index 7551cd3..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 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 PredictionTracker_h
-#define PredictionTracker_h
-
-#include "PredictedType.h"
-#include <wtf/HashMap.h>
-
-namespace JSC {
-
-struct PredictionSlot {
-public:
-    PredictionSlot()
-        : m_value(PredictNone)
-    {
-    }
-    PredictedType m_value;
-};
-
-class PredictionTracker {
-public:
-    PredictionTracker()
-    {
-    }
-    
-    bool predictGlobalVar(unsigned varNumber, PredictedType prediction)
-    {
-        HashMap<unsigned, PredictionSlot>::iterator iter = m_globalVars.find(varNumber + 1);
-        if (iter == m_globalVars.end()) {
-            PredictionSlot predictionSlot;
-            bool result = mergePrediction(predictionSlot.m_value, prediction);
-            m_globalVars.add(varNumber + 1, predictionSlot);
-            return result;
-        }
-        return mergePrediction(iter->second.m_value, prediction);
-    }
-    
-    PredictedType getGlobalVarPrediction(unsigned varNumber)
-    {
-        HashMap<unsigned, PredictionSlot>::iterator iter = m_globalVars.find(varNumber + 1);
-        if (iter == m_globalVars.end())
-            return PredictNone;
-        return iter->second.m_value;
-    }
-    
-private:
-    HashMap<unsigned, PredictionSlot> m_globalVars;
-};
-
-} // namespace JSC
-
-#endif // PredictionTracker_h
-
index 08ad461..7f4077b 100644 (file)
@@ -2022,9 +2022,8 @@ bool ByteCodeParser::parseBlock(unsigned limit)
         case op_get_global_var: {
             PredictedType prediction = getPrediction();
             
-            NodeIndex getGlobalVar = addToGraph(GetGlobalVar, OpInfo(currentInstruction[2].u.operand));
+            NodeIndex getGlobalVar = addToGraph(GetGlobalVar, OpInfo(currentInstruction[2].u.operand), OpInfo(prediction));
             set(currentInstruction[1].u.operand, getGlobalVar);
-            m_graph.predictGlobalVar(currentInstruction[2].u.operand, prediction);
             NEXT_OPCODE(op_get_global_var);
         }
 
index 86c0a4e..3c99e5d 100644 (file)
@@ -268,8 +268,6 @@ void Graph::dump(NodeIndex nodeIndex)
             dataLog("  predicting %s, double ratio %lf%s", predictionToString(node.variableAccessData()->prediction()), node.variableAccessData()->doubleVoteRatio(), node.variableAccessData()->shouldUseDoubleFormat() ? ", forcing double" : "");
         else if (node.hasHeapPrediction())
             dataLog("  predicting %s", predictionToString(node.getHeapPrediction()));
-        else if (node.hasVarNumber())
-            dataLog("  predicting %s", predictionToString(getGlobalVarPrediction(node.varNumber())));
     }
     
     dataLog("\n");
index 8e97548..0c8ac2d 100644 (file)
@@ -34,7 +34,6 @@
 #include "DFGBasicBlock.h"
 #include "DFGNode.h"
 #include "MethodOfGettingAValueProfile.h"
-#include "PredictionTracker.h"
 #include "RegisterFile.h"
 #include <wtf/BitVector.h>
 #include <wtf/HashMap.h>
@@ -148,16 +147,6 @@ public:
 
     BlockIndex blockIndexForBytecodeOffset(Vector<BlockIndex>& blocks, unsigned bytecodeBegin);
 
-    bool predictGlobalVar(unsigned varNumber, PredictedType prediction)
-    {
-        return m_predictions.predictGlobalVar(varNumber, prediction);
-    }
-    
-    PredictedType getGlobalVarPrediction(unsigned varNumber)
-    {
-        return m_predictions.getGlobalVarPrediction(varNumber);
-    }
-    
     PredictedType getJSConstantPrediction(Node& node)
     {
         return predictionFromValue(node.valueOfJSConstant(m_codeBlock));
@@ -390,8 +379,6 @@ private:
     // When a node's refCount goes from 0 to 1, it must (logically) recursively ref all of its children, and vice versa.
     void refChildren(NodeIndex);
     void derefChildren(NodeIndex);
-
-    PredictionTracker m_predictions;
 };
 
 class GetBytecodeBeginForBlock {
index 9dfd212..1aa2260 100644 (file)
@@ -476,6 +476,7 @@ struct Node {
         case ArrayPush:
         case RegExpExec:
         case RegExpTest:
+        case GetGlobalVar:
             return true;
         default:
             return false;
index 6ad4af5..2be8fad 100644 (file)
@@ -447,14 +447,11 @@ private:
         }
             
         case GetGlobalVar: {
-            PredictedType prediction = m_graph.getGlobalVarPrediction(node.varNumber());
-            changed |= mergePrediction(prediction);
+            changed |= mergePrediction(node.getHeapPrediction());
             break;
         }
             
         case PutGlobalVar: {
-            changed |= m_graph.predictGlobalVar(
-                node.varNumber(), m_graph[node.child1()].prediction());
             changed |= m_graph[node.child1()].mergeFlags(NodeUsedAsValue);
             break;
         }