Bug 621432 - Properly reconstruct the pcstack when decompiling for an exception thrown during script prolog execution. r=jorendorff, a=beltzner
authorJeff Walden <jwalden@mit.edu>
Fri, 11 Feb 2011 14:14:50 -0800
changeset 62934 19560901b9e764f99f15c0001a1fa59154009ea9
parent 62933 dd971b2a61291d4708cdb9b88035c1bffb2d3064
child 62935 d3dd12467800cfa8735b31b0724875abde2fe9b2
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersjorendorff, beltzner
bugs621432
milestone2.0b12pre
Bug 621432 - Properly reconstruct the pcstack when decompiling for an exception thrown during script prolog execution. r=jorendorff, a=beltzner
js/src/jsopcode.cpp
js/src/tests/ecma_5/Global/adding-global-var-nonextensible-error.js
js/src/tests/ecma_5/Global/jstests.list
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -5484,18 +5484,18 @@ ReconstructPCStack(JSContext *cx, JSScri
      */
 #ifdef JS_TRACER
     jsbytecode *imacstart = js_GetImacroStart(target);
 
     if (imacstart)
         return ReconstructImacroPCStack(cx, script, imacstart, target, pcstack);
 #endif
 
-    LOCAL_ASSERT(script->main <= target && target < script->code + script->length);
-    jsbytecode *pc = script->main;
+    LOCAL_ASSERT(script->code <= target && target < script->code + script->length);
+    jsbytecode *pc = script->code;
     uintN pcdepth = 0;
     ptrdiff_t oplen;
     for (; pc < target; pc += oplen) {
         JSOp op = js_GetOpcode(cx, script, pc);
         const JSCodeSpec *cs = &js_CodeSpec[op];
         oplen = cs->length;
         if (oplen < 0)
             oplen = js_GetVariableBytecodeLength(pc);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_5/Global/adding-global-var-nonextensible-error.js
@@ -0,0 +1,35 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 621432;
+var summary =
+  "If a var statement can't create a global property because the global " +
+  "object isn't extensible, and an error is thrown while decompiling the " +
+  "global, don't assert";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var toSource = [];
+Object.preventExtensions(this);
+
+try
+{
+  eval("var x;");
+  throw new Error("no error thrown");
+}
+catch (e)
+{
+  assertEq(e instanceof TypeError, true, "expected TypeError, got: " + e);
+}
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+  reportCompare(true, true);
+
+print("All tests passed!");
--- a/js/src/tests/ecma_5/Global/jstests.list
+++ b/js/src/tests/ecma_5/Global/jstests.list
@@ -1,9 +1,10 @@
 url-prefix ../../jsreftest.html?test=ecma_5/Global/
+script adding-global-var-nonextensible-error.js
 script parseInt-01.js
 script parseFloat-01.js
 script eval-01.js
 script eval-02.js
 script eval-inside-with-is-direct.js
 script parenthesized-eval-is-direct.js
 script eval-native-callback-is-indirect.js
 script direct-eval-but-not.js