Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (111973 => 111974)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2012-03-24 03:23:02 UTC (rev 111974)
@@ -65,6 +65,7 @@
dfg/DFGCorrectableJumpPoint.cpp
dfg/DFGCSEPhase.cpp
dfg/DFGDriver.cpp
+ dfg/DFGFixupPhase.cpp
dfg/DFGGraph.cpp
dfg/DFGJITCompiler.cpp
dfg/DFGNodeFlags.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (111973 => 111974)
--- trunk/Source/_javascript_Core/ChangeLog 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-03-24 03:23:02 UTC (rev 111974)
@@ -1,3 +1,39 @@
+2012-03-23 Filip Pizlo <[email protected]>
+
+ DFG Fixup should be able to short-circuit trivial ValueToInt32's
+ https://bugs.webkit.org/show_bug.cgi?id=82030
+
+ Reviewed by Michael Saboff.
+
+ Takes the fixup() method of the prediction propagation phase and makes it
+ into its own phase. Adds the ability to short-circuit trivial ValueToInt32
+ nodes, and mark pure ValueToInt32's as such.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Target.pri:
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::makeSafe):
+ (JSC::DFG::ByteCodeParser::handleCall):
+ (JSC::DFG::ByteCodeParser::parseBlock):
+ * dfg/DFGCommon.h:
+ * dfg/DFGDriver.cpp:
+ (JSC::DFG::compile):
+ * dfg/DFGFixupPhase.cpp: Added.
+ (DFG):
+ (FixupPhase):
+ (JSC::DFG::FixupPhase::FixupPhase):
+ (JSC::DFG::FixupPhase::run):
+ (JSC::DFG::FixupPhase::fixupNode):
+ (JSC::DFG::FixupPhase::fixIntEdge):
+ (JSC::DFG::performFixup):
+ * dfg/DFGFixupPhase.h: Added.
+ (DFG):
+ * dfg/DFGPredictionPropagationPhase.cpp:
+ (JSC::DFG::PredictionPropagationPhase::run):
+ (PredictionPropagationPhase):
+
2012-03-23 Mark Hahnenberg <[email protected]>
tryReallocate could break the zero-ed memory invariant of CopiedBlocks
Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (111973 => 111974)
--- trunk/Source/_javascript_Core/GNUmakefile.list.am 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am 2012-03-24 03:23:02 UTC (rev 111974)
@@ -161,6 +161,8 @@
Source/_javascript_Core/dfg/DFGDriver.cpp \
Source/_javascript_Core/dfg/DFGDriver.h \
Source/_javascript_Core/dfg/DFGFPRInfo.h \
+ Source/_javascript_Core/dfg/DFGFixupPhase.cpp \
+ Source/_javascript_Core/dfg/DFGFixupPhase.h \
Source/_javascript_Core/dfg/DFGGenerationInfo.h \
Source/_javascript_Core/dfg/DFGGPRInfo.h \
Source/_javascript_Core/dfg/DFGGraph.cpp \
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (111973 => 111974)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2012-03-24 03:23:02 UTC (rev 111974)
@@ -72,6 +72,8 @@
0F21C27D14BE727A00ADC64B /* CodeSpecializationKind.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F21C27F14BEAA8200ADC64B /* BytecodeConventions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C27E14BEAA8000ADC64B /* BytecodeConventions.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F242DA713F3B1E8007ADD4C /* WeakReferenceHarvester.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0F2BDC15151C5D4D00CD8910 /* DFGFixupPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2BDC12151C5D4A00CD8910 /* DFGFixupPhase.cpp */; };
+ 0F2BDC16151C5D4F00CD8910 /* DFGFixupPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2BDC13151C5D4A00CD8910 /* DFGFixupPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F2C556F14738F3100121E4F /* DFGCodeBlocks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2C556E14738F2E00121E4F /* DFGCodeBlocks.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F2C557014738F3500121E4F /* DFGCodeBlocks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2C556D14738F2E00121E4F /* DFGCodeBlocks.cpp */; };
0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A451460CBAB00131F8F /* ValueRecovery.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -720,6 +722,8 @@
0F21C27A14BE727300ADC64B /* ExecutionHarness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutionHarness.h; sourceTree = "<group>"; };
0F21C27E14BEAA8000ADC64B /* BytecodeConventions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeConventions.h; sourceTree = "<group>"; };
0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakReferenceHarvester.h; sourceTree = "<group>"; };
+ 0F2BDC12151C5D4A00CD8910 /* DFGFixupPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGFixupPhase.cpp; path = dfg/DFGFixupPhase.cpp; sourceTree = "<group>"; };
+ 0F2BDC13151C5D4A00CD8910 /* DFGFixupPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGFixupPhase.h; path = dfg/DFGFixupPhase.h; sourceTree = "<group>"; };
0F2C556D14738F2E00121E4F /* DFGCodeBlocks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFGCodeBlocks.cpp; sourceTree = "<group>"; };
0F2C556E14738F2E00121E4F /* DFGCodeBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFGCodeBlocks.h; sourceTree = "<group>"; };
0F426A451460CBAB00131F8F /* ValueRecovery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueRecovery.h; sourceTree = "<group>"; };
@@ -1984,6 +1988,8 @@
0FD3C82014115CF800FD81CB /* DFGDriver.cpp */,
0FD3C82214115D0E00FD81CB /* DFGDriver.h */,
86AE6C4B136A11E400963012 /* DFGFPRInfo.h */,
+ 0F2BDC12151C5D4A00CD8910 /* DFGFixupPhase.cpp */,
+ 0F2BDC13151C5D4A00CD8910 /* DFGFixupPhase.h */,
86EC9DB61328DF82002B2AD7 /* DFGGenerationInfo.h */,
86AE6C4C136A11E400963012 /* DFGGPRInfo.h */,
86EC9DB71328DF82002B2AD7 /* DFGGraph.cpp */,
@@ -2494,6 +2500,7 @@
0A4337BE1506219B00991C95 /* DFGRedundantPhiEliminationPhase.h in Headers */,
0FA581BB150E953000B9A2D9 /* DFGNodeFlags.h in Headers */,
0FA581BC150E953000B9A2D9 /* DFGNodeType.h in Headers */,
+ 0F2BDC16151C5D4F00CD8910 /* DFGFixupPhase.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3048,6 +3055,7 @@
0F56A1D515001CF4002992B1 /* ExecutionCounter.cpp in Sources */,
0A4337BB1506218800991C95 /* DFGRedundantPhiEliminationPhase.cpp in Sources */,
0FA581BA150E952C00B9A2D9 /* DFGNodeFlags.cpp in Sources */,
+ 0F2BDC15151C5D4D00CD8910 /* DFGFixupPhase.cpp in Sources */,
8642C510151C06A90046D4EF /* RegExpCachedResult.cpp in Sources */,
8642C512151C083D0046D4EF /* RegExpMatchesArray.cpp in Sources */,
);
Modified: trunk/Source/_javascript_Core/Target.pri (111973 => 111974)
--- trunk/Source/_javascript_Core/Target.pri 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/Target.pri 2012-03-24 03:23:02 UTC (rev 111974)
@@ -92,6 +92,7 @@
dfg/DFGCorrectableJumpPoint.cpp \
dfg/DFGCSEPhase.cpp \
dfg/DFGDriver.cpp \
+ dfg/DFGFixupPhase.cpp \
dfg/DFGGraph.cpp \
dfg/DFGJITCompiler.cpp \
dfg/DFGNodeFlags.cpp \
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (111973 => 111974)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2012-03-24 03:23:02 UTC (rev 111974)
@@ -698,10 +698,6 @@
&& !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, NegativeZero))
return nodeIndex;
-#if DFG_ENABLE(DEBUG_VERBOSE)
- dataLog("Making %s @%u safe at bc#%u because slow-case counter is at %u and exit profiles say %d, %d\n", Graph::opName(m_graph[nodeIndex].op()), nodeIndex, m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter, m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, Overflow), m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, NegativeZero));
-#endif
-
switch (m_graph[nodeIndex].op()) {
case UInt32ToNumber:
case ArithAdd:
@@ -993,10 +989,6 @@
NodeIndex callTarget = get(currentInstruction[1].u.operand);
enum { ConstantFunction, LinkedFunction, UnknownFunction } callType;
-#if DFG_ENABLE(DEBUG_VERBOSE)
- dataLog("Slow case count for call at @%zu bc#%u: %u/%u; exit profile: %d.\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter, m_inlineStackTop->m_profiledBlock->executionEntryCount(), m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache));
-#endif
-
CallLinkStatus callLinkStatus = CallLinkStatus::computeFor(
m_inlineStackTop->m_profiledBlock, m_currentIndex);
@@ -1879,10 +1871,6 @@
GetByIdStatus getByIdStatus = GetByIdStatus::computeFor(
m_inlineStackTop->m_profiledBlock, m_currentIndex, identifier);
-#if DFG_ENABLE(DEBUG_VERBOSE)
- dataLog("Slow case count for GetById @%zu bc#%u: %u; exit profile: %d\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter, m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache));
-#endif
-
if (getByIdStatus.isSimpleDirect()
&& !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache)) {
ASSERT(getByIdStatus.structureSet().size());
@@ -1921,10 +1909,6 @@
bool hasExitSite = m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache);
-#if DFG_ENABLE(DEBUG_VERBOSE)
- dataLog("Slow case count for PutById @%zu bc#%u: %u; exit profile: %d\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter, m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache));
-#endif
-
if (!hasExitSite && putByIdStatus.isSimpleReplace()) {
addToGraph(CheckStructure, OpInfo(m_graph.addStructureSet(putByIdStatus.oldStructure())), base);
addToGraph(PutByOffset, OpInfo(m_graph.m_storageAccessData.size()), base, addToGraph(GetPropertyStorage, base), value);
Modified: trunk/Source/_javascript_Core/dfg/DFGCommon.h (111973 => 111974)
--- trunk/Source/_javascript_Core/dfg/DFGCommon.h 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/dfg/DFGCommon.h 2012-03-24 03:23:02 UTC (rev 111974)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Modified: trunk/Source/_javascript_Core/dfg/DFGDriver.cpp (111973 => 111974)
--- trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2012-03-24 03:23:02 UTC (rev 111974)
@@ -31,6 +31,7 @@
#include "DFGByteCodeParser.h"
#include "DFGCFAPhase.h"
#include "DFGCSEPhase.h"
+#include "DFGFixupPhase.h"
#include "DFGJITCompiler.h"
#include "DFGPredictionPropagationPhase.h"
#include "DFGRedundantPhiEliminationPhase.h"
@@ -60,6 +61,7 @@
performRedundantPhiElimination(dfg);
performPredictionPropagation(dfg);
+ performFixup(dfg);
performCSE(dfg);
performVirtualRegisterAllocation(dfg);
performCFA(dfg);
Added: trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (0 => 111974)
--- trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (rev 0)
+++ trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp 2012-03-24 03:23:02 UTC (rev 111974)
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#include "config.h"
+#include "DFGFixupPhase.h"
+
+#if ENABLE(DFG_JIT)
+
+#include "DFGGraph.h"
+#include "DFGPhase.h"
+
+namespace JSC { namespace DFG {
+
+class FixupPhase : public Phase {
+public:
+ FixupPhase(Graph& graph)
+ : Phase(graph, "fixup")
+ {
+ }
+
+ void run()
+ {
+ for (m_compileIndex = 0; m_compileIndex < m_graph.size(); ++m_compileIndex)
+ fixupNode(m_graph[m_compileIndex]);
+ }
+
+private:
+ void fixupNode(Node& node)
+ {
+ if (!node.shouldGenerate())
+ return;
+
+ NodeType op = node.op();
+
+#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
+ dataLog(" %s @%u: ", Graph::opName(op), m_compileIndex);
+#endif
+
+ switch (op) {
+ case GetById: {
+ if (!isInt32Prediction(m_graph[m_compileIndex].prediction()))
+ break;
+ if (codeBlock()->identifier(node.identifierNumber()) != globalData().propertyNames->length)
+ break;
+ bool isArray = isArrayPrediction(m_graph[node.child1()].prediction());
+ bool isString = isStringPrediction(m_graph[node.child1()].prediction());
+ bool isByteArray = m_graph[node.child1()].shouldSpeculateByteArray();
+ bool isInt8Array = m_graph[node.child1()].shouldSpeculateInt8Array();
+ bool isInt16Array = m_graph[node.child1()].shouldSpeculateInt16Array();
+ bool isInt32Array = m_graph[node.child1()].shouldSpeculateInt32Array();
+ bool isUint8Array = m_graph[node.child1()].shouldSpeculateUint8Array();
+ bool isUint8ClampedArray = m_graph[node.child1()].shouldSpeculateUint8ClampedArray();
+ bool isUint16Array = m_graph[node.child1()].shouldSpeculateUint16Array();
+ bool isUint32Array = m_graph[node.child1()].shouldSpeculateUint32Array();
+ bool isFloat32Array = m_graph[node.child1()].shouldSpeculateFloat32Array();
+ bool isFloat64Array = m_graph[node.child1()].shouldSpeculateFloat64Array();
+ if (!isArray && !isString && !isByteArray && !isInt8Array && !isInt16Array && !isInt32Array && !isUint8Array && !isUint8ClampedArray && !isUint16Array && !isUint32Array && !isFloat32Array && !isFloat64Array)
+ break;
+
+#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
+ dataLog(" @%u -> %s", m_compileIndex, isArray ? "GetArrayLength" : "GetStringLength");
+#endif
+ if (isArray)
+ node.setOp(GetArrayLength);
+ else if (isString)
+ node.setOp(GetStringLength);
+ else if (isByteArray)
+ node.setOp(GetByteArrayLength);
+ else if (isInt8Array)
+ node.setOp(GetInt8ArrayLength);
+ else if (isInt16Array)
+ node.setOp(GetInt16ArrayLength);
+ else if (isInt32Array)
+ node.setOp(GetInt32ArrayLength);
+ else if (isUint8Array)
+ node.setOp(GetUint8ArrayLength);
+ else if (isUint8ClampedArray)
+ node.setOp(GetUint8ClampedArrayLength);
+ else if (isUint16Array)
+ node.setOp(GetUint16ArrayLength);
+ else if (isUint32Array)
+ node.setOp(GetUint32ArrayLength);
+ else if (isFloat32Array)
+ node.setOp(GetFloat32ArrayLength);
+ else if (isFloat64Array)
+ node.setOp(GetFloat64ArrayLength);
+ else
+ ASSERT_NOT_REACHED();
+ // No longer MustGenerate
+ ASSERT(node.flags() & NodeMustGenerate);
+ node.clearFlags(NodeMustGenerate);
+ m_graph.deref(m_compileIndex);
+ break;
+ }
+ case GetIndexedPropertyStorage: {
+ PredictedType basePrediction = m_graph[node.child2()].prediction();
+ if (!(basePrediction & PredictInt32) && basePrediction) {
+ node.setOpAndDefaultFlags(Nop);
+ m_graph.clearAndDerefChild1(node);
+ m_graph.clearAndDerefChild2(node);
+ m_graph.clearAndDerefChild3(node);
+ node.setRefCount(0);
+ }
+ break;
+ }
+ case GetByVal:
+ case StringCharAt:
+ case StringCharCodeAt: {
+ if (!!node.child3() && m_graph[node.child3()].op() == Nop)
+ node.children.child3() = Edge();
+ break;
+ }
+
+ case ValueToInt32: {
+ if (m_graph[node.child1()].shouldSpeculateNumber()) {
+ node.clearFlags(NodeMustGenerate);
+ m_graph.deref(m_compileIndex);
+ }
+ break;
+ }
+
+ case BitAnd:
+ case BitOr:
+ case BitXor:
+ case BitRShift:
+ case BitLShift:
+ case BitURShift: {
+ fixIntEdge(node.children.child1());
+ fixIntEdge(node.children.child2());
+ break;
+ }
+
+ default:
+ break;
+ }
+
+#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
+ dataLog("\n");
+#endif
+ }
+
+ void fixIntEdge(Edge& edge)
+ {
+ Node& node = m_graph[edge];
+ if (node.op() != ValueToInt32)
+ return;
+
+ if (!m_graph[node.child1()].shouldSpeculateInteger())
+ return;
+
+ Edge oldEdge = edge;
+ Edge newEdge = node.child1();
+
+ m_graph.ref(newEdge);
+ m_graph.deref(oldEdge);
+
+ edge = newEdge;
+ }
+
+ NodeIndex m_compileIndex;
+};
+
+void performFixup(Graph& graph)
+{
+ runPhase<FixupPhase>(graph);
+}
+
+} } // namespace JSC::DFG
+
+#endif // ENABLE(DFG_JIT)
+
Added: trunk/Source/_javascript_Core/dfg/DFGFixupPhase.h (0 => 111974)
--- trunk/Source/_javascript_Core/dfg/DFGFixupPhase.h (rev 0)
+++ trunk/Source/_javascript_Core/dfg/DFGFixupPhase.h 2012-03-24 03:23:02 UTC (rev 111974)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 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 DFGFixupPhase_h
+#define DFGFixupPhase_h
+
+#include <wtf/Platform.h>
+
+#if ENABLE(DFG_JIT)
+
+namespace JSC { namespace DFG {
+
+class Graph;
+
+// Fix portions of the graph that are inefficient given the predictions that
+// we have. This should run after prediction propagation but before CSE.
+
+void performFixup(Graph&);
+
+} } // namespace JSC::DFG::Phase
+
+#endif // ENABLE(DFG_JIT)
+
+#endif // DFGFixupPhase_h
Modified: trunk/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp (111973 => 111974)
--- trunk/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp 2012-03-24 03:11:45 UTC (rev 111973)
+++ trunk/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp 2012-03-24 03:23:02 UTC (rev 111974)
@@ -75,8 +75,6 @@
doRoundOfDoubleVoting();
propagateBackward();
} while (m_changed);
-
- fixup();
}
private:
@@ -773,109 +771,6 @@
}
}
- void fixupNode(Node& node)
- {
- if (!node.shouldGenerate())
- return;
-
- NodeType op = node.op();
-
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
- dataLog(" %s @%u: ", Graph::opName(op), m_compileIndex);
-#endif
-
- switch (op) {
- case GetById: {
- if (!isInt32Prediction(m_graph[m_compileIndex].prediction()))
- break;
- if (codeBlock()->identifier(node.identifierNumber()) != globalData().propertyNames->length)
- break;
- bool isArray = isArrayPrediction(m_graph[node.child1()].prediction());
- bool isString = isStringPrediction(m_graph[node.child1()].prediction());
- bool isByteArray = m_graph[node.child1()].shouldSpeculateByteArray();
- bool isInt8Array = m_graph[node.child1()].shouldSpeculateInt8Array();
- bool isInt16Array = m_graph[node.child1()].shouldSpeculateInt16Array();
- bool isInt32Array = m_graph[node.child1()].shouldSpeculateInt32Array();
- bool isUint8Array = m_graph[node.child1()].shouldSpeculateUint8Array();
- bool isUint8ClampedArray = m_graph[node.child1()].shouldSpeculateUint8ClampedArray();
- bool isUint16Array = m_graph[node.child1()].shouldSpeculateUint16Array();
- bool isUint32Array = m_graph[node.child1()].shouldSpeculateUint32Array();
- bool isFloat32Array = m_graph[node.child1()].shouldSpeculateFloat32Array();
- bool isFloat64Array = m_graph[node.child1()].shouldSpeculateFloat64Array();
- if (!isArray && !isString && !isByteArray && !isInt8Array && !isInt16Array && !isInt32Array && !isUint8Array && !isUint8ClampedArray && !isUint16Array && !isUint32Array && !isFloat32Array && !isFloat64Array)
- break;
-
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
- dataLog(" @%u -> %s", m_compileIndex, isArray ? "GetArrayLength" : "GetStringLength");
-#endif
- if (isArray)
- node.setOp(GetArrayLength);
- else if (isString)
- node.setOp(GetStringLength);
- else if (isByteArray)
- node.setOp(GetByteArrayLength);
- else if (isInt8Array)
- node.setOp(GetInt8ArrayLength);
- else if (isInt16Array)
- node.setOp(GetInt16ArrayLength);
- else if (isInt32Array)
- node.setOp(GetInt32ArrayLength);
- else if (isUint8Array)
- node.setOp(GetUint8ArrayLength);
- else if (isUint8ClampedArray)
- node.setOp(GetUint8ClampedArrayLength);
- else if (isUint16Array)
- node.setOp(GetUint16ArrayLength);
- else if (isUint32Array)
- node.setOp(GetUint32ArrayLength);
- else if (isFloat32Array)
- node.setOp(GetFloat32ArrayLength);
- else if (isFloat64Array)
- node.setOp(GetFloat64ArrayLength);
- else
- ASSERT_NOT_REACHED();
- // No longer MustGenerate
- ASSERT(node.flags() & NodeMustGenerate);
- node.clearFlags(NodeMustGenerate);
- m_graph.deref(m_compileIndex);
- break;
- }
- case GetIndexedPropertyStorage: {
- PredictedType basePrediction = m_graph[node.child2()].prediction();
- if (!(basePrediction & PredictInt32) && basePrediction) {
- node.setOpAndDefaultFlags(Nop);
- m_graph.clearAndDerefChild1(node);
- m_graph.clearAndDerefChild2(node);
- m_graph.clearAndDerefChild3(node);
- node.setRefCount(0);
- }
- break;
- }
- case GetByVal:
- case StringCharAt:
- case StringCharCodeAt: {
- if (!!node.child3() && m_graph[node.child3()].op() == Nop)
- node.children.child3() = Edge();
- break;
- }
- default:
- break;
- }
-
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
- dataLog("\n");
-#endif
- }
-
- void fixup()
- {
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
- dataLog("Performing Fixup\n");
-#endif
- for (m_compileIndex = 0; m_compileIndex < m_graph.size(); ++m_compileIndex)
- fixupNode(m_graph[m_compileIndex]);
- }
-
NodeIndex m_compileIndex;
bool m_changed;