Title: [119575] trunk
Revision
119575
Author
wi...@igalia.com
Date
2012-06-06 02:39:04 -0700 (Wed, 06 Jun 2012)

Log Message

REGRESSION (r106478): None of the Paper.js _javascript_ examples work
https://bugs.webkit.org/show_bug.cgi?id=87158

Source/_javascript_Core:

Reviewed by Michael Saboff.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::resolve): If we have to bail out to
dynamicResolve(), only skip static scopes from the head of the
scope chain.  Before, we were also skipping activations with
direct eval as well, which was incorrect.

LayoutTests:

Added regression tests for functions inside eval inside a with.

Reviewed by Michael Saboff.

* fast/js/eval-and-with-expected.txt: Added.
* fast/js/eval-and-with.html: Added.
* fast/js/script-tests/eval-and-with.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119574 => 119575)


--- trunk/LayoutTests/ChangeLog	2012-06-06 09:34:37 UTC (rev 119574)
+++ trunk/LayoutTests/ChangeLog	2012-06-06 09:39:04 UTC (rev 119575)
@@ -1,3 +1,16 @@
+2012-06-06  Andy Wingo  <wi...@igalia.com>
+
+        REGRESSION (r106478): None of the Paper.js _javascript_ examples work
+        https://bugs.webkit.org/show_bug.cgi?id=87158
+
+        Added regression tests for functions inside eval inside a with.
+
+        Reviewed by Michael Saboff.
+
+        * fast/js/eval-and-with-expected.txt: Added.
+        * fast/js/eval-and-with.html: Added.
+        * fast/js/script-tests/eval-and-with.js: Added.
+
 2012-06-06  Zoltan Arvai  <zar...@inf.u-szeged.hu>
 
         [Qt][WK2] Unreviewed gardening. Skip modified falining test. Rebase a test.

Added: trunk/LayoutTests/fast/js/eval-and-with-expected.txt (0 => 119575)


--- trunk/LayoutTests/fast/js/eval-and-with-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/js/eval-and-with-expected.txt	2012-06-06 09:39:04 UTC (rev 119575)
@@ -0,0 +1,18 @@
+This test case checks variable resolution in the presence of both eval and with.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS freeVarInsideEvalAndWith({}, "true")() is true
+PASS freeVarInsideEvalAndWith({}, "false")() is false
+PASS freeVarInsideEvalAndWith({}, "var x = 10; x")() == 10 is true
+PASS freeVarInsideEvalAndWith({}, "var x = 10; (function (){return x;})")()() == 10 is true
+PASS localVarInsideEvalAndWith({}, "true") is true
+PASS localVarInsideEvalAndWith({}, "false") is false
+PASS localVarInsideEvalAndWith({}, "var x = true; x") is true
+PASS localVarInsideEvalAndWith({}, "var x = 10; (function (){return x;})")() == 10 is true
+PASS localVarInsideEvalAndWith(y={x:false}, "var x = true; x && y.x") is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/js/eval-and-with.html (0 => 119575)


--- trunk/LayoutTests/fast/js/eval-and-with.html	                        (rev 0)
+++ trunk/LayoutTests/fast/js/eval-and-with.html	2012-06-06 09:39:04 UTC (rev 119575)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/js/script-tests/eval-and-with.js (0 => 119575)


