Chromium Code Reviews| Index: src/ia32/code-stubs-ia32.cc |
| diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
| index b5cf5cec5c1ac71ca6f14e4fed3f68e0d57fbd9b..96cc77113052b69a983c39832ed797c4579e9578 100644 |
| --- a/src/ia32/code-stubs-ia32.cc |
| +++ b/src/ia32/code-stubs-ia32.cc |
| @@ -1184,6 +1184,52 @@ void RestParamAccessStub::GenerateNew(MacroAssembler* masm) { |
| } |
| +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 eax to |
| + // contain the current pending exception, don't clobber it. |
| + ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate); |
| + __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc. |
| + __ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv. |
| + __ mov(Operand(esp, 2 * kPointerSize), |
| + Immediate(ExternalReference::isolate_address(isolate))); |
| + __ mov(ebx, Immediate(find_handler)); |
| + __ call(ebx); |
| + |
| + // Retrieve the handler context, SP and FP. |
| + __ mov(esi, Operand::StaticVariable(pending_handler_context_address)); |
| + __ mov(esp, Operand::StaticVariable(pending_handler_sp_address)); |
| + __ mov(ebp, Operand::StaticVariable(pending_handler_fp_address)); |
| + |
| + // If the handler is a JS frame, restore the context to the frame. |
| + // (kind == ENTRY) == (ebp == 0) == (esi == 0), so we could test either |
| + // ebp or esi. |
| + Label skip; |
| + __ test(esi, esi); |
| + __ j(zero, &skip, Label::kNear); |
| + __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi); |
| + __ bind(&skip); |
| + |
| + // Compute the handler entry address and jump to it. |
| + __ mov(edi, Operand::StaticVariable(pending_handler_code_address)); |
| + __ mov(edx, Operand::StaticVariable(pending_handler_offset_address)); |
| + __ lea(edi, FieldOperand(edi, edx, times_1, Code::kHeaderSize)); |
| + __ jmp(edi); |
| +} |
| + |
| + |
| void RegExpExecStub::Generate(MacroAssembler* masm) { |
| // Just jump directly to runtime if native RegExp is not selected at compile |
| // time or if regexp entry in generated code is turned off runtime switch or |
| @@ -1465,22 +1511,9 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { |
| __ mov(eax, Operand::StaticVariable(pending_exception)); |
| __ cmp(edx, eax); |
| __ j(equal, &runtime); |
| - // For exception, throw the exception again. |
| - // Clear the pending exception variable. |
| - __ mov(Operand::StaticVariable(pending_exception), edx); |
| - |
| - // Special handling of termination exceptions which are uncatchable |
| - // by javascript code. |
| - __ cmp(eax, factory->termination_exception()); |
| - Label throw_termination_exception; |
| - __ j(equal, &throw_termination_exception, Label::kNear); |
| - |
| - // Handle normal exception by following handler chain. |
| - __ Throw(eax); |
| - |
| - __ bind(&throw_termination_exception); |
| - __ ThrowUncatchable(eax); |
| + // For exception, throw the exception again. |
| + ThrowPendingException(masm); |
|
Jarin
2015/02/27 07:49:14
Out of curiosity, how is the uncatchable exception
|
| __ bind(&failure); |
| // For failure to match, return null. |
| @@ -2515,15 +2548,14 @@ void CEntryStub::Generate(MacroAssembler* masm) { |
| __ cmp(eax, isolate()->factory()->exception()); |
| __ j(equal, &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) { |
| __ push(edx); |
| __ mov(edx, Immediate(isolate()->factory()->the_hole_value())); |
| Label okay; |
| + ExternalReference pending_exception_address( |
| + Isolate::kPendingExceptionAddress, isolate()); |
| __ cmp(edx, Operand::StaticVariable(pending_exception_address)); |
| // Cannot use check here as it attempts to generate call into runtime. |
| __ j(equal, &okay, Label::kNear); |
| @@ -2538,25 +2570,7 @@ void CEntryStub::Generate(MacroAssembler* masm) { |
| // Handling of exception. |
| __ bind(&exception_returned); |
| - |
| - // Retrieve the pending exception. |
| - __ mov(eax, Operand::StaticVariable(pending_exception_address)); |
| - |
| - // Clear the pending exception. |
| - __ mov(edx, Immediate(isolate()->factory()->the_hole_value())); |
| - __ mov(Operand::StaticVariable(pending_exception_address), edx); |
| - |
| - // Special handling of termination exceptions which are uncatchable |
| - // by javascript code. |
| - Label throw_termination_exception; |
| - __ cmp(eax, isolate()->factory()->termination_exception()); |
| - __ j(equal, &throw_termination_exception); |
| - |
| - // Handle normal exception. |
| - __ Throw(eax); |
| - |
| - __ bind(&throw_termination_exception); |
| - __ ThrowUncatchable(eax); |
| + ThrowPendingException(masm); |
| } |