| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 __ mov(Operand(esp, 2 * kPointerSize), ecx); | 1178 __ mov(Operand(esp, 2 * kPointerSize), ecx); |
| 1179 __ lea(edx, Operand(edx, ecx, times_2, | 1179 __ lea(edx, Operand(edx, ecx, times_2, |
| 1180 StandardFrameConstants::kCallerSPOffset)); | 1180 StandardFrameConstants::kCallerSPOffset)); |
| 1181 __ mov(Operand(esp, 3 * kPointerSize), edx); | 1181 __ mov(Operand(esp, 3 * kPointerSize), edx); |
| 1182 | 1182 |
| 1183 __ bind(&runtime); | 1183 __ bind(&runtime); |
| 1184 __ TailCallRuntime(Runtime::kNewRestParam, 3, 1); | 1184 __ TailCallRuntime(Runtime::kNewRestParam, 3, 1); |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 | 1187 |
| 1188 static void ThrowPendingException(MacroAssembler* masm) { | |
| 1189 Isolate* isolate = masm->isolate(); | |
| 1190 | |
| 1191 ExternalReference pending_handler_context_address( | |
| 1192 Isolate::kPendingHandlerContextAddress, isolate); | |
| 1193 ExternalReference pending_handler_code_address( | |
| 1194 Isolate::kPendingHandlerCodeAddress, isolate); | |
| 1195 ExternalReference pending_handler_offset_address( | |
| 1196 Isolate::kPendingHandlerOffsetAddress, isolate); | |
| 1197 ExternalReference pending_handler_fp_address( | |
| 1198 Isolate::kPendingHandlerFPAddress, isolate); | |
| 1199 ExternalReference pending_handler_sp_address( | |
| 1200 Isolate::kPendingHandlerSPAddress, isolate); | |
| 1201 | |
| 1202 // Ask the runtime for help to determine the handler. This will set eax to | |
| 1203 // contain the current pending exception, don't clobber it. | |
| 1204 ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate); | |
| 1205 { | |
| 1206 FrameScope scope(masm, StackFrame::MANUAL); | |
| 1207 __ PrepareCallCFunction(3, eax); | |
| 1208 __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc. | |
| 1209 __ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv. | |
| 1210 __ mov(Operand(esp, 2 * kPointerSize), | |
| 1211 Immediate(ExternalReference::isolate_address(isolate))); | |
| 1212 __ CallCFunction(find_handler, 3); | |
| 1213 } | |
| 1214 | |
| 1215 // Retrieve the handler context, SP and FP. | |
| 1216 __ mov(esi, Operand::StaticVariable(pending_handler_context_address)); | |
| 1217 __ mov(esp, Operand::StaticVariable(pending_handler_sp_address)); | |
| 1218 __ mov(ebp, Operand::StaticVariable(pending_handler_fp_address)); | |
| 1219 | |
| 1220 // If the handler is a JS frame, restore the context to the frame. | |
| 1221 // (kind == ENTRY) == (ebp == 0) == (esi == 0), so we could test either | |
| 1222 // ebp or esi. | |
| 1223 Label skip; | |
| 1224 __ test(esi, esi); | |
| 1225 __ j(zero, &skip, Label::kNear); | |
| 1226 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi); | |
| 1227 __ bind(&skip); | |
| 1228 | |
| 1229 // Compute the handler entry address and jump to it. | |
| 1230 __ mov(edi, Operand::StaticVariable(pending_handler_code_address)); | |
| 1231 __ mov(edx, Operand::StaticVariable(pending_handler_offset_address)); | |
| 1232 __ lea(edi, FieldOperand(edi, edx, times_1, Code::kHeaderSize)); | |
| 1233 __ jmp(edi); | |
| 1234 } | |
| 1235 | |
| 1236 | |
| 1237 void RegExpExecStub::Generate(MacroAssembler* masm) { | 1188 void RegExpExecStub::Generate(MacroAssembler* masm) { |
| 1238 // Just jump directly to runtime if native RegExp is not selected at compile | 1189 // Just jump directly to runtime if native RegExp is not selected at compile |
| 1239 // time or if regexp entry in generated code is turned off runtime switch or | 1190 // time or if regexp entry in generated code is turned off runtime switch or |
| 1240 // at compilation. | 1191 // at compilation. |
| 1241 #ifdef V8_INTERPRETED_REGEXP | 1192 #ifdef V8_INTERPRETED_REGEXP |
| 1242 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); | 1193 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
| 1243 #else // V8_INTERPRETED_REGEXP | 1194 #else // V8_INTERPRETED_REGEXP |
| 1244 | 1195 |
| 1245 // Stack frame on entry. | 1196 // Stack frame on entry. |
| 1246 // esp[0]: return address | 1197 // esp[0]: return address |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 // haven't created the exception yet. Handle that in the runtime system. | 1461 // haven't created the exception yet. Handle that in the runtime system. |
| 1511 // TODO(592): Rerunning the RegExp to get the stack overflow exception. | 1462 // TODO(592): Rerunning the RegExp to get the stack overflow exception. |
| 1512 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | 1463 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
| 1513 isolate()); | 1464 isolate()); |
| 1514 __ mov(edx, Immediate(isolate()->factory()->the_hole_value())); | 1465 __ mov(edx, Immediate(isolate()->factory()->the_hole_value())); |
| 1515 __ mov(eax, Operand::StaticVariable(pending_exception)); | 1466 __ mov(eax, Operand::StaticVariable(pending_exception)); |
| 1516 __ cmp(edx, eax); | 1467 __ cmp(edx, eax); |
| 1517 __ j(equal, &runtime); | 1468 __ j(equal, &runtime); |
| 1518 | 1469 |
| 1519 // For exception, throw the exception again. | 1470 // For exception, throw the exception again. |
| 1520 __ EnterExitFrame(false); | 1471 __ TailCallRuntime(Runtime::kRegExpExecReThrow, 4, 1); |
| 1521 ThrowPendingException(masm); | |
| 1522 | 1472 |
| 1523 __ bind(&failure); | 1473 __ bind(&failure); |
| 1524 // For failure to match, return null. | 1474 // For failure to match, return null. |
| 1525 __ mov(eax, factory->null_value()); | 1475 __ mov(eax, factory->null_value()); |
| 1526 __ ret(4 * kPointerSize); | 1476 __ ret(4 * kPointerSize); |
| 1527 | 1477 |
| 1528 // Load RegExp data. | 1478 // Load RegExp data. |
| 1529 __ bind(&success); | 1479 __ bind(&success); |
| 1530 __ mov(eax, Operand(esp, kJSRegExpOffset)); | 1480 __ mov(eax, Operand(esp, kJSRegExpOffset)); |
| 1531 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); | 1481 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2569 __ bind(&okay); | 2519 __ bind(&okay); |
| 2570 __ pop(edx); | 2520 __ pop(edx); |
| 2571 } | 2521 } |
| 2572 | 2522 |
| 2573 // Exit the JavaScript to C++ exit frame. | 2523 // Exit the JavaScript to C++ exit frame. |
| 2574 __ LeaveExitFrame(save_doubles()); | 2524 __ LeaveExitFrame(save_doubles()); |
| 2575 __ ret(0); | 2525 __ ret(0); |
| 2576 | 2526 |
| 2577 // Handling of exception. | 2527 // Handling of exception. |
| 2578 __ bind(&exception_returned); | 2528 __ bind(&exception_returned); |
| 2579 ThrowPendingException(masm); | 2529 |
| 2530 ExternalReference pending_handler_context_address( |
| 2531 Isolate::kPendingHandlerContextAddress, isolate()); |
| 2532 ExternalReference pending_handler_code_address( |
| 2533 Isolate::kPendingHandlerCodeAddress, isolate()); |
| 2534 ExternalReference pending_handler_offset_address( |
| 2535 Isolate::kPendingHandlerOffsetAddress, isolate()); |
| 2536 ExternalReference pending_handler_fp_address( |
| 2537 Isolate::kPendingHandlerFPAddress, isolate()); |
| 2538 ExternalReference pending_handler_sp_address( |
| 2539 Isolate::kPendingHandlerSPAddress, isolate()); |
| 2540 |
| 2541 // Ask the runtime for help to determine the handler. This will set eax to |
| 2542 // contain the current pending exception, don't clobber it. |
| 2543 ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate()); |
| 2544 { |
| 2545 FrameScope scope(masm, StackFrame::MANUAL); |
| 2546 __ PrepareCallCFunction(3, eax); |
| 2547 __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc. |
| 2548 __ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv. |
| 2549 __ mov(Operand(esp, 2 * kPointerSize), |
| 2550 Immediate(ExternalReference::isolate_address(isolate()))); |
| 2551 __ CallCFunction(find_handler, 3); |
| 2552 } |
| 2553 |
| 2554 // Retrieve the handler context, SP and FP. |
| 2555 __ mov(esi, Operand::StaticVariable(pending_handler_context_address)); |
| 2556 __ mov(esp, Operand::StaticVariable(pending_handler_sp_address)); |
| 2557 __ mov(ebp, Operand::StaticVariable(pending_handler_fp_address)); |
| 2558 |
| 2559 // If the handler is a JS frame, restore the context to the frame. |
| 2560 // (kind == ENTRY) == (ebp == 0) == (esi == 0), so we could test either |
| 2561 // ebp or esi. |
| 2562 Label skip; |
| 2563 __ test(esi, esi); |
| 2564 __ j(zero, &skip, Label::kNear); |
| 2565 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi); |
| 2566 __ bind(&skip); |
| 2567 |
| 2568 // Compute the handler entry address and jump to it. |
| 2569 __ mov(edi, Operand::StaticVariable(pending_handler_code_address)); |
| 2570 __ mov(edx, Operand::StaticVariable(pending_handler_offset_address)); |
| 2571 __ lea(edi, FieldOperand(edi, edx, times_1, Code::kHeaderSize)); |
| 2572 __ jmp(edi); |
| 2580 } | 2573 } |
| 2581 | 2574 |
| 2582 | 2575 |
| 2583 void JSEntryStub::Generate(MacroAssembler* masm) { | 2576 void JSEntryStub::Generate(MacroAssembler* masm) { |
| 2584 Label invoke, handler_entry, exit; | 2577 Label invoke, handler_entry, exit; |
| 2585 Label not_outermost_js, not_outermost_js_2; | 2578 Label not_outermost_js, not_outermost_js_2; |
| 2586 | 2579 |
| 2587 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 2580 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 2588 | 2581 |
| 2589 // Set up frame. | 2582 // Set up frame. |
| (...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5406 ApiParameterOperand(2), kStackSpace, nullptr, | 5399 ApiParameterOperand(2), kStackSpace, nullptr, |
| 5407 Operand(ebp, 7 * kPointerSize), NULL); | 5400 Operand(ebp, 7 * kPointerSize), NULL); |
| 5408 } | 5401 } |
| 5409 | 5402 |
| 5410 | 5403 |
| 5411 #undef __ | 5404 #undef __ |
| 5412 | 5405 |
| 5413 } } // namespace v8::internal | 5406 } } // namespace v8::internal |
| 5414 | 5407 |
| 5415 #endif // V8_TARGET_ARCH_IA32 | 5408 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |