Bug 676023 - Increment pc on error path out of JSOP_RETURN (r=dvander)

This commit is contained in:
Luke Wagner 2011-08-04 23:15:35 -07:00
Родитель 5faa4d1700
Коммит 4e698e1b0a
2 изменённых файлов: 45 добавлений и 2 удалений

Просмотреть файл

@ -103,3 +103,42 @@ BEGIN_TEST(testDebugger_getThisStrict)
return true;
}
END_TEST(testDebugger_getThisStrict)
bool called = false;
static JSTrapStatus
ThrowHook(JSContext *cx, JSScript *, jsbytecode *, jsval *rval, void *closure)
{
called = true;
JSObject *global = JS_GetGlobalForScopeChain(cx);
char text[] = "new Error()";
jsval _;
JS_EvaluateScript(cx, global, text, strlen(text), "", 0, &_);
return JSTRAP_CONTINUE;
}
BEGIN_TEST(testDebugger_throwHook)
{
uint32 newopts = JS_GetOptions(cx) | JSOPTION_METHODJIT | JSOPTION_METHODJIT_ALWAYS;
uint32 oldopts = JS_SetOptions(cx, newopts);
JSDebugHooks hooks = { 0 };
hooks.throwHook = ThrowHook;
JSDebugHooks *old = JS_SetContextDebugHooks(cx, &hooks);
EXEC("function foo() { throw 3 };\n"
"for (var i = 0; i < 10; ++i) { \n"
" var x = <tag></tag>;\n"
" try {\n"
" foo(); \n"
" } catch(e) {}\n"
"}\n");
CHECK(called);
JS_SetContextDebugHooks(cx, old);
JS_SetOptions(cx, oldopts);
return true;
}
END_TEST(testDebugger_throwHook)

Просмотреть файл

@ -2363,15 +2363,19 @@ BEGIN_CASE(JSOP_STOP)
argv = regs.fp()->maybeFormalArgs();
atoms = FrameAtomBase(cx, regs.fp());
JS_ASSERT(*regs.pc == JSOP_TRAP || *regs.pc == JSOP_NEW || *regs.pc == JSOP_CALL ||
*regs.pc == JSOP_FUNCALL || *regs.pc == JSOP_FUNAPPLY);
/* Resume execution in the calling frame. */
RESET_USE_METHODJIT();
if (JS_LIKELY(interpReturnOK)) {
JS_ASSERT(js_CodeSpec[js_GetOpcode(cx, script, regs.pc)].length
== JSOP_CALL_LENGTH);
TRACE_0(LeaveFrame);
len = JSOP_CALL_LENGTH;
DO_NEXT_OP(len);
}
/* Increment pc so that |sp - fp->slots == ReconstructStackDepth(pc)|. */
regs.pc += JSOP_CALL_LENGTH;
goto error;
} else {
JS_ASSERT(regs.sp == regs.fp()->base());