summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-24 13:09:44 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-24 13:09:44 +0200
commitdc6262b587c71c14e30d93e57ed812e36a79a33e (patch)
tree03ff986e7aa38bba0c0ef374f44fda52aff93f01 /Source/JavaScriptCore/dfg/DFGCSEPhase.cpp
parent02e1fbbefd49229b102ef107bd70ce974a2d85fb (diff)
downloadqtwebkit-dc6262b587c71c14e30d93e57ed812e36a79a33e.tar.gz
Imported WebKit commit 6339232fec7f5d9984a33388aecfd2cbc7832053 (http://svn.webkit.org/repository/webkit/trunk@129343)
New snapshot with build fixes for latest qtbase
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGCSEPhase.cpp')
-rw-r--r--Source/JavaScriptCore/dfg/DFGCSEPhase.cpp165
1 files changed, 130 insertions, 35 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp b/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp
index 111c15f17..cea2f3c48 100644
--- a/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp
+++ b/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp
@@ -96,6 +96,9 @@ private:
break;
Node& otherNode = m_graph[index];
+ if (!otherNode.shouldGenerate())
+ continue;
+
if (node.op() != otherNode.op())
continue;
@@ -157,38 +160,34 @@ private:
return NoNode;
}
- NodeIndex impureCSE(Node& node)
+ NodeIndex getArrayLengthElimination(NodeIndex array)
{
- NodeIndex child1 = canonicalize(node.child1());
- NodeIndex child2 = canonicalize(node.child2());
- NodeIndex child3 = canonicalize(node.child3());
-
for (unsigned i = m_indexInBlock; i--;) {
NodeIndex index = m_currentBlock->at(i);
- if (index == child1 || index == child2 || index == child3)
- break;
-
- Node& otherNode = m_graph[index];
- if (node.op() == otherNode.op()
- && node.arithNodeFlags() == otherNode.arithNodeFlags()) {
- NodeIndex otherChild = canonicalize(otherNode.child1());
- if (otherChild == NoNode)
+ Node& node = m_graph[index];
+ if (!node.shouldGenerate())
+ continue;
+ switch (node.op()) {
+ case GetArrayLength:
+ if (node.child1() == array)
return index;
- if (otherChild == child1) {
- otherChild = canonicalize(otherNode.child2());
- if (otherChild == NoNode)
- return index;
- if (otherChild == child2) {
- otherChild = canonicalize(otherNode.child3());
- if (otherChild == NoNode)
- return index;
- if (otherChild == child3)
- return index;
- }
+ break;
+
+ case PutByVal:
+ if (!m_graph.byValIsPure(node))
+ return NoNode;
+ switch (node.arrayMode()) {
+ case ARRAY_STORAGE_TO_HOLE_MODES:
+ return NoNode;
+ default:
+ break;
}
- }
- if (m_graph.clobbersWorld(index))
break;
+
+ default:
+ if (m_graph.clobbersWorld(index))
+ return NoNode;
+ }
}
return NoNode;
}
@@ -216,6 +215,34 @@ private:
return NoNode;
}
+ NodeIndex scopedVarLoadElimination(unsigned scopeChainDepth, unsigned varNumber)
+ {
+ for (unsigned i = m_indexInBlock; i--;) {
+ NodeIndex index = m_currentBlock->at(i);
+ Node& node = m_graph[index];
+ switch (node.op()) {
+ case GetScopedVar: {
+ Node& getScopeRegisters = m_graph[node.child1()];
+ Node& getScope = m_graph[getScopeRegisters.child1()];
+ if (getScope.scopeChainDepth() == scopeChainDepth && node.varNumber() == varNumber)
+ return index;
+ break;
+ }
+ case PutScopedVar: {
+ Node& getScope = m_graph[node.child1()];
+ if (getScope.scopeChainDepth() == scopeChainDepth && node.varNumber() == varNumber)
+ return node.child3().index();
+ break;
+ }
+ default:
+ break;
+ }
+ if (m_graph.clobbersWorld(index))
+ break;
+ }
+ return NoNode;
+ }
+
bool globalVarWatchpointElimination(WriteBarrier<Unknown>* registerPointer)
{
for (unsigned i = m_indexInBlock; i--;) {
@@ -267,6 +294,38 @@ private:
return NoNode;
}
+ NodeIndex scopedVarStoreElimination(unsigned scopeChainDepth, unsigned varNumber)
+ {
+ for (unsigned i = m_indexInBlock; i--;) {
+ NodeIndex index = m_currentBlock->at(i);
+ Node& node = m_graph[index];
+ if (!node.shouldGenerate())
+ continue;
+ switch (node.op()) {
+ case PutScopedVar: {
+ Node& getScope = m_graph[node.child1()];
+ if (getScope.scopeChainDepth() == scopeChainDepth && node.varNumber() == varNumber)
+ return index;
+ break;
+ }
+
+ case GetScopedVar: {
+ Node& getScopeRegisters = m_graph[node.child1()];
+ Node& getScope = m_graph[getScopeRegisters.child1()];
+ if (getScope.scopeChainDepth() == scopeChainDepth && node.varNumber() == varNumber)
+ return NoNode;
+ break;
+ }
+
+ default:
+ break;
+ }
+ if (m_graph.clobbersWorld(index) || node.canExit())
+ return NoNode;
+ }
+ return NoNode;
+ }
+
NodeIndex getByValLoadElimination(NodeIndex child1, NodeIndex child2)
{
for (unsigned i = m_indexInBlock; i--;) {
@@ -437,7 +496,7 @@ private:
break;
Node& node = m_graph[index];
if (!node.shouldGenerate())
- break;
+ continue;
switch (node.op()) {
case CheckStructure:
case ForwardCheckStructure:
@@ -690,19 +749,35 @@ private:
return NoNode;
}
- NodeIndex getScopeChainLoadElimination(unsigned depth)
+ NodeIndex getScopeLoadElimination(unsigned depth)
{
for (unsigned i = endIndexForPureCSE(); i--;) {
NodeIndex index = m_currentBlock->at(i);
Node& node = m_graph[index];
if (!node.shouldGenerate())
continue;
- if (node.op() == GetScopeChain
+ if (node.op() == GetScope
&& node.scopeChainDepth() == depth)
return index;
}
return NoNode;
}
+
+ NodeIndex getScopeRegistersLoadElimination(unsigned depth)
+ {
+ for (unsigned i = endIndexForPureCSE(); i--;) {
+ NodeIndex index = m_currentBlock->at(i);
+ Node& node = m_graph[index];
+ if (!node.shouldGenerate())
+ continue;
+ if (node.op() == GetScopeRegisters
+ && m_graph[node.scope()].scopeChainDepth() == depth)
+ return index;
+ }
+ return NoNode;
+ }
+
+
NodeIndex getLocalLoadElimination(VirtualRegister local, NodeIndex& relevantLocalOp, bool careAboutClobbering)
{
@@ -787,7 +862,8 @@ private:
return result;
}
- case GetScopeChain:
+ case GetScope:
+ case GetScopeRegisters:
if (m_graph.uncheckedActivationRegisterFor(node.codeOrigin) == local)
result.mayBeAccessed = true;
break;
@@ -1078,11 +1154,15 @@ private:
break;
case GetArrayLength:
- setReplacement(impureCSE(node));
+ setReplacement(getArrayLengthElimination(node.child1().index()));
break;
-
- case GetScopeChain:
- setReplacement(getScopeChainLoadElimination(node.scopeChainDepth()));
+
+ case GetScope:
+ setReplacement(getScopeLoadElimination(node.scopeChainDepth()));
+ break;
+
+ case GetScopeRegisters:
+ setReplacement(getScopeRegistersLoadElimination(m_graph[node.scope()].scopeChainDepth()));
break;
// Handle nodes that are conditionally pure: these are pure, and can
@@ -1106,7 +1186,14 @@ private:
case GetGlobalVar:
setReplacement(globalVarLoadElimination(node.registerPointer()));
break;
-
+
+ case GetScopedVar: {
+ Node& getScopeRegisters = m_graph[node.child1()];
+ Node& getScope = m_graph[getScopeRegisters.child1()];
+ setReplacement(scopedVarLoadElimination(getScope.scopeChainDepth(), node.varNumber()));
+ break;
+ }
+
case GlobalVarWatchpoint:
if (globalVarWatchpointElimination(node.registerPointer()))
eliminate();
@@ -1119,6 +1206,14 @@ private:
eliminate(globalVarStoreElimination(node.registerPointer()));
break;
+ case PutScopedVar: {
+ if (m_graph.m_fixpointState == FixpointNotConverged)
+ break;
+ Node& getScope = m_graph[node.child1()];
+ eliminate(scopedVarStoreElimination(getScope.scopeChainDepth(), node.varNumber()));
+ break;
+ }
+
case GetByVal:
if (m_graph.byValIsPure(node))
setReplacement(getByValLoadElimination(node.child1().index(), node.child2().index()));