Bug 717417: Don't skip ScriptDebugEpilogue when an onExceptionUnwind handler throws an uncaught exception or terminates the debuggee. r=jorendorff
authorJim Blandy <jimb@mozilla.com>
Mon, 23 Jan 2012 17:44:32 -0800
changeset 86391 650f4fa9ca1244e9538edb4daabebbc805e6eee5
parent 86390 93602e4ac4d9f8bce5594f72bfdfaa2190da2c24
child 86392 ca4d85ac6bf50317f6f9d52f314cb53bb2a1cf79
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs717417
milestone12.0a1
Bug 717417: Don't skip ScriptDebugEpilogue when an onExceptionUnwind handler throws an uncaught exception or terminates the debuggee. r=jorendorff
js/src/jit-test/tests/debug/onExceptionUnwind-08.js
js/src/jit-test/tests/debug/onExceptionUnwind-09.js
js/src/jit-test/tests/debug/onExceptionUnwind-10.js
js/src/methodjit/InvokeHelpers.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/onExceptionUnwind-08.js
@@ -0,0 +1,18 @@
+// Ensure that ScriptDebugEpilogue gets called when onExceptionUnwind
+// throws an uncaught exception.
+var g = newGlobal('new-compartment');
+var dbg = Debugger(g);
+var frame;
+dbg.onExceptionUnwind = function (f, x) {
+    frame = f;
+    assertEq(frame.live, true);
+    throw 'unhandled';
+};
+dbg.onDebuggerStatement = function(f) {
+    assertEq(f.eval('throw 42'), null);
+    assertEq(frame.live, false);
+};
+g.eval('debugger');
+
+// Don't fail just because we reported an uncaught exception.
+quit(0);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/onExceptionUnwind-09.js
@@ -0,0 +1,15 @@
+// Ensure that ScriptDebugEpilogue gets called when onExceptionUnwind
+// terminates execution.
+var g = newGlobal('new-compartment');
+var dbg = Debugger(g);
+var frame;
+dbg.onExceptionUnwind = function (f, x) {
+    frame = f;
+    assertEq(frame.live, true);
+    return null;
+};
+dbg.onDebuggerStatement = function(f) {
+    assertEq(f.eval('throw 42'), null);
+    assertEq(frame.live, false);
+};
+g.eval('debugger');
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/onExceptionUnwind-10.js
@@ -0,0 +1,16 @@
+// Ensure that ScriptDebugEpilogue gets called when onExceptionUnwind
+// terminates execution.
+var g = newGlobal('new-compartment');
+var dbg = Debugger(g);
+var frame;
+dbg.onExceptionUnwind = function (f, x) {
+    frame = f;
+    assertEq(frame.type, 'eval');
+    assertEq(frame.live, true);
+    terminate();
+};
+dbg.onDebuggerStatement = function(f) {
+    assertEq(f.eval('throw 42'), null);
+    assertEq(frame.live, false);
+};
+g.eval('debugger');
--- a/js/src/methodjit/InvokeHelpers.cpp
+++ b/js/src/methodjit/InvokeHelpers.cpp
@@ -542,20 +542,20 @@ js_InternalThrow(VMFrame &f)
                 if (st == JSTRAP_CONTINUE && handler) {
                     st = handler(cx, cx->fp()->script(), cx->regs().pc, &rval,
                                  cx->debugHooks->throwHookData);
                 }
 
                 switch (st) {
                 case JSTRAP_ERROR:
                     cx->clearPendingException();
-                    return NULL;
+                    break;
 
                 case JSTRAP_CONTINUE:
-                  break;
+                    break;
 
                 case JSTRAP_RETURN:
                     cx->clearPendingException();
                     cx->fp()->setReturnValue(rval);
                     return cx->jaegerCompartment()->forceReturnFromExternC();
 
                 case JSTRAP_THROW:
                     cx->setPendingException(rval);