[interpreter] Fix return address when entering exception handler.

This fixes the broken return address when the exception handler within
interpreted bytecode is being entered via stack unwinding. The address
in question will never actually be taken, but our stack walker uses this
address to determine whether a frame is interpreted.

R=rmcilroy@chromium.org
TEST=cctest/test-interpreter/InterpreterTryCatch
BUG=v8:4674
LOG=n

Review URL: https://codereview.chromium.org/1615063002

Cr-Commit-Position: refs/heads/master@{#33463}
This commit is contained in:
mstarzinger 2016-01-22 03:16:16 -08:00 committed by Commit bot
parent 747bd6f215
commit ca51c204e1
7 changed files with 39 additions and 0 deletions

View File

@ -1149,6 +1149,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ Move(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline());
Generate_EnterBytecodeDispatch(masm);
}

View File

@ -1108,6 +1108,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline());
Generate_EnterBytecodeDispatch(masm);
}

View File

@ -857,6 +857,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ Push(masm->isolate()->builtins()->InterpreterEntryTrampoline());
Generate_EnterBytecodeDispatch(masm);
}

View File

@ -1140,6 +1140,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline()));
Generate_EnterBytecodeDispatch(masm);
}

View File

@ -1131,6 +1131,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline()));
Generate_EnterBytecodeDispatch(masm);
}

View File

@ -905,6 +905,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ Push(masm->isolate()->builtins()->InterpreterEntryTrampoline());
Generate_EnterBytecodeDispatch(masm);
}

View File

@ -2030,6 +2030,9 @@ TEST(InterpreterTryCatch) {
handle(Smi::FromInt(2), isolate)),
std::make_pair("var a; try { throw 1 } catch(e) { a = e + 2 }; return a;",
handle(Smi::FromInt(3), isolate)),
std::make_pair("var a; try { throw 1 } catch(e) { a = e + 2 };"
" try { throw a } catch(e) { a = e + 3 }; return a;",
handle(Smi::FromInt(6), isolate)),
};
for (size_t i = 0; i < arraysize(catches); i++) {