Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 965423002: Simplify re-throwing in RegExpExecStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_trycatch-8
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 __ mov(Operand(esp, 2 * kPointerSize), ecx); 1177 __ mov(Operand(esp, 2 * kPointerSize), ecx);
1178 __ lea(edx, Operand(edx, ecx, times_2, 1178 __ lea(edx, Operand(edx, ecx, times_2,
1179 StandardFrameConstants::kCallerSPOffset)); 1179 StandardFrameConstants::kCallerSPOffset));
1180 __ mov(Operand(esp, 3 * kPointerSize), edx); 1180 __ mov(Operand(esp, 3 * kPointerSize), edx);
1181 1181
1182 __ bind(&runtime); 1182 __ bind(&runtime);
1183 __ TailCallRuntime(Runtime::kNewRestParam, 3, 1); 1183 __ TailCallRuntime(Runtime::kNewRestParam, 3, 1);
1184 } 1184 }
1185 1185
1186 1186
1187 static void ThrowPendingException(MacroAssembler* masm) {
1188 Isolate* isolate = masm->isolate();
1189
1190 ExternalReference pending_handler_context_address(
1191 Isolate::kPendingHandlerContextAddress, isolate);
1192 ExternalReference pending_handler_code_address(
1193 Isolate::kPendingHandlerCodeAddress, isolate);
1194 ExternalReference pending_handler_offset_address(
1195 Isolate::kPendingHandlerOffsetAddress, isolate);
1196 ExternalReference pending_handler_fp_address(
1197 Isolate::kPendingHandlerFPAddress, isolate);
1198 ExternalReference pending_handler_sp_address(
1199 Isolate::kPendingHandlerSPAddress, isolate);
1200
1201 // Ask the runtime for help to determine the handler. This will set eax to
1202 // contain the current pending exception, don't clobber it.
1203 ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate);
1204 __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc.
1205 __ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv.
1206 __ mov(Operand(esp, 2 * kPointerSize),
1207 Immediate(ExternalReference::isolate_address(isolate)));
1208 __ mov(ebx, Immediate(find_handler));
1209 __ call(ebx);
1210
1211 // Retrieve the handler context, SP and FP.
1212 __ mov(esi, Operand::StaticVariable(pending_handler_context_address));
1213 __ mov(esp, Operand::StaticVariable(pending_handler_sp_address));
1214 __ mov(ebp, Operand::StaticVariable(pending_handler_fp_address));
1215
1216 // If the handler is a JS frame, restore the context to the frame.
1217 // (kind == ENTRY) == (ebp == 0) == (esi == 0), so we could test either
1218 // ebp or esi.
1219 Label skip;
1220 __ test(esi, esi);
1221 __ j(zero, &skip, Label::kNear);
1222 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi);
1223 __ bind(&skip);
1224
1225 // Compute the handler entry address and jump to it.
1226 __ mov(edi, Operand::StaticVariable(pending_handler_code_address));
1227 __ mov(edx, Operand::StaticVariable(pending_handler_offset_address));
1228 __ lea(edi, FieldOperand(edi, edx, times_1, Code::kHeaderSize));
1229 __ jmp(edi);
1230 }
1231
1232
1233 void RegExpExecStub::Generate(MacroAssembler* masm) { 1187 void RegExpExecStub::Generate(MacroAssembler* masm) {
1234 // Just jump directly to runtime if native RegExp is not selected at compile 1188 // Just jump directly to runtime if native RegExp is not selected at compile
1235 // time or if regexp entry in generated code is turned off runtime switch or 1189 // time or if regexp entry in generated code is turned off runtime switch or
1236 // at compilation. 1190 // at compilation.
1237 #ifdef V8_INTERPRETED_REGEXP 1191 #ifdef V8_INTERPRETED_REGEXP
1238 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); 1192 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1);
1239 #else // V8_INTERPRETED_REGEXP 1193 #else // V8_INTERPRETED_REGEXP
1240 1194
1241 // Stack frame on entry. 1195 // Stack frame on entry.
1242 // esp[0]: return address 1196 // esp[0]: return address
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 // stack overflow (on the backtrack stack) was detected in RegExp code but 1459 // stack overflow (on the backtrack stack) was detected in RegExp code but
1506 // haven't created the exception yet. Handle that in the runtime system. 1460 // haven't created the exception yet. Handle that in the runtime system.
1507 // TODO(592): Rerunning the RegExp to get the stack overflow exception. 1461 // TODO(592): Rerunning the RegExp to get the stack overflow exception.
1508 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, 1462 ExternalReference pending_exception(Isolate::kPendingExceptionAddress,
1509 isolate()); 1463 isolate());
1510 __ mov(edx, Immediate(isolate()->factory()->the_hole_value())); 1464 __ mov(edx, Immediate(isolate()->factory()->the_hole_value()));
1511 __ mov(eax, Operand::StaticVariable(pending_exception)); 1465 __ mov(eax, Operand::StaticVariable(pending_exception));
1512 __ cmp(edx, eax); 1466 __ cmp(edx, eax);
1513 __ j(equal, &runtime); 1467 __ j(equal, &runtime);
1514 1468
1469 // Clear the pending exception variable.
1470 __ mov(Operand::StaticVariable(pending_exception), edx);
1471
1515 // For exception, throw the exception again. 1472 // For exception, throw the exception again.
1516 __ EnterExitFrame(false); 1473 {
1517 ThrowPendingException(masm); 1474 FrameScope frame(masm, StackFrame::INTERNAL);
1475 __ push(eax); // Exception.
1476 __ CallRuntime(Runtime::kReThrow, 1);
1477 __ int3(); // Unreachable.
1478 }
1518 1479
1519 __ bind(&failure); 1480 __ bind(&failure);
1520 // For failure to match, return null. 1481 // For failure to match, return null.
1521 __ mov(eax, factory->null_value()); 1482 __ mov(eax, factory->null_value());
1522 __ ret(4 * kPointerSize); 1483 __ ret(4 * kPointerSize);
1523 1484
1524 // Load RegExp data. 1485 // Load RegExp data.
1525 __ bind(&success); 1486 __ bind(&success);
1526 __ mov(eax, Operand(esp, kJSRegExpOffset)); 1487 __ mov(eax, Operand(esp, kJSRegExpOffset));
1527 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); 1488 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset));
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 __ bind(&okay); 2525 __ bind(&okay);
2565 __ pop(edx); 2526 __ pop(edx);
2566 } 2527 }
2567 2528
2568 // Exit the JavaScript to C++ exit frame. 2529 // Exit the JavaScript to C++ exit frame.
2569 __ LeaveExitFrame(save_doubles()); 2530 __ LeaveExitFrame(save_doubles());
2570 __ ret(0); 2531 __ ret(0);
2571 2532
2572 // Handling of exception. 2533 // Handling of exception.
2573 __ bind(&exception_returned); 2534 __ bind(&exception_returned);
2574 ThrowPendingException(masm); 2535
2536 ExternalReference pending_handler_context_address(
2537 Isolate::kPendingHandlerContextAddress, isolate());
2538 ExternalReference pending_handler_code_address(
2539 Isolate::kPendingHandlerCodeAddress, isolate());
2540 ExternalReference pending_handler_offset_address(
2541 Isolate::kPendingHandlerOffsetAddress, isolate());
2542 ExternalReference pending_handler_fp_address(
2543 Isolate::kPendingHandlerFPAddress, isolate());
2544 ExternalReference pending_handler_sp_address(
2545 Isolate::kPendingHandlerSPAddress, isolate());
2546
2547 // Ask the runtime for help to determine the handler. This will set eax to
2548 // contain the current pending exception, don't clobber it.
2549 ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate());
2550 __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc.
2551 __ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv.
2552 __ mov(Operand(esp, 2 * kPointerSize),
2553 Immediate(ExternalReference::isolate_address(isolate())));
2554 __ mov(ebx, Immediate(find_handler));
2555 __ call(ebx);
2556
2557 // Retrieve the handler context, SP and FP.
2558 __ mov(esi, Operand::StaticVariable(pending_handler_context_address));
2559 __ mov(esp, Operand::StaticVariable(pending_handler_sp_address));
2560 __ mov(ebp, Operand::StaticVariable(pending_handler_fp_address));
2561
2562 // If the handler is a JS frame, restore the context to the frame.
2563 // (kind == ENTRY) == (ebp == 0) == (esi == 0), so we could test either
2564 // ebp or esi.
2565 Label skip;
2566 __ test(esi, esi);
2567 __ j(zero, &skip, Label::kNear);
2568 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi);
2569 __ bind(&skip);
2570
2571 // Compute the handler entry address and jump to it.
2572 __ mov(edi, Operand::StaticVariable(pending_handler_code_address));
2573 __ mov(edx, Operand::StaticVariable(pending_handler_offset_address));
2574 __ lea(edi, FieldOperand(edi, edx, times_1, Code::kHeaderSize));
2575 __ jmp(edi);
2575 } 2576 }
2576 2577
2577 2578
2578 void JSEntryStub::Generate(MacroAssembler* masm) { 2579 void JSEntryStub::Generate(MacroAssembler* masm) {
2579 Label invoke, handler_entry, exit; 2580 Label invoke, handler_entry, exit;
2580 Label not_outermost_js, not_outermost_js_2; 2581 Label not_outermost_js, not_outermost_js_2;
2581 2582
2582 ProfileEntryHookStub::MaybeCallEntryHook(masm); 2583 ProfileEntryHookStub::MaybeCallEntryHook(masm);
2583 2584
2584 // Set up frame. 2585 // Set up frame.
(...skipping 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after
5153 ApiParameterOperand(2), kStackSpace, nullptr, 5154 ApiParameterOperand(2), kStackSpace, nullptr,
5154 Operand(ebp, 7 * kPointerSize), NULL); 5155 Operand(ebp, 7 * kPointerSize), NULL);
5155 } 5156 }
5156 5157
5157 5158
5158 #undef __ 5159 #undef __
5159 5160
5160 } } // namespace v8::internal 5161 } } // namespace v8::internal
5161 5162
5162 #endif // V8_TARGET_ARCH_IA32 5163 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698