2008-06-12 Cameron Zwarich <cwzwarich@uwaterloo.ca>
authorcwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jun 2008 09:03:41 +0000 (09:03 +0000)
committercwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jun 2008 09:03:41 +0000 (09:03 +0000)
        Reviewed by Maciej.

        Bug 19510: CodeBlock::needsFullScopeChain not always set for global code
        <https://bugs.webkit.org/show_bug.cgi?id=19510>

        This fixes the symptoms by using CodeGenerator::m_codeType to determine
        when to use temporaries instead of CodeBlock::needsFullScopeChain, but
        it does not fix the problem itself.

        JavaScriptCore:

        * VM/CodeGenerator.h:
        (KJS::CodeGenerator::leftHandSideNeedsCopy):

        LayoutTests:

        * fast/js/codegen-temporaries-multiple-global-blocks-expected.txt: Added.
        * fast/js/codegen-temporaries-multiple-global-blocks.html: Added.
        * fast/js/resources/codegen-temporaries-multiple-global-blocks-1.js: Added.
        * fast/js/resources/codegen-temporaries-multiple-global-blocks-2.js: Added.

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

JavaScriptCore/ChangeLog
JavaScriptCore/VM/CodeGenerator.h
LayoutTests/ChangeLog
LayoutTests/fast/js/codegen-temporaries-multiple-global-blocks-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/codegen-temporaries-multiple-global-blocks.html [new file with mode: 0644]
LayoutTests/fast/js/resources/codegen-temporaries-multiple-global-blocks-1.js [new file with mode: 0644]
LayoutTests/fast/js/resources/codegen-temporaries-multiple-global-blocks-2.js [new file with mode: 0644]

index 6b4fb012a21544b2a83752e505a988f5ca20eb7a..b28b76a2d51d552cbed23cb469e0473c83ede98e 100644 (file)
@@ -1,3 +1,17 @@
+2008-06-12  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Maciej.
+
+        Bug 19510: CodeBlock::needsFullScopeChain not always set for global code
+        <https://bugs.webkit.org/show_bug.cgi?id=19510>
+
+        This fixes the symptoms by using CodeGenerator::m_codeType to determine
+        when to use temporaries instead of CodeBlock::needsFullScopeChain, but
+        it does not fix the problem itself.
+
+        * VM/CodeGenerator.h:
+        (KJS::CodeGenerator::leftHandSideNeedsCopy):
+
 2008-06-11  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
 
         Reviewed by Maciej.
index 6c38ae138dfc8fd30a868093eb1f8f9359d1e442..2b2d83e9480b467e344fda8c4f37ce2fb261bdc5 100644 (file)
@@ -173,7 +173,7 @@ namespace KJS {
 
         ALWAYS_INLINE bool leftHandSideNeedsCopy(bool rightHasAssignments)
         {
-            return m_codeBlock->needsFullScopeChain || rightHasAssignments;
+            return m_codeType != FunctionCode || m_codeBlock->needsFullScopeChain || rightHasAssignments;
         }
 
         ALWAYS_INLINE PassRefPtr<RegisterID> emitNodeForLeftHandSide(ExpressionNode* n, bool rightHasAssignments)
index 62358e4d9c1830f8cec8188e7aad0eed9ea8429d..1c13e092fc9f6e6a4a508bd8b7e3c86c7c7142fb 100644 (file)
@@ -1,3 +1,17 @@
+2008-06-12  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Maciej.
+
+        Tests for:
+
+        Bug 19510: CodeBlock::needsFullScopeChain not always set for global code
+        <https://bugs.webkit.org/show_bug.cgi?id=19510>
+
+        * fast/js/codegen-temporaries-multiple-global-blocks-expected.txt: Added.
+        * fast/js/codegen-temporaries-multiple-global-blocks.html: Added.
+        * fast/js/resources/codegen-temporaries-multiple-global-blocks-1.js: Added.
+        * fast/js/resources/codegen-temporaries-multiple-global-blocks-2.js: Added.
+
 2008-06-12  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/fast/js/codegen-temporaries-multiple-global-blocks-expected.txt b/LayoutTests/fast/js/codegen-temporaries-multiple-global-blocks-expected.txt
new file mode 100644 (file)
index 0000000..ff94254
--- /dev/null
@@ -0,0 +1,17 @@
+Tests whether bytecode codegen properly handles temporaries across multiple global blocks.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS v1 is 2
+PASS o2.a is 2
+PASS o3.a is 2
+PASS r4 is 1
+PASS o5.a is 2
+PASS o6.a is 2
+PASS o7.a is 2
+PASS o8.a is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/codegen-temporaries-multiple-global-blocks.html b/LayoutTests/fast/js/codegen-temporaries-multiple-global-blocks.html
new file mode 100644 (file)
index 0000000..abf3e77
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/codegen-temporaries-multiple-global-blocks-1.js"></script>
+<script src="resources/codegen-temporaries-multiple-global-blocks-2.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/resources/codegen-temporaries-multiple-global-blocks-1.js b/LayoutTests/fast/js/resources/codegen-temporaries-multiple-global-blocks-1.js
new file mode 100644 (file)
index 0000000..2871af3
--- /dev/null
@@ -0,0 +1,47 @@
+function assign1()
+{
+    v1 = 0;
+    return 1;
+}
+
+function assign2()
+{
+    v2 = { a: 0 };
+    return 2;
+}
+
+function assign3()
+{
+    v3 = { a: 0 };
+    return 1;
+}
+
+function assign4()
+{
+    v4 = { a: 0 };
+    return "a";
+}
+
+function assign5()
+{
+    v5 = { a: 0 };
+    return "a";
+}
+
+function assign6()
+{
+    v6 = { a: 0 };
+    return 2;
+}
+
+function assign7()
+{
+    v7 = { a: 0 };
+    return "a";
+}
+
+function assign8()
+{
+    v8 = { a: 0 };
+    return 1;
+}
diff --git a/LayoutTests/fast/js/resources/codegen-temporaries-multiple-global-blocks-2.js b/LayoutTests/fast/js/resources/codegen-temporaries-multiple-global-blocks-2.js
new file mode 100644 (file)
index 0000000..bc92860
--- /dev/null
@@ -0,0 +1,43 @@
+description(
+'Tests whether bytecode codegen properly handles temporaries across multiple global blocks.'
+);
+
+var v1 = 1;
+v1 += assign1();
+shouldBe("v1", "2");
+
+var o2 = { a: 1 };
+var v2 = o2;
+v2.a = assign2();
+shouldBe("o2.a", "2");
+
+var o3 = { a: 1 };
+var v3 = o3;
+v3.a += assign3();
+shouldBe("o3.a", "2");
+
+var v4 = { a: 1 };
+var r4 = v4[assign4()];
+shouldBe("r4", "1");
+
+var o5 = { a: 1 };
+var v5 = o5;
+v5[assign5()] = 2;
+shouldBe("o5.a", "2");
+
+var o6 = { a: 1 };
+var v6 = o6;
+v6["a"] = assign6();
+shouldBe("o6.a", "2");
+
+var o7 = { a: 1 };
+var v7 = o7;
+v7[assign7()] += 1;
+shouldBe("o7.a", "2");
+
+var o8 = { a: 1 };
+var v8 = o8;
+v8["a"] += assign8();
+shouldBe("o8.a", "2");
+
+var successfullyParsed = true;