Commit d2192c60 authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: [turbofan] Implement throwing exceptions into TurboFan code.

Port 1382879f

Original commit message:
This extends the stack unwinding logic to respect optimized frames
and perform a lookup in the handler table to find handlers. It also
contains fixes to the API call stubs to allow a stack walk while
promoting scheduled exceptions.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#27027}
parent e813afaf
...@@ -5036,7 +5036,6 @@ static void CallApiFunctionAndReturn( ...@@ -5036,7 +5036,6 @@ static void CallApiFunctionAndReturn(
} }
Label promote_scheduled_exception; Label promote_scheduled_exception;
Label exception_handled;
Label delete_allocated_handles; Label delete_allocated_handles;
Label leave_exit_frame; Label leave_exit_frame;
Label return_value_loaded; Label return_value_loaded;
...@@ -5057,13 +5056,8 @@ static void CallApiFunctionAndReturn( ...@@ -5057,13 +5056,8 @@ static void CallApiFunctionAndReturn(
__ lw(at, MemOperand(s3, kLimitOffset)); __ lw(at, MemOperand(s3, kLimitOffset));
__ Branch(&delete_allocated_handles, ne, s1, Operand(at)); __ Branch(&delete_allocated_handles, ne, s1, Operand(at));
// Check if the function scheduled an exception. // Leave the API exit frame.
__ bind(&leave_exit_frame); __ bind(&leave_exit_frame);
__ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
__ li(at, Operand(ExternalReference::scheduled_exception_address(isolate)));
__ lw(t1, MemOperand(at));
__ Branch(&promote_scheduled_exception, ne, t0, Operand(t1));
__ bind(&exception_handled);
bool restore_context = context_restore_operand != NULL; bool restore_context = context_restore_operand != NULL;
if (restore_context) { if (restore_context) {
...@@ -5076,16 +5070,20 @@ static void CallApiFunctionAndReturn( ...@@ -5076,16 +5070,20 @@ static void CallApiFunctionAndReturn(
} else { } else {
__ li(s0, Operand(stack_space)); __ li(s0, Operand(stack_space));
} }
__ LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN, __ LeaveExitFrame(false, s0, !restore_context, NO_EMIT_RETURN,
stack_space_offset != kInvalidStackOffset); stack_space_offset != kInvalidStackOffset);
// Check if the function scheduled an exception.
__ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
__ li(at, Operand(ExternalReference::scheduled_exception_address(isolate)));
__ lw(t1, MemOperand(at));
__ Branch(&promote_scheduled_exception, ne, t0, Operand(t1));
__ Ret();
// Re-throw by promoting a scheduled exception.
__ bind(&promote_scheduled_exception); __ bind(&promote_scheduled_exception);
{ __ TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
FrameScope frame(masm, StackFrame::INTERNAL);
__ CallExternalReference(
ExternalReference(Runtime::kPromoteScheduledException, isolate), 0);
}
__ jmp(&exception_handled);
// HandleScope limit has changed. Delete allocated extensions. // HandleScope limit has changed. Delete allocated extensions.
__ bind(&delete_allocated_handles); __ bind(&delete_allocated_handles);
......
...@@ -5081,7 +5081,6 @@ static void CallApiFunctionAndReturn( ...@@ -5081,7 +5081,6 @@ static void CallApiFunctionAndReturn(
} }
Label promote_scheduled_exception; Label promote_scheduled_exception;
Label exception_handled;
Label delete_allocated_handles; Label delete_allocated_handles;
Label leave_exit_frame; Label leave_exit_frame;
Label return_value_loaded; Label return_value_loaded;
...@@ -5102,13 +5101,8 @@ static void CallApiFunctionAndReturn( ...@@ -5102,13 +5101,8 @@ static void CallApiFunctionAndReturn(
__ ld(at, MemOperand(s3, kLimitOffset)); __ ld(at, MemOperand(s3, kLimitOffset));
__ Branch(&delete_allocated_handles, ne, s1, Operand(at)); __ Branch(&delete_allocated_handles, ne, s1, Operand(at));
// Check if the function scheduled an exception. // Leave the API exit frame.
__ bind(&leave_exit_frame); __ bind(&leave_exit_frame);
__ LoadRoot(a4, Heap::kTheHoleValueRootIndex);
__ li(at, Operand(ExternalReference::scheduled_exception_address(isolate)));
__ ld(a5, MemOperand(at));
__ Branch(&promote_scheduled_exception, ne, a4, Operand(a5));
__ bind(&exception_handled);
bool restore_context = context_restore_operand != NULL; bool restore_context = context_restore_operand != NULL;
if (restore_context) { if (restore_context) {
...@@ -5120,15 +5114,20 @@ static void CallApiFunctionAndReturn( ...@@ -5120,15 +5114,20 @@ static void CallApiFunctionAndReturn(
} else { } else {
__ li(s0, Operand(stack_space)); __ li(s0, Operand(stack_space));
} }
__ LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN, __ LeaveExitFrame(false, s0, !restore_context, NO_EMIT_RETURN,
stack_space_offset != kInvalidStackOffset); stack_space_offset != kInvalidStackOffset);
// Check if the function scheduled an exception.
__ LoadRoot(a4, Heap::kTheHoleValueRootIndex);
__ li(at, Operand(ExternalReference::scheduled_exception_address(isolate)));
__ ld(a5, MemOperand(at));
__ Branch(&promote_scheduled_exception, ne, a4, Operand(a5));
__ Ret();
// Re-throw by promoting a scheduled exception.
__ bind(&promote_scheduled_exception); __ bind(&promote_scheduled_exception);
{ __ TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
FrameScope frame(masm, StackFrame::INTERNAL);
__ CallExternalReference(
ExternalReference(Runtime::kPromoteScheduledException, isolate), 0);
}
__ jmp(&exception_handled);
// HandleScope limit has changed. Delete allocated extensions. // HandleScope limit has changed. Delete allocated extensions.
__ bind(&delete_allocated_handles); __ bind(&delete_allocated_handles);
......
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