Bug 677367 - Update pc in mjit throw-handling to match interp (r=dvander)
authorLuke Wagner <luke@mozilla.com>
Thu, 11 Aug 2011 16:59:55 -0700
changeset 75516 5bbc3615e3877e0d3fb047263cc995bc72e9cb73
parent 75515 2e2e0dc4654c4ad405b7dc0af4c8f88a97083ac0
child 75517 796b8466d549dc5db8df06f33210f8a1f02aaaf2
push id21031
push usermak77@bonardo.net
push dateFri, 19 Aug 2011 09:40:40 +0000
treeherdermozilla-central@1881f9b5f8b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
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 - Update pc in mjit throw-handling to match interp (r=dvander)
js/src/jit-test/tests/basic/bug666448.js
js/src/jit-test/tests/basic/testErrorInFinalizerCalledWhileUnwinding.js
js/src/methodjit/InvokeHelpers.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testErrorInFinalizerCalledWhileUnwinding.js
@@ -0,0 +1,32 @@
+var finalizerRun = false;
+var caught = false;
+
+function foo(arr) {
+  finalizerRun = true;
+  return not_defined;
+}
+
+function gen() {
+  try {
+    yield 1;
+  } finally {
+    foo();
+  }
+}
+
+function test() {
+  var i_have_locals;
+  for (i in gen()) {
+    "this won't work"();
+  }
+}
+
+try {
+    test();
+} catch(e) {
+    caught = true;
+    assertEq(''+e, "ReferenceError: not_defined is not defined");
+}
+
+assertEq(finalizerRun, true);
+assertEq(caught, true);
--- a/js/src/methodjit/InvokeHelpers.cpp
+++ b/js/src/methodjit/InvokeHelpers.cpp
@@ -109,16 +109,17 @@ top:
             //       But the first ops of exception handlers generated by our
             //       bytecode compiler cannot throw, so this is not possible.
             if (offset - tn->start > tn->length)
                 continue;
             if (tn->stackDepth > cx->regs().sp - fp->base())
                 continue;
 
             jsbytecode *pc = script->main + tn->start + tn->length;
+            cx->regs().pc = pc;
             JSBool ok = js_UnwindScope(cx, tn->stackDepth, JS_TRUE);
             JS_ASSERT(cx->regs().sp == fp->base() + tn->stackDepth);
 
             switch (tn->kind) {
                 case JSTRY_CATCH:
                   JS_ASSERT(js_GetOpcode(cx, fp->script(), pc) == JSOP_ENTERBLOCK);
 
 #if JS_HAS_GENERATORS