Bug 1147216 - Part 2: Use the right line number for strict eval. r=luke, a=lizzard
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 10 Apr 2015 11:38:52 +0200
changeset 267018 729003f39455b1f1bd8d152b1b326ef791d736c9
parent 267017 2deec68d84bb52f6116365f2b588e77188895ef9
child 267019 1edabd405ab87b2c466693899186441afcb42d3b
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke, lizzard
bugs1147216
milestone39.0a2
Bug 1147216 - Part 2: Use the right line number for strict eval. r=luke, a=lizzard
js/src/jit-test/tests/basic/bug1147216.js
js/src/jsscript.cpp
--- a/js/src/jit-test/tests/basic/bug1147216.js
+++ b/js/src/jit-test/tests/basic/bug1147216.js
@@ -1,14 +1,25 @@
 // Ensure JSOP_LINENO (emitted after JSOP_EVAL) handles big line
 // numbers correctly.
-function f() {
+function getsource() {
     var s = "";
-    var stack;
     for (var i=0; i<66002; i++) {
 	s += "\n";
 	if (i === 66000)
 	    s += "eval('stack = Error().stack');";
     }
-    eval(s);
+    return s;
+}
+function test() {
+    var stack;
+    eval(getsource());
     assertEq(stack.indexOf("line 66002") > 0, true);
 }
-f();
+test();
+
+function testStrict() {
+    "use strict";
+    var stack;
+    eval(getsource());
+    assertEq(stack.indexOf("line 66002") > 0, true);
+}
+testStrict();
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -2910,22 +2910,23 @@ js::DescribeScriptedCallerForCompilation
         jsbytecode* pc = nullptr;
         maybeScript.set(cx->currentScript(&pc));
         static_assert(JSOP_SPREADEVAL_LENGTH == JSOP_STRICTSPREADEVAL_LENGTH,
                     "next op after a spread must be at consistent offset");
         static_assert(JSOP_EVAL_LENGTH == JSOP_STRICTEVAL_LENGTH,
                     "next op after a direct eval must be at consistent offset");
         MOZ_ASSERT(JSOp(*pc) == JSOP_EVAL || JSOp(*pc) == JSOP_STRICTEVAL ||
                    JSOp(*pc) == JSOP_SPREADEVAL || JSOp(*pc) == JSOP_STRICTSPREADEVAL);
-        mozilla::DebugOnly<bool> isSpread = JSOp(*pc) == JSOP_SPREADEVAL ||
-                                            JSOp(*pc) == JSOP_STRICTSPREADEVAL;
-        MOZ_ASSERT(*(pc + (isSpread ? JSOP_SPREADEVAL_LENGTH : JSOP_EVAL_LENGTH)) == JSOP_LINENO);
+
+        bool isSpread = JSOp(*pc) == JSOP_SPREADEVAL || JSOp(*pc) == JSOP_STRICTSPREADEVAL;
+        jsbytecode* nextpc = pc + (isSpread ? JSOP_SPREADEVAL_LENGTH : JSOP_EVAL_LENGTH);
+        MOZ_ASSERT(*nextpc == JSOP_LINENO);
+
         *file = maybeScript->filename();
-        *linenop = GET_UINT32(pc + (JSOp(*pc) == JSOP_EVAL ? JSOP_EVAL_LENGTH
-                                                           : JSOP_SPREADEVAL_LENGTH));
+        *linenop = GET_UINT32(nextpc);
         *pcOffset = pc - maybeScript->code();
         *mutedErrors = maybeScript->mutedErrors();
         return;
     }
 
     NonBuiltinFrameIter iter(cx);
 
     if (iter.done()) {