Fix codegen for assignment being used as a function.
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 May 2008 04:15:45 +0000 (04:15 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 May 2008 04:15:45 +0000 (04:15 +0000)
Reviewed by Anders.

FunctionCallValueNode::emitCode failed to account for the
potential of the function expression to allocate arbitrary
registers.

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

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/nodes.cpp
LayoutTests/ChangeLog
LayoutTests/fast/js/codegen-temporaries-expected.txt
LayoutTests/fast/js/resources/codegen-temporaries.js

index f12d0fd..2a626af 100644 (file)
@@ -1,3 +1,16 @@
+2008-05-28  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Anders.
+
+        Fix codegen for assignment being used as a function.
+
+        FunctionCallValueNode::emitCode failed to account for the
+        potential of the function expression to allocate arbitrary
+        registers.
+
+        * kjs/nodes.cpp:
+        (KJS::FunctionCallValueNode::emitCode):
+
 2008-05-27  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Tim Hatcher.
index ce9d783..6d7b305 100644 (file)
@@ -1309,8 +1309,8 @@ JSValue* EvalFunctionCallNode::evaluate(OldInterpreterExecState* exec)
 
 RegisterID* FunctionCallValueNode::emitCode(CodeGenerator& generator, RegisterID* dst)
 {
-    RegisterID* r0 = generator.emitNode(m_expr.get());
-    return generator.emitCall(generator.finalDestination(dst), r0, 0, m_args.get());
+    RefPtr<RegisterID> func = generator.emitNode(m_expr.get());
+    return generator.emitCall(generator.finalDestination(dst), func.get(), 0, m_args.get());
 }
 
 void FunctionCallValueNode::optimizeVariableAccess(OldInterpreterExecState*, const SymbolTable&, const LocalStorage&, NodeStack& nodeStack)
index fdbd95f..c30722d 100644 (file)
@@ -1,3 +1,12 @@
+2008-05-28  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Anders.
+
+        Adding a test case for assignment result used as a function.
+
+        * fast/js/codegen-temporaries-expected.txt:
+        * fast/js/resources/codegen-temporaries.js:
+
 2008-05-28  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Oliver.
index 89d8b43..6195cb8 100644 (file)
@@ -35,6 +35,7 @@ PASS assign_test27() is 3
 PASS assign_test28() is 3
 PASS assign_test29() is 3
 PASS assign_test30() is 'fooNaN'
+PASS assign_test31() is 'PASS'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 61f4dd3..7a7a143 100644 (file)
@@ -288,4 +288,12 @@ function assign_test30()
 
 shouldBe("assign_test30()", "'fooNaN'");
 
+function assign_test31()
+{
+    function result() { return "PASS"; }
+    return (globalVar = result)()
+}
+
+shouldBe("assign_test31()", "'PASS'");
+
 successfullyParsed = true;