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 75518 5bbc3615e3877e0d3fb047263cc995bc72e9cb73
parent 75517 2e2e0dc4654c4ad405b7dc0af4c8f88a97083ac0
child 75519 796b8466d549dc5db8df06f33210f8a1f02aaaf2
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersdvander
bugs677367
milestone9.0a1
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