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