Bug 654734 - TrampolineCompiler::generateForceReturn should emit a call to ScriptDebugEpilogue.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 04 May 2011 11:15:42 -0500
changeset 74407 5fd40e7a5fafe5a0692a4886c543f8e6a1580a06
parent 74406 37b0503c5603ac038ff3f97b84639b161ae37b91
child 74408 c0cd70139fec36901d399270b394d73c8e522252
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs654734
milestone6.0a1
Bug 654734 - TrampolineCompiler::generateForceReturn should emit a call to ScriptDebugEpilogue.
js/src/jit-test/tests/debug/Frame-identity-01.js
js/src/jit-test/tests/debug/Frame-identity-02.js
js/src/methodjit/TrampolineCompiler.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Frame-identity-01.js
@@ -0,0 +1,22 @@
+// |jit-test| debug
+// Check that {return:} resumption kills the current stack frame.
+
+var g = newGlobal('new-compartment');
+g.debuggeeGlobal = this;
+g.eval("(" + function () {
+        var dbg = new Debug(debuggeeGlobal);
+        var prev = null;
+        dbg.hooks = {
+            debuggerHandler: function (frame) {
+                assertEq(frame === prev, false);
+                if (prev)
+                    assertEq(prev.live, false);
+                prev = frame;
+                return {return: frame.arguments[0]};
+            }
+        };
+    } + ")();");
+
+function f(i) { debugger; }
+for (var i = 0; i < HOTLOOP + 2; i++)
+    assertEq(f(i), i);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Frame-identity-02.js
@@ -0,0 +1,24 @@
+// |jit-test| debug
+// Check that {throw:} resumption kills the current stack frame.
+
+load(libdir + "asserts.js");
+
+var g = newGlobal('new-compartment');
+g.debuggeeGlobal = this;
+g.eval("(" + function () {
+        var dbg = new Debug(debuggeeGlobal);
+        var prev = null;
+        dbg.hooks = {
+            debuggerHandler: function (frame) {
+                assertEq(frame === prev, false);
+                if (prev)
+                    assertEq(prev.live, false);
+                prev = frame;
+                return {throw: debuggeeGlobal.i};
+            }
+        };
+    } + ")();");
+
+function f() { debugger; }
+for (var i = 0; i < HOTLOOP + 2; i++)
+    assertThrowsValue(f, i);
--- a/js/src/methodjit/TrampolineCompiler.cpp
+++ b/js/src/methodjit/TrampolineCompiler.cpp
@@ -111,16 +111,18 @@ TrampolineCompiler::compileTrampoline(Tr
  * - There was always at least one inline call.
  * - We don't know if there is a call object, so we always check.
  * - We don't know where we came from, so we don't know frame depth or PC.
  * - There is no stub buffer.
  */
 bool
 TrampolineCompiler::generateForceReturn(Assembler &masm)
 {
+    masm.fallibleVMCall(JS_FUNC_TO_DATA_PTR(void *, stubs::ScriptDebugEpilogue), NULL, 0);
+
     /* if (hasArgsObj() || hasCallObj()) stubs::PutActivationObjects() */
     Jump noActObjs = masm.branchTest32(Assembler::Zero, FrameFlagsAddress(),
                                        Imm32(StackFrame::HAS_CALL_OBJ | StackFrame::HAS_ARGS_OBJ));
     masm.fallibleVMCall(JS_FUNC_TO_DATA_PTR(void *, stubs::PutActivationObjects), NULL, 0);
     noActObjs.linkTo(masm.label(), &masm);
 
     /* Store any known return value */
     masm.loadValueAsComponents(UndefinedValue(), JSReturnReg_Type, JSReturnReg_Data);