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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 // Open a frame scope to indicate that there is a frame on the stack. The | 625 // Open a frame scope to indicate that there is a frame on the stack. The |
626 // MANUAL indicates that the scope shouldn't actually generate code to set up | 626 // MANUAL indicates that the scope shouldn't actually generate code to set up |
627 // the frame (that is done below). | 627 // the frame (that is done below). |
628 FrameScope frame_scope(masm, StackFrame::MANUAL); | 628 FrameScope frame_scope(masm, StackFrame::MANUAL); |
629 __ pushq(rbp); // Caller's frame pointer. | 629 __ pushq(rbp); // Caller's frame pointer. |
630 __ movp(rbp, rsp); | 630 __ movp(rbp, rsp); |
631 __ Push(rsi); // Callee's context. | 631 __ Push(rsi); // Callee's context. |
632 __ Push(rdi); // Callee's JS function. | 632 __ Push(rdi); // Callee's JS function. |
633 __ Push(rdx); // Callee's new target. | 633 __ Push(rdx); // Callee's new target. |
634 | 634 |
635 // Get the bytecode array from the function object and load the pointer to the | 635 // Get the bytecode array from the function object (or from the DebugInfo if |
636 // first entry into edi (InterpreterBytecodeRegister). | 636 // it is present) and load it into kInterpreterBytecodeArrayRegister. |
637 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 637 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
638 | |
639 Label load_debug_bytecode_array, bytecode_array_loaded; | 638 Label load_debug_bytecode_array, bytecode_array_loaded; |
640 DCHECK_EQ(Smi::FromInt(0), DebugInfo::uninitialized()); | 639 DCHECK_EQ(Smi::FromInt(0), DebugInfo::uninitialized()); |
641 __ cmpp(FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset), | 640 __ cmpp(FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset), |
642 Immediate(0)); | 641 Immediate(0)); |
643 __ j(not_equal, &load_debug_bytecode_array); | 642 __ j(not_equal, &load_debug_bytecode_array); |
644 __ movp(kInterpreterBytecodeArrayRegister, | 643 __ movp(kInterpreterBytecodeArrayRegister, |
645 FieldOperand(rax, SharedFunctionInfo::kFunctionDataOffset)); | 644 FieldOperand(rax, SharedFunctionInfo::kFunctionDataOffset)); |
646 __ bind(&bytecode_array_loaded); | 645 __ bind(&bytecode_array_loaded); |
647 | 646 |
| 647 // Check function data field is actually a BytecodeArray object. |
| 648 Label bytecode_array_not_present; |
| 649 __ CompareRoot(kInterpreterBytecodeArrayRegister, |
| 650 Heap::kUndefinedValueRootIndex); |
| 651 __ j(equal, &bytecode_array_not_present); |
648 if (FLAG_debug_code) { | 652 if (FLAG_debug_code) { |
649 // Check function data field is actually a BytecodeArray object. | |
650 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 653 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
651 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 654 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
652 rax); | 655 rax); |
653 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 656 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
654 } | 657 } |
655 | 658 |
656 // Push bytecode array. | 659 // Push bytecode array. |
657 __ Push(kInterpreterBytecodeArrayRegister); | 660 __ Push(kInterpreterBytecodeArrayRegister); |
658 // Push zero for bytecode array offset. | 661 // Push zero for bytecode array offset. |
659 __ Push(Immediate(0)); | 662 __ Push(Immediate(0)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 // Even though the first bytecode handler was called, we will never return. | 711 // Even though the first bytecode handler was called, we will never return. |
709 __ Abort(kUnexpectedReturnFromBytecodeHandler); | 712 __ Abort(kUnexpectedReturnFromBytecodeHandler); |
710 | 713 |
711 // Load debug copy of the bytecode array. | 714 // Load debug copy of the bytecode array. |
712 __ bind(&load_debug_bytecode_array); | 715 __ bind(&load_debug_bytecode_array); |
713 Register debug_info = kInterpreterBytecodeArrayRegister; | 716 Register debug_info = kInterpreterBytecodeArrayRegister; |
714 __ movp(debug_info, FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset)); | 717 __ movp(debug_info, FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset)); |
715 __ movp(kInterpreterBytecodeArrayRegister, | 718 __ movp(kInterpreterBytecodeArrayRegister, |
716 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 719 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
717 __ jmp(&bytecode_array_loaded); | 720 __ jmp(&bytecode_array_loaded); |
| 721 |
| 722 // If the bytecode array is no longer present, then the underlying function |
| 723 // has been switched to a different kind of code and we heal the closure by |
| 724 // switching the code entry field over to the new code object as well. |
| 725 __ bind(&bytecode_array_not_present); |
| 726 __ leave(); // Leave the frame so we can tail call. |
| 727 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 728 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset)); |
| 729 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); |
| 730 __ movp(FieldOperand(rdi, JSFunction::kCodeEntryOffset), rcx); |
| 731 __ RecordWriteCodeEntryField(rdi, rcx, r15); |
| 732 __ jmp(rcx); |
718 } | 733 } |
719 | 734 |
720 | 735 |
721 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 736 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
722 // The return value is in accumulator, which is already in rax. | 737 // The return value is in accumulator, which is already in rax. |
723 | 738 |
724 // Leave the frame (also dropping the register file). | 739 // Leave the frame (also dropping the register file). |
725 __ leave(); | 740 __ leave(); |
726 | 741 |
727 // Drop receiver + arguments and return. | 742 // Drop receiver + arguments and return. |
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2917 __ ret(0); | 2932 __ ret(0); |
2918 } | 2933 } |
2919 | 2934 |
2920 | 2935 |
2921 #undef __ | 2936 #undef __ |
2922 | 2937 |
2923 } // namespace internal | 2938 } // namespace internal |
2924 } // namespace v8 | 2939 } // namespace v8 |
2925 | 2940 |
2926 #endif // V8_TARGET_ARCH_X64 | 2941 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |