Bug 677367 - Debug eval-in-frame needs to compute this of enclosing frame (r=jorendorff)
authorLuke Wagner <luke@mozilla.com>
Wed, 10 Aug 2011 17:34:34 -0700
changeset 76826 2e2e0dc4654c4ad405b7dc0af4c8f88a97083ac0
parent 76825 902a7c3eb320a18b4052db3c19fa750e42b4bb71
child 76827 5bbc3615e3877e0d3fb047263cc995bc72e9cb73
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs677367
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 677367 - Debug eval-in-frame needs to compute this of enclosing frame (r=jorendorff)
js/src/jit-test/tests/basic/bug666448.js
js/src/jit-test/tests/basic/testBug677367.js
js/src/jit-test/tests/basic/testEvalFromTrap.js
js/src/jit-test/tests/bug666448.js
js/src/jit-test/tests/debug/onDebuggerStatement-04.js
js/src/jsobj.cpp
js/src/vm/Debugger.cpp
rename from js/src/jit-test/tests/bug666448.js
rename to js/src/jit-test/tests/basic/bug666448.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testBug677367.js
@@ -0,0 +1,5 @@
+// |jit-test| debug
+
+function f() {}
+trap(f, 0, 'eval("2+2")');
+f();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testEvalFromTrap.js
@@ -0,0 +1,4 @@
+// |jit-test| debug
+function f() {}
+trap(f, 0, 'eval("2+2")');
+f();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/onDebuggerStatement-04.js
@@ -0,0 +1,10 @@
+var g = newGlobal('new-compartment');
+var dbg = new Debugger(g);
+dbg.onDebuggerStatement = function (frame) {
+    var code = "assertEq(c, 'ok');\n";
+    assertEq(frame.evalWithBindings("eval(s)", {s: code, a: 1234}).return, undefined);
+};
+g.eval("function first() { return second(); }");
+g.eval("function second() { return eval('third()'); }");
+g.eval("function third() { debugger; }");
+g.evaluate("first();");
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -1186,17 +1186,16 @@ EvalKernel(JSContext *cx, const CallArgs
          * the eval code to use.
          */
         if (!ComputeThis(cx, caller))
             return false;
         thisv = caller->thisValue();
 
 #ifdef DEBUG
         jsbytecode *callerPC = caller->pcQuadratic(cx);
-        JS_ASSERT_IF(caller->isFunctionFrame(), caller->fun()->isHeavyweight());
         JS_ASSERT(callerPC && js_GetOpcode(cx, caller->script(), callerPC) == JSOP_EVAL);
 #endif
     } else {
         JS_ASSERT(call.callee().getGlobal() == &scopeobj);
         staticLevel = 0;
 
         /* Use the global as 'this', modulo outerization. */
         JSObject *thisobj = scopeobj.thisObject(cx);
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2653,16 +2653,20 @@ DebuggerFrame_getLive(JSContext *cx, uin
 namespace js {
 
 JSBool
 EvaluateInScope(JSContext *cx, JSObject *scobj, StackFrame *fp, const jschar *chars,
                 uintN length, const char *filename, uintN lineno, Value *rval)
 {
     assertSameCompartment(cx, scobj, fp);
 
+    /* Execute assumes an already-computed 'this" value. */
+    if (!ComputeThis(cx, fp))
+        return false;
+
     /*
      * NB: This function breaks the assumption that the compiler can see all
      * calls and properly compute a static level. In order to get around this,
      * we use a static level that will cause us not to attempt to optimize
      * variable references made by this frame.
      */
     JSScript *script = Compiler::compileScript(cx, scobj, fp, fp->scopeChain().principals(cx),
                                                TCF_COMPILE_N_GO, chars, length,