--- trunk/LayoutTests/fast/js/script-tests/eval-and-with.js	                        (rev 0)
+++ trunk/LayoutTests/fast/js/script-tests/eval-and-with.js	2012-06-06 09:39:04 UTC (rev 119575)
@@ -0,0 +1,34 @@
+description(
+"This test case checks variable resolution in the presence of both eval and with."
+);
+
+// Direct non-strict eval inside a with.
+
+function freeVarInsideEvalAndWith(o, str)
+{
+    with (o)
+    {
+        return function () { return eval(str); }
+    }
+}
+
+shouldBeTrue('freeVarInsideEvalAndWith({}, "true")()')
+shouldBeFalse('freeVarInsideEvalAndWith({}, "false")()')
+shouldBeTrue('freeVarInsideEvalAndWith({}, "var x = 10; x")() == 10')
+shouldBeTrue('freeVarInsideEvalAndWith({}, "var x = 10; (function (){return x;})")()() == 10')
+
+function localVarInsideEvalAndWith(o, str)
+{
+    with (o)
+    {
+        return eval(str);
+    }
+}
+
+shouldBeTrue('localVarInsideEvalAndWith({}, "true")')
+shouldBeFalse('localVarInsideEvalAndWith({}, "false")')
+shouldBeTrue('localVarInsideEvalAndWith({}, "var x = true; x")')
+shouldBeTrue('localVarInsideEvalAndWith({}, "var x = 10; (function (){return x;})")() == 10')
+
+var y;
+shouldBeTrue('localVarInsideEvalAndWith(y={x:false}, "var x = true; x && y.x")')

Modified: trunk/Source/_javascript_Core/ChangeLog (119574 => 119575)


--- trunk/Source/_javascript_Core/ChangeLog	2012-06-06 09:34:37 UTC (rev 119574)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-06-06 09:39:04 UTC (rev 119575)
@@ -1,3 +1,16 @@
+2012-06-06  Andy Wingo  <wi...@igalia.com>
+
+        REGRESSION (r106478): None of the Paper.js _javascript_ examples work
+        https://bugs.webkit.org/show_bug.cgi?id=87158
+
+        Reviewed by Michael Saboff.
+
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::resolve): If we have to bail out to
+        dynamicResolve(), only skip static scopes from the head of the
+        scope chain.  Before, we were also skipping activations with
+        direct eval as well, which was incorrect.
+
 2012-06-06  Dan Bernstein  <m...@apple.com>
 
         Reverted r119567, the fix for <http://webkit.org/b/88378>, because it broke the 32-bit build.

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (119574 => 119575)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2012-06-06 09:34:37 UTC (rev 119574)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2012-06-06 09:39:04 UTC (rev 119575)
@@ -1170,6 +1170,7 @@
     ScopeChainIterator iter = m_scopeChain->begin();
     ScopeChainIterator end = m_scopeChain->end();
     size_t depth = 0;
+    size_t depthOfFirstScopeWithDynamicChecks = 0;
     unsigned flags = 0;
     for (; iter != end; ++iter, ++depth) {
         JSObject* currentScope = iter->get();
@@ -1199,19 +1200,27 @@
         bool scopeRequiresDynamicChecks = false;
         if (currentVariableObject->isDynamicScope(scopeRequiresDynamicChecks))
             break;
-        if (scopeRequiresDynamicChecks)
-            flags |= ResolveResult::DynamicFlag;
+        if (!(flags & ResolveResult::DynamicFlag)) {
+            if (scopeRequiresDynamicChecks)
+                flags |= ResolveResult::DynamicFlag;
+            else
+                ++depthOfFirstScopeWithDynamicChecks;
+        }
     }
 
     // Can't locate the property but we're able to avoid a few lookups.
     JSObject* scope = iter->get();
+    // Step over the function's activation, if it needs one. At this point we
+    // know there is no dynamic scope in the function itself, so this is safe to
+    // do.
     depth += m_codeBlock->needsFullScopeChain();
+    depthOfFirstScopeWithDynamicChecks += m_codeBlock->needsFullScopeChain();
     if (++iter == end) {
         if ((flags & ResolveResult::DynamicFlag) && depth)
             return ResolveResult::dynamicGlobalResolve(depth, scope);
         return ResolveResult::globalResolve(scope);
     }
-    return ResolveResult::dynamicResolve(depth);
+    return ResolveResult::dynamicResolve(depthOfFirstScopeWithDynamicChecks);
 }
 
 ResolveResult BytecodeGenerator::resolveConstDecl(const Identifier& property)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to