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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 656 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
657 Label load_debug_bytecode_array, bytecode_array_loaded; | 657 Label load_debug_bytecode_array, bytecode_array_loaded; |
658 DCHECK_EQ(Smi::FromInt(0), DebugInfo::uninitialized()); | 658 DCHECK_EQ(Smi::FromInt(0), DebugInfo::uninitialized()); |
659 __ cmpp(FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset), | 659 __ cmpp(FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset), |
660 Immediate(0)); | 660 Immediate(0)); |
661 __ j(not_equal, &load_debug_bytecode_array); | 661 __ j(not_equal, &load_debug_bytecode_array); |
662 __ movp(kInterpreterBytecodeArrayRegister, | 662 __ movp(kInterpreterBytecodeArrayRegister, |
663 FieldOperand(rax, SharedFunctionInfo::kFunctionDataOffset)); | 663 FieldOperand(rax, SharedFunctionInfo::kFunctionDataOffset)); |
664 __ bind(&bytecode_array_loaded); | 664 __ bind(&bytecode_array_loaded); |
665 | 665 |
| 666 // Check whether we should continue to use the interpreter. |
| 667 Label switch_to_different_code_kind; |
| 668 __ Move(rcx, masm->CodeObject()); // Self-reference to this code. |
| 669 __ cmpp(rcx, FieldOperand(rax, SharedFunctionInfo::kCodeOffset)); |
| 670 __ j(not_equal, &switch_to_different_code_kind); |
| 671 |
666 // Check function data field is actually a BytecodeArray object. | 672 // Check function data field is actually a BytecodeArray object. |
667 Label bytecode_array_not_present; | |
668 __ CompareRoot(kInterpreterBytecodeArrayRegister, | |
669 Heap::kUndefinedValueRootIndex); | |
670 __ j(equal, &bytecode_array_not_present); | |
671 if (FLAG_debug_code) { | 673 if (FLAG_debug_code) { |
672 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 674 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
673 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 675 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
674 rax); | 676 rax); |
675 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 677 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
676 } | 678 } |
677 | 679 |
678 // Load initial bytecode offset. | 680 // Load initial bytecode offset. |
679 __ movp(kInterpreterBytecodeOffsetRegister, | 681 __ movp(kInterpreterBytecodeOffsetRegister, |
680 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 682 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 __ ret(0); | 734 __ ret(0); |
733 | 735 |
734 // Load debug copy of the bytecode array. | 736 // Load debug copy of the bytecode array. |
735 __ bind(&load_debug_bytecode_array); | 737 __ bind(&load_debug_bytecode_array); |
736 Register debug_info = kInterpreterBytecodeArrayRegister; | 738 Register debug_info = kInterpreterBytecodeArrayRegister; |
737 __ movp(debug_info, FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset)); | 739 __ movp(debug_info, FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset)); |
738 __ movp(kInterpreterBytecodeArrayRegister, | 740 __ movp(kInterpreterBytecodeArrayRegister, |
739 FieldOperand(debug_info, DebugInfo::kDebugBytecodeArrayIndex)); | 741 FieldOperand(debug_info, DebugInfo::kDebugBytecodeArrayIndex)); |
740 __ jmp(&bytecode_array_loaded); | 742 __ jmp(&bytecode_array_loaded); |
741 | 743 |
742 // If the bytecode array is no longer present, then the underlying function | 744 // If the shared code is no longer this entry trampoline, then the underlying |
743 // has been switched to a different kind of code and we heal the closure by | 745 // function has been switched to a different kind of code and we heal the |
744 // switching the code entry field over to the new code object as well. | 746 // closure by switching the code entry field over to the new code as well. |
745 __ bind(&bytecode_array_not_present); | 747 __ bind(&switch_to_different_code_kind); |
746 __ leave(); // Leave the frame so we can tail call. | 748 __ leave(); // Leave the frame so we can tail call. |
747 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 749 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
748 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset)); | 750 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset)); |
749 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); | 751 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); |
750 __ movp(FieldOperand(rdi, JSFunction::kCodeEntryOffset), rcx); | 752 __ movp(FieldOperand(rdi, JSFunction::kCodeEntryOffset), rcx); |
751 __ RecordWriteCodeEntryField(rdi, rcx, r15); | 753 __ RecordWriteCodeEntryField(rdi, rcx, r15); |
752 __ jmp(rcx); | 754 __ jmp(rcx); |
753 } | 755 } |
754 | 756 |
755 void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { | 757 void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { |
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3075 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3074 Generate_OnStackReplacementHelper(masm, true); | 3076 Generate_OnStackReplacementHelper(masm, true); |
3075 } | 3077 } |
3076 | 3078 |
3077 #undef __ | 3079 #undef __ |
3078 | 3080 |
3079 } // namespace internal | 3081 } // namespace internal |
3080 } // namespace v8 | 3082 } // namespace v8 |
3081 | 3083 |
3082 #endif // V8_TARGET_ARCH_X64 | 3084 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |