2008-05-21 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2008 02:03:39 +0000 (02:03 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2008 02:03:39 +0000 (02:03 +0000)
        Reviewed by Darin.

        - save a hash lookup wne writing to global properties
        0.3% speedup on SunSpider, 7% on bitops-bitwise-and

        * VM/Machine.cpp:
        (KJS::resolveBase): Check for being a the end of the scope chain
        before hash lookup.

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

JavaScriptCore/ChangeLog
JavaScriptCore/VM/Machine.cpp

index 028a30d..7223f32 100644 (file)
@@ -1,3 +1,14 @@
+2008-05-21  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - save a hash lookup wne writing to global properties
+        0.3% speedup on SunSpider, 7% on bitops-bitwise-and
+
+        * VM/Machine.cpp:
+        (KJS::resolveBase): Check for being a the end of the scope chain
+        before hash lookup.
+
 2008-05-21  Alp Toker  <alp@nuanti.com>
 
         Rubber-stamped by Maciej.
index 87bcfec..068d364 100644 (file)
@@ -259,21 +259,23 @@ static void NEVER_INLINE resolveBase(ExecState* exec, Instruction* vPC, Register
     int property = (vPC + 2)->u.operand;
 
     ScopeChainIterator iter = scopeChain->begin();
+    ScopeChainIterator next = iter;
+    ++next;
     ScopeChainIterator end = scopeChain->end();
     ASSERT(iter != end);
 
     PropertySlot slot;
     Identifier& ident = codeBlock->identifiers[property];
     JSObject* base;
-    do {
+    while (true) {
         base = *iter;
-        if (base->getPropertySlot(exec, ident, slot)) {
+        if (next == end || base->getPropertySlot(exec, ident, slot)) {
             r[dst].u.jsValue = base;
             return;
         }
-    } while (++iter != end);
-
-    r[dst].u.jsValue = base;
+        iter = next;
+        ++next;
+    }
 }
 
 static bool NEVER_INLINE resolveBaseAndProperty(ExecState* exec, Instruction* vPC, Register* r, ScopeChainNode* scopeChain, CodeBlock* codeBlock, JSValue*& exceptionValue)