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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 __ mov(eax, Operand(esp, -kPointerSize)); | 752 __ mov(eax, Operand(esp, -kPointerSize)); |
753 | 753 |
754 // Re-push return address. | 754 // Re-push return address. |
755 __ Push(ecx); | 755 __ Push(ecx); |
756 | 756 |
757 // Call the constructor with unmodified eax, edi, ebi values. | 757 // Call the constructor with unmodified eax, edi, ebi values. |
758 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 758 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
759 } | 759 } |
760 | 760 |
761 | 761 |
762 static void Generate_InterpreterNotifyDeoptimizedHelper( | 762 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { |
763 MacroAssembler* masm, Deoptimizer::BailoutType type) { | |
764 // Enter an internal frame. | |
765 { | |
766 FrameScope scope(masm, StackFrame::INTERNAL); | |
767 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register. | |
768 | |
769 // Pass the deoptimization type to the runtime system. | |
770 __ Push(Smi::FromInt(static_cast<int>(type))); | |
771 | |
772 __ CallRuntime(Runtime::kNotifyDeoptimized); | |
773 | |
774 __ Pop(kInterpreterAccumulatorRegister); // Restore accumulator register. | |
775 // Tear down internal frame. | |
776 } | |
777 | |
778 // Initialize register file register. | 763 // Initialize register file register. |
779 __ mov(kInterpreterRegisterFileRegister, ebp); | 764 __ mov(kInterpreterRegisterFileRegister, ebp); |
780 __ add(kInterpreterRegisterFileRegister, | 765 __ add(kInterpreterRegisterFileRegister, |
781 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | 766 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); |
782 | 767 |
783 // Get the bytecode array pointer from the frame. | 768 // Get the bytecode array pointer from the frame. |
784 __ mov(ebx, Operand(kInterpreterRegisterFileRegister, | 769 __ mov(ebx, Operand(kInterpreterRegisterFileRegister, |
785 InterpreterFrameConstants::kFunctionFromRegisterPointer)); | 770 InterpreterFrameConstants::kFunctionFromRegisterPointer)); |
786 __ mov(ebx, FieldOperand(ebx, JSFunction::kSharedFunctionInfoOffset)); | 771 __ mov(ebx, FieldOperand(ebx, JSFunction::kSharedFunctionInfoOffset)); |
787 __ mov(kInterpreterBytecodeArrayRegister, | 772 __ mov(kInterpreterBytecodeArrayRegister, |
788 FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset)); | 773 FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset)); |
789 | 774 |
790 if (FLAG_debug_code) { | 775 if (FLAG_debug_code) { |
791 // Check function data field is actually a BytecodeArray object. | 776 // Check function data field is actually a BytecodeArray object. |
792 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 777 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
793 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 778 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
794 ebx); | 779 ebx); |
795 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 780 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
796 } | 781 } |
797 | 782 |
798 // Get the target bytecode offset from the frame. | 783 // Get the target bytecode offset from the frame. |
799 __ mov( | 784 __ mov( |
800 kInterpreterBytecodeOffsetRegister, | 785 kInterpreterBytecodeOffsetRegister, |
801 Operand(kInterpreterRegisterFileRegister, | 786 Operand(kInterpreterRegisterFileRegister, |
802 InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer)); | 787 InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer)); |
803 __ SmiUntag(kInterpreterBytecodeOffsetRegister); | 788 __ SmiUntag(kInterpreterBytecodeOffsetRegister); |
804 | 789 |
805 // Push dispatch table as a stack located parameter to the bytecode handler - | 790 // Push dispatch table as a stack located parameter to the bytecode handler. |
806 // overwrite the state slot (we don't use these for interpreter deopts). | |
807 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); | 791 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); |
808 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); | 792 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); |
809 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); | 793 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); |
810 __ mov(Operand(esp, kPointerSize), ebx); | 794 __ Pop(esi); |
| 795 __ Push(ebx); |
| 796 __ Push(esi); |
811 | 797 |
812 // Dispatch to the target bytecode. | 798 // Dispatch to the target bytecode. |
813 __ movzx_b(esi, Operand(kInterpreterBytecodeArrayRegister, | 799 __ movzx_b(esi, Operand(kInterpreterBytecodeArrayRegister, |
814 kInterpreterBytecodeOffsetRegister, times_1, 0)); | 800 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
815 __ mov(ebx, Operand(ebx, esi, times_pointer_size, 0)); | 801 __ mov(ebx, Operand(ebx, esi, times_pointer_size, 0)); |
816 | 802 |
817 // Get the context from the frame. | 803 // Get the context from the frame. |
818 // TODO(rmcilroy): Update interpreter frame to expect current context at the | 804 // TODO(rmcilroy): Update interpreter frame to expect current context at the |
819 // context slot instead of the function context. | 805 // context slot instead of the function context. |
820 __ mov(kContextRegister, | 806 __ mov(kContextRegister, |
821 Operand(kInterpreterRegisterFileRegister, | 807 Operand(kInterpreterRegisterFileRegister, |
822 InterpreterFrameConstants::kContextFromRegisterPointer)); | 808 InterpreterFrameConstants::kContextFromRegisterPointer)); |
823 | 809 |
824 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging | 810 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging |
825 // and header removal. | 811 // and header removal. |
826 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 812 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
827 __ jmp(ebx); | 813 __ jmp(ebx); |
828 } | 814 } |
829 | 815 |
830 | 816 |
| 817 static void Generate_InterpreterNotifyDeoptimizedHelper( |
| 818 MacroAssembler* masm, Deoptimizer::BailoutType type) { |
| 819 // Enter an internal frame. |
| 820 { |
| 821 FrameScope scope(masm, StackFrame::INTERNAL); |
| 822 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register. |
| 823 |
| 824 // Pass the deoptimization type to the runtime system. |
| 825 __ Push(Smi::FromInt(static_cast<int>(type))); |
| 826 |
| 827 __ CallRuntime(Runtime::kNotifyDeoptimized); |
| 828 |
| 829 __ Pop(kInterpreterAccumulatorRegister); // Restore accumulator register. |
| 830 // Tear down internal frame. |
| 831 } |
| 832 |
| 833 // Drop state (we don't use these for interpreter deopts) and push PC at top |
| 834 // of stack (to simulate initial call to bytecode handler in interpreter entry |
| 835 // trampoline). |
| 836 __ Pop(ebx); |
| 837 __ Drop(1); |
| 838 __ Push(ebx); |
| 839 |
| 840 // Enter the bytecode dispatch. |
| 841 Generate_EnterBytecodeDispatch(masm); |
| 842 } |
| 843 |
| 844 |
831 void Builtins::Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm) { | 845 void Builtins::Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm) { |
832 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); | 846 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); |
833 } | 847 } |
834 | 848 |
835 | 849 |
836 void Builtins::Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm) { | 850 void Builtins::Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm) { |
837 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 851 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
838 } | 852 } |
839 | 853 |
840 | 854 |
841 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { | 855 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { |
842 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 856 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
843 } | 857 } |
844 | 858 |
845 | 859 |
| 860 void Builtins::Generate_InterpreterEnterExceptionHandler(MacroAssembler* masm) { |
| 861 Generate_EnterBytecodeDispatch(masm); |
| 862 } |
| 863 |
| 864 |
846 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 865 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
847 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 866 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
848 GenerateTailCallToReturnedCode(masm); | 867 GenerateTailCallToReturnedCode(masm); |
849 } | 868 } |
850 | 869 |
851 | 870 |
852 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 871 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
853 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 872 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
854 GenerateTailCallToReturnedCode(masm); | 873 GenerateTailCallToReturnedCode(masm); |
855 } | 874 } |
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2526 | 2545 |
2527 __ bind(&ok); | 2546 __ bind(&ok); |
2528 __ ret(0); | 2547 __ ret(0); |
2529 } | 2548 } |
2530 | 2549 |
2531 #undef __ | 2550 #undef __ |
2532 } // namespace internal | 2551 } // namespace internal |
2533 } // namespace v8 | 2552 } // namespace v8 |
2534 | 2553 |
2535 #endif // V8_TARGET_ARCH_X87 | 2554 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |