2008-06-14 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Jun 2008 22:13:18 +0000 (22:13 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Jun 2008 22:13:18 +0000 (22:13 +0000)
        Reviewed by Oliver.

        - initialize local vars as side effect of call instead of in bytecode
        1.004x speedup on SunSpider.

        This removes just the dispatch overhead for these loads - in the
        future, dead store elimination might be able to eliminate them
        entirely.

        * VM/CodeGenerator.cpp:
        (KJS::CodeGenerator::CodeGenerator): For function blocks, don't
        emit loads of undefined for var initialization.
        * VM/Machine.cpp:
        (KJS::slideRegisterWindowForCall): Instead, initialize locals
        as part of the call.

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

JavaScriptCore/ChangeLog
JavaScriptCore/VM/CodeGenerator.cpp
JavaScriptCore/VM/Machine.cpp

index 6138933d48a4c95704ea80fd6534090d856775b4..e6475ba903a52b35735c41a7e618a4d0da9f823e 100644 (file)
@@ -1,3 +1,21 @@
+2008-06-14  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver.
+        
+        - initialize local vars as side effect of call instead of in bytecode
+        1.004x speedup on SunSpider.
+
+        This removes just the dispatch overhead for these loads - in the
+        future, dead store elimination might be able to eliminate them
+        entirely.
+        
+        * VM/CodeGenerator.cpp:
+        (KJS::CodeGenerator::CodeGenerator): For function blocks, don't
+        emit loads of undefined for var initialization.
+        * VM/Machine.cpp:
+        (KJS::slideRegisterWindowForCall): Instead, initialize locals
+        as part of the call.
+
 2008-06-14  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
 
         Reviewed by Oliver.
 2008-06-14  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
 
         Reviewed by Oliver.
index 47ce839055600c553bce2678e95fce9d2f91ca6e..b560ce7e6cc92dc839770a7879c9b3712c9c91c6 100644 (file)
@@ -257,8 +257,7 @@ CodeGenerator::CodeGenerator(FunctionBodyNode* functionBody, const Debugger* deb
             continue;
 
         RegisterID* r0;
             continue;
 
         RegisterID* r0;
-        if (addVar(ident, r0, varStack[i].second & DeclarationStacks::IsConstant))
-            emitLoad(r0, jsUndefined());
+        addVar(ident, r0, varStack[i].second & DeclarationStacks::IsConstant);
     }
 
     Vector<Identifier>& parameters = functionBody->parameters();
     }
 
     Vector<Identifier>& parameters = functionBody->parameters();
index f9e94b07922e9c641f84ab930ffd5617aac9f24a..4e0bc1400fe573a31d68e2023f084a10fbc1b4e8 100644 (file)
@@ -404,6 +404,10 @@ ALWAYS_INLINE Register* slideRegisterWindowForCall(ExecState* exec, CodeBlock* n
         for ( ; it != end; ++it)
             *(it + shift) = *it;
     }
         for ( ; it != end; ++it)
             *(it + shift) = *it;
     }
+    
+    // initialize local variable slots
+    for (Register* it = r - newCodeBlock->numVars; it != r; ++it)
+        (*it).u.jsValue = jsUndefined();
 
     return r;
 }
 
     return r;
 }