Bug 19116: SquirrelFish shouldn't regress on variable lookups
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2008 19:36:52 +0000 (19:36 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2008 19:36:52 +0000 (19:36 +0000)
<https://bugs.webkit.org/show_bug.cgi?id=19116>

Reviewed by Darin.

Last of the multiscope look up optimisations.  This is a wash overall on SunSpider
but is a factor of 5-10 improvement in multiscope read/write/modify (eg. ++, --, +=,
... applied to any non-local var).

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

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/nodes.cpp

index 0bf09e4..45916da 100644 (file)
@@ -1,3 +1,21 @@
+2008-05-22  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Darin.
+
+        Bug 19116: SquirrelFish shouldn't regress on variable lookups
+        <https://bugs.webkit.org/show_bug.cgi?id=19116>
+
+        Last of the multiscope look up optimisations.  This is a wash overall on SunSpider
+        but is a factor of 5-10 improvement in multiscope read/write/modify (eg. ++, --, +=,
+        ... applied to any non-local var).
+
+        * kjs/nodes.cpp:
+        (KJS::PostIncResolveNode::emitCode):
+        (KJS::PostDecResolveNode::emitCode):
+        (KJS::PreIncResolveNode::emitCode):
+        (KJS::PreDecResolveNode::emitCode):
+        (KJS::ReadModifyResolveNode::emitCode):
+
 2008-05-22  David Kilzer  <ddkilzer@apple.com>
 
         <rdar://problem/5954233> Add method to release free memory from FastMalloc
index d4eb401..5a6e9d9 100644 (file)
@@ -1742,6 +1742,15 @@ RegisterID* PostIncResolveNode::emitCode(CodeGenerator& generator, RegisterID* d
         return generator.emitPostInc(generator.finalDestination(dst), local);
     }
 
+    int index = 0;
+    size_t depth = 0;
+    if (generator.findScopedProperty(m_ident, index, depth) && index != missingSymbolMarker()) {
+        RefPtr<RegisterID> value = generator.emitGetScopedVar(generator.newTemporary(), depth, index);
+        RegisterID* oldValue = generator.emitPostInc(generator.finalDestination(dst), value.get());
+        generator.emitPutScopedVar(depth, index, value.get());
+        return oldValue;
+    }
+
     RefPtr<RegisterID> value = generator.newTemporary();
     RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), value.get(), m_ident);
     RegisterID* oldValue = generator.emitPostInc(generator.finalDestination(dst), value.get());
@@ -1826,6 +1835,15 @@ RegisterID* PostDecResolveNode::emitCode(CodeGenerator& generator, RegisterID* d
         return generator.emitPostDec(generator.finalDestination(dst), local);
     }
 
+    int index = 0;
+    size_t depth = 0;
+    if (generator.findScopedProperty(m_ident, index, depth) && index != missingSymbolMarker()) {
+        RefPtr<RegisterID> value = generator.emitGetScopedVar(generator.newTemporary(), depth, index);
+        RegisterID* oldValue = generator.emitPostDec(generator.finalDestination(dst), value.get());
+        generator.emitPutScopedVar(depth, index, value.get());
+        return oldValue;
+    }
+
     RefPtr<RegisterID> value = generator.newTemporary();
     RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), value.get(), m_ident);
     RegisterID* oldValue = generator.emitPostDec(generator.finalDestination(dst), value.get());
@@ -2349,7 +2367,16 @@ RegisterID* PreIncResolveNode::emitCode(CodeGenerator& generator, RegisterID* ds
         generator.emitPreInc(local);
         return generator.moveToDestinationIfNeeded(dst, local);
     }
-    
+
+    int index = 0;
+    size_t depth = 0;
+    if (generator.findScopedProperty(m_ident, index, depth) && index != missingSymbolMarker()) {
+        RefPtr<RegisterID> propDst = generator.emitGetScopedVar(generator.tempDestination(dst), depth, index);
+        generator.emitPreInc(propDst.get());
+        generator.emitPutScopedVar(depth, index, propDst.get());
+        return generator.moveToDestinationIfNeeded(dst, propDst.get());;
+    }
+
     RefPtr<RegisterID> propDst = generator.tempDestination(dst);
     RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), propDst.get(), m_ident);
     generator.emitPreInc(propDst.get());
@@ -2421,6 +2448,15 @@ RegisterID* PreDecResolveNode::emitCode(CodeGenerator& generator, RegisterID* ds
         return generator.moveToDestinationIfNeeded(dst, local);
     }
 
+    int index = 0;
+    size_t depth = 0;
+    if (generator.findScopedProperty(m_ident, index, depth) && index != missingSymbolMarker()) {
+        RefPtr<RegisterID> propDst = generator.emitGetScopedVar(generator.tempDestination(dst), depth, index);
+        generator.emitPreDec(propDst.get());
+        generator.emitPutScopedVar(depth, index, propDst.get());
+        return generator.moveToDestinationIfNeeded(dst, propDst.get());;
+    }
+
     RefPtr<RegisterID> propDst = generator.tempDestination(dst);
     RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), propDst.get(), m_ident);
     generator.emitPreDec(propDst.get());
@@ -4183,6 +4219,16 @@ RegisterID* ReadModifyResolveNode::emitCode(CodeGenerator& generator, RegisterID
         return generator.moveToDestinationIfNeeded(dst, result);
     }
 
+    int index = 0;
+    size_t depth = 0;
+    if (generator.findScopedProperty(m_ident, index, depth) && index != missingSymbolMarker()) {
+        RefPtr<RegisterID> src1 = generator.emitGetScopedVar(generator.tempDestination(dst), depth, index);
+        RegisterID* src2 = generator.emitNode(m_right.get());
+        RegisterID* result = emitReadModifyAssignment(generator, generator.finalDestination(dst, src1.get()), src1.get(), src2, m_operator);
+        generator.emitPutScopedVar(depth, index, result);
+        return result;
+    }
+
     RefPtr<RegisterID> src1 = generator.tempDestination(dst);
     RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), src1.get(), m_ident);
     RegisterID* src2 = generator.emitNode(m_right.get());