| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 __ Move(arg_reg_3, ExternalReference::isolate_address(isolate())); | 2465 __ Move(arg_reg_3, ExternalReference::isolate_address(isolate())); |
| 2466 __ PrepareCallCFunction(3); | 2466 __ PrepareCallCFunction(3); |
| 2467 __ CallCFunction(find_handler, 3); | 2467 __ CallCFunction(find_handler, 3); |
| 2468 } | 2468 } |
| 2469 | 2469 |
| 2470 // Retrieve the handler context, SP and FP. | 2470 // Retrieve the handler context, SP and FP. |
| 2471 __ movp(rsi, masm->ExternalOperand(pending_handler_context_address)); | 2471 __ movp(rsi, masm->ExternalOperand(pending_handler_context_address)); |
| 2472 __ movp(rsp, masm->ExternalOperand(pending_handler_sp_address)); | 2472 __ movp(rsp, masm->ExternalOperand(pending_handler_sp_address)); |
| 2473 __ movp(rbp, masm->ExternalOperand(pending_handler_fp_address)); | 2473 __ movp(rbp, masm->ExternalOperand(pending_handler_fp_address)); |
| 2474 | 2474 |
| 2475 // If the handler is a JS frame, restore the context to the frame. | 2475 // If the handler is a JS frame, restore the context to the frame. Note that |
| 2476 // (kind == ENTRY) == (rbp == 0) == (rsi == 0), so we could test either | 2476 // the context will be set to (rsi == 0) for non-JS frames. |
| 2477 // rbp or rsi. | |
| 2478 Label skip; | 2477 Label skip; |
| 2479 __ testp(rsi, rsi); | 2478 __ testp(rsi, rsi); |
| 2480 __ j(zero, &skip, Label::kNear); | 2479 __ j(zero, &skip, Label::kNear); |
| 2481 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); | 2480 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); |
| 2482 __ bind(&skip); | 2481 __ bind(&skip); |
| 2483 | 2482 |
| 2484 // Compute the handler entry address and jump to it. | 2483 // Compute the handler entry address and jump to it. |
| 2485 __ movp(rdi, masm->ExternalOperand(pending_handler_code_address)); | 2484 __ movp(rdi, masm->ExternalOperand(pending_handler_code_address)); |
| 2486 __ movp(rdx, masm->ExternalOperand(pending_handler_offset_address)); | 2485 __ movp(rdx, masm->ExternalOperand(pending_handler_offset_address)); |
| 2487 __ leap(rdi, FieldOperand(rdi, rdx, times_1, Code::kHeaderSize)); | 2486 __ leap(rdi, FieldOperand(rdi, rdx, times_1, Code::kHeaderSize)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 __ bind(&handler_entry); | 2566 __ bind(&handler_entry); |
| 2568 handler_offset_ = handler_entry.pos(); | 2567 handler_offset_ = handler_entry.pos(); |
| 2569 // Caught exception: Store result (exception) in the pending exception | 2568 // Caught exception: Store result (exception) in the pending exception |
| 2570 // field in the JSEnv and return a failure sentinel. | 2569 // field in the JSEnv and return a failure sentinel. |
| 2571 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | 2570 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
| 2572 isolate()); | 2571 isolate()); |
| 2573 __ Store(pending_exception, rax); | 2572 __ Store(pending_exception, rax); |
| 2574 __ LoadRoot(rax, Heap::kExceptionRootIndex); | 2573 __ LoadRoot(rax, Heap::kExceptionRootIndex); |
| 2575 __ jmp(&exit); | 2574 __ jmp(&exit); |
| 2576 | 2575 |
| 2577 // Invoke: Link this frame into the handler chain. There's only one | 2576 // Invoke: Link this frame into the handler chain. |
| 2578 // handler block in this code object, so its index is 0. | |
| 2579 __ bind(&invoke); | 2577 __ bind(&invoke); |
| 2580 __ PushTryHandler(StackHandler::JS_ENTRY, 0); | 2578 __ PushStackHandler(); |
| 2581 | 2579 |
| 2582 // Clear any pending exceptions. | 2580 // Clear any pending exceptions. |
| 2583 __ LoadRoot(rax, Heap::kTheHoleValueRootIndex); | 2581 __ LoadRoot(rax, Heap::kTheHoleValueRootIndex); |
| 2584 __ Store(pending_exception, rax); | 2582 __ Store(pending_exception, rax); |
| 2585 | 2583 |
| 2586 // Fake a receiver (NULL). | 2584 // Fake a receiver (NULL). |
| 2587 __ Push(Immediate(0)); // receiver | 2585 __ Push(Immediate(0)); // receiver |
| 2588 | 2586 |
| 2589 // Invoke the function by calling through JS entry trampoline builtin and | 2587 // Invoke the function by calling through JS entry trampoline builtin and |
| 2590 // pop the faked function when we return. We load the address from an | 2588 // pop the faked function when we return. We load the address from an |
| 2591 // external reference instead of inlining the call target address directly | 2589 // external reference instead of inlining the call target address directly |
| 2592 // in the code, because the builtin stubs may not have been generated yet | 2590 // in the code, because the builtin stubs may not have been generated yet |
| 2593 // at the time this code is generated. | 2591 // at the time this code is generated. |
| 2594 if (type() == StackFrame::ENTRY_CONSTRUCT) { | 2592 if (type() == StackFrame::ENTRY_CONSTRUCT) { |
| 2595 ExternalReference construct_entry(Builtins::kJSConstructEntryTrampoline, | 2593 ExternalReference construct_entry(Builtins::kJSConstructEntryTrampoline, |
| 2596 isolate()); | 2594 isolate()); |
| 2597 __ Load(rax, construct_entry); | 2595 __ Load(rax, construct_entry); |
| 2598 } else { | 2596 } else { |
| 2599 ExternalReference entry(Builtins::kJSEntryTrampoline, isolate()); | 2597 ExternalReference entry(Builtins::kJSEntryTrampoline, isolate()); |
| 2600 __ Load(rax, entry); | 2598 __ Load(rax, entry); |
| 2601 } | 2599 } |
| 2602 __ leap(kScratchRegister, FieldOperand(rax, Code::kHeaderSize)); | 2600 __ leap(kScratchRegister, FieldOperand(rax, Code::kHeaderSize)); |
| 2603 __ call(kScratchRegister); | 2601 __ call(kScratchRegister); |
| 2604 | 2602 |
| 2605 // Unlink this frame from the handler chain. | 2603 // Unlink this frame from the handler chain. |
| 2606 __ PopTryHandler(); | 2604 __ PopStackHandler(); |
| 2607 | 2605 |
| 2608 __ bind(&exit); | 2606 __ bind(&exit); |
| 2609 // Check if the current stack frame is marked as the outermost JS frame. | 2607 // Check if the current stack frame is marked as the outermost JS frame. |
| 2610 __ Pop(rbx); | 2608 __ Pop(rbx); |
| 2611 __ Cmp(rbx, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)); | 2609 __ Cmp(rbx, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)); |
| 2612 __ j(not_equal, ¬_outermost_js_2); | 2610 __ j(not_equal, ¬_outermost_js_2); |
| 2613 __ Move(kScratchRegister, js_entry_sp); | 2611 __ Move(kScratchRegister, js_entry_sp); |
| 2614 __ movp(Operand(kScratchRegister, 0), Immediate(0)); | 2612 __ movp(Operand(kScratchRegister, 0), Immediate(0)); |
| 2615 __ bind(¬_outermost_js_2); | 2613 __ bind(¬_outermost_js_2); |
| 2616 | 2614 |
| (...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5360 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, | 5358 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, |
| 5361 kStackSpace, nullptr, return_value_operand, NULL); | 5359 kStackSpace, nullptr, return_value_operand, NULL); |
| 5362 } | 5360 } |
| 5363 | 5361 |
| 5364 | 5362 |
| 5365 #undef __ | 5363 #undef __ |
| 5366 | 5364 |
| 5367 } } // namespace v8::internal | 5365 } } // namespace v8::internal |
| 5368 | 5366 |
| 5369 #endif // V8_TARGET_ARCH_X64 | 5367 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |