Chromium Code Reviews| Index: src/arm/code-stubs-arm.cc |
| diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc |
| index ad04cb5454adff449c9d3236ce65ae0aa80330a7..5cf7238a68a298709e2d1c80acd7edcdd5dfbe62 100644 |
| --- a/src/arm/code-stubs-arm.cc |
| +++ b/src/arm/code-stubs-arm.cc |
| @@ -937,6 +937,57 @@ void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
| } |
| +static void ThrowPendingException(MacroAssembler* masm) { |
| + Isolate* isolate = masm->isolate(); |
| + |
| + ExternalReference pending_handler_context_address( |
| + Isolate::kPendingHandlerContextAddress, isolate); |
| + ExternalReference pending_handler_code_address( |
| + Isolate::kPendingHandlerCodeAddress, isolate); |
| + ExternalReference pending_handler_offset_address( |
| + Isolate::kPendingHandlerOffsetAddress, isolate); |
| + ExternalReference pending_handler_fp_address( |
| + Isolate::kPendingHandlerFPAddress, isolate); |
| + ExternalReference pending_handler_sp_address( |
| + Isolate::kPendingHandlerSPAddress, isolate); |
| + |
| + // Ask the runtime for help to determine the handler. This will set r0 to |
| + // contain the current pending exception, don't clobber it. |
| + ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate); |
| + __ mov(r0, Operand(0)); |
| + __ mov(r1, Operand(0)); |
| + __ mov(r2, Operand(ExternalReference::isolate_address(isolate))); |
| + __ mov(r5, Operand(find_handler)); |
| + __ Call(r5); |
| + |
| + // Retrieve the handler context, SP and FP. |
| + __ mov(ip, Operand(pending_handler_context_address)); |
|
rmcilroy
2015/03/02 13:08:27
I don't think you should use ip here - it could be
Michael Starzinger
2015/03/02 14:21:17
Done. Thanks, got it.
|
| + __ ldr(cp, MemOperand(ip)); |
| + __ mov(ip, Operand(pending_handler_sp_address)); |
| + __ ldr(sp, MemOperand(ip)); |
| + __ mov(ip, Operand(pending_handler_fp_address)); |
| + __ ldr(fp, MemOperand(ip)); |
| + |
| + // If the handler is a JS frame, restore the context to the frame. |
| + // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp |
| + // or cp. |
| + __ tst(cp, cp); |
| + __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne); |
| + |
| + // Compute the handler entry address and jump to it. |
| + ConstantPoolUnavailableScope constant_pool_unavailable(masm); |
| + __ mov(r1, Operand(pending_handler_code_address)); |
| + __ ldr(r1, MemOperand(r1)); |
| + __ mov(r2, Operand(pending_handler_offset_address)); |
| + __ ldr(r2, MemOperand(r2)); |
| + if (FLAG_enable_ool_constant_pool) { |
| + __ ldr(pp, FieldMemOperand(r1, Code::kConstantPoolOffset)); |
| + } |
| + __ add(r1, r1, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| + __ add(pc, r1, r2); |
| +} |
| + |
| + |
| void CEntryStub::Generate(MacroAssembler* masm) { |
| // Called from JavaScript; parameters are on stack as if calling JS function. |
| // r0: number of arguments including receiver |
| @@ -1018,13 +1069,12 @@ void CEntryStub::Generate(MacroAssembler* masm) { |
| __ CompareRoot(r0, Heap::kExceptionRootIndex); |
| __ b(eq, &exception_returned); |
| - ExternalReference pending_exception_address( |
| - Isolate::kPendingExceptionAddress, isolate()); |
| - |
| // Check that there is no pending exception, otherwise we |
| // should have returned the exception sentinel. |
| if (FLAG_debug_code) { |
| Label okay; |
| + ExternalReference pending_exception_address( |
| + Isolate::kPendingExceptionAddress, isolate()); |
| __ mov(r2, Operand(pending_exception_address)); |
| __ ldr(r2, MemOperand(r2)); |
| __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); |
| @@ -1044,26 +1094,7 @@ void CEntryStub::Generate(MacroAssembler* masm) { |
| // Handling of exception. |
| __ bind(&exception_returned); |
| - |
| - // Retrieve the pending exception. |
| - __ mov(r2, Operand(pending_exception_address)); |
| - __ ldr(r0, MemOperand(r2)); |
| - |
| - // Clear the pending exception. |
| - __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); |
| - __ str(r3, MemOperand(r2)); |
| - |
| - // Special handling of termination exceptions which are uncatchable |
| - // by javascript code. |
| - Label throw_termination_exception; |
| - __ CompareRoot(r0, Heap::kTerminationExceptionRootIndex); |
| - __ b(eq, &throw_termination_exception); |
| - |
| - // Handle normal exception. |
| - __ Throw(r0); |
| - |
| - __ bind(&throw_termination_exception); |
| - __ ThrowUncatchable(r0); |
| + ThrowPendingException(masm); |
| } |
| @@ -2200,18 +2231,9 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { |
| __ cmp(r0, r1); |
| __ b(eq, &runtime); |
| - __ str(r1, MemOperand(r2, 0)); // Clear pending exception. |
| - |
| - // Check if the exception is a termination. If so, throw as uncatchable. |
| - __ CompareRoot(r0, Heap::kTerminationExceptionRootIndex); |
| - |
| - Label termination_exception; |
| - __ b(eq, &termination_exception); |
| - |
| - __ Throw(r0); |
| - |
| - __ bind(&termination_exception); |
| - __ ThrowUncatchable(r0); |
| + // For exception, throw the exception again. |
| + __ EnterExitFrame(false); |
| + ThrowPendingException(masm); |
| __ bind(&failure); |
| // For failure and exception return null. |