Commit ca51c204 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[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}
parent 747bd6f2
...@@ -1149,6 +1149,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { ...@@ -1149,6 +1149,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(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); Generate_EnterBytecodeDispatch(masm);
} }
......
...@@ -1108,6 +1108,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { ...@@ -1108,6 +1108,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(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); Generate_EnterBytecodeDispatch(masm);
} }
......
...@@ -857,6 +857,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { ...@@ -857,6 +857,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(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); Generate_EnterBytecodeDispatch(masm);
} }
......
...@@ -1140,6 +1140,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { ...@@ -1140,6 +1140,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(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); Generate_EnterBytecodeDispatch(masm);
} }
......
...@@ -1131,6 +1131,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { ...@@ -1131,6 +1131,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(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); Generate_EnterBytecodeDispatch(masm);
} }
......
...@@ -905,6 +905,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { ...@@ -905,6 +905,12 @@ void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_InterpreterEnterExceptionHandler(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); Generate_EnterBytecodeDispatch(masm);
} }
......
...@@ -2030,6 +2030,9 @@ TEST(InterpreterTryCatch) { ...@@ -2030,6 +2030,9 @@ TEST(InterpreterTryCatch) {
handle(Smi::FromInt(2), isolate)), handle(Smi::FromInt(2), isolate)),
std::make_pair("var a; try { throw 1 } catch(e) { a = e + 2 }; return a;", std::make_pair("var a; try { throw 1 } catch(e) { a = e + 2 }; return a;",
handle(Smi::FromInt(3), isolate)), 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++) { for (size_t i = 0; i < arraysize(catches); i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment