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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 // Drop receiver + arguments and return. | 717 // Drop receiver + arguments and return. |
718 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, | 718 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, |
719 BytecodeArray::kParameterSizeOffset)); | 719 BytecodeArray::kParameterSizeOffset)); |
720 __ pop(ecx); | 720 __ pop(ecx); |
721 __ add(esp, ebx); | 721 __ add(esp, ebx); |
722 __ push(ecx); | 722 __ push(ecx); |
723 __ ret(0); | 723 __ ret(0); |
724 } | 724 } |
725 | 725 |
726 | 726 |
727 static void Generate_InterpreterPushArgs(MacroAssembler* masm, | |
728 Register array_limit) { | |
729 // ----------- S t a t e ------------- | |
730 // -- ebx : Pointer to the last argument in the args array. | |
731 // -- array_limit : Pointer to one before the first argument in the | |
732 // args array. | |
733 // ----------------------------------- | |
734 Label loop_header, loop_check; | |
735 __ jmp(&loop_check); | |
736 __ bind(&loop_header); | |
737 __ Push(Operand(ebx, 0)); | |
738 __ sub(ebx, Immediate(kPointerSize)); | |
739 __ bind(&loop_check); | |
740 __ cmp(ebx, array_limit); | |
741 __ j(greater, &loop_header, Label::kNear); | |
742 } | |
743 | |
744 | |
745 // static | 727 // static |
746 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { | 728 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
747 // ----------- S t a t e ------------- | 729 // ----------- S t a t e ------------- |
748 // -- eax : the number of arguments (not including the receiver) | 730 // -- eax : the number of arguments (not including the receiver) |
749 // -- ebx : the address of the first argument to be pushed. Subsequent | 731 // -- ebx : the address of the first argument to be pushed. Subsequent |
750 // arguments should be consecutive above this, in the same order as | 732 // arguments should be consecutive above this, in the same order as |
751 // they are to be pushed onto the stack. | 733 // they are to be pushed onto the stack. |
752 // -- edi : the target to call (can be any Object). | 734 // -- edi : the target to call (can be any Object). |
753 // ----------------------------------- | |
754 | 735 |
755 // Pop return address to allow tail-call after pushing arguments. | 736 // Pop return address to allow tail-call after pushing arguments. |
756 __ Pop(edx); | 737 __ Pop(edx); |
757 | 738 |
758 // Find the address of the last argument. | 739 // Find the address of the last argument. |
759 __ mov(ecx, eax); | 740 __ mov(ecx, eax); |
760 __ add(ecx, Immediate(1)); // Add one for receiver. | 741 __ add(ecx, Immediate(1)); // Add one for receiver. |
761 __ shl(ecx, kPointerSizeLog2); | 742 __ shl(ecx, kPointerSizeLog2); |
762 __ neg(ecx); | 743 __ neg(ecx); |
763 __ add(ecx, ebx); | 744 __ add(ecx, ebx); |
764 | 745 |
765 Generate_InterpreterPushArgs(masm, ecx); | 746 // Push the arguments. |
| 747 Label loop_header, loop_check; |
| 748 __ jmp(&loop_check); |
| 749 __ bind(&loop_header); |
| 750 __ Push(Operand(ebx, 0)); |
| 751 __ sub(ebx, Immediate(kPointerSize)); |
| 752 __ bind(&loop_check); |
| 753 __ cmp(ebx, ecx); |
| 754 __ j(greater, &loop_header, Label::kNear); |
766 | 755 |
767 // Call the target. | 756 // Call the target. |
768 __ Push(edx); // Re-push return address. | 757 __ Push(edx); // Re-push return address. |
769 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 758 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
770 } | 759 } |
771 | 760 |
772 | 761 |
773 // static | |
774 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | |
775 // ----------- S t a t e ------------- | |
776 // -- eax : the number of arguments (not including the receiver) | |
777 // -- edx : the original constructor | |
778 // -- edi : the constructor | |
779 // -- ebx : the address of the first argument to be pushed. Subsequent | |
780 // arguments should be consecutive above this, in the same order as | |
781 // they are to be pushed onto the stack. | |
782 // ----------------------------------- | |
783 | |
784 // Save number of arguments on the stack below where arguments are going | |
785 // to be pushed. | |
786 __ mov(ecx, eax); | |
787 __ neg(ecx); | |
788 __ mov(Operand(esp, ecx, times_pointer_size, -kPointerSize), eax); | |
789 __ mov(eax, ecx); | |
790 | |
791 // Pop return address to allow tail-call after pushing arguments. | |
792 __ Pop(ecx); | |
793 | |
794 // Find the address of the last argument. | |
795 __ shl(eax, kPointerSizeLog2); | |
796 __ add(eax, ebx); | |
797 | |
798 // Push padding for receiver. | |
799 __ Push(Immediate(0)); | |
800 | |
801 Generate_InterpreterPushArgs(masm, eax); | |
802 | |
803 // Restore number of arguments from slot on stack. | |
804 __ mov(eax, Operand(esp, -kPointerSize)); | |
805 | |
806 // Re-push return address. | |
807 __ Push(ecx); | |
808 | |
809 // Call the constructor with unmodified eax, edi, ebi values. | |
810 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); | |
811 } | |
812 | |
813 | |
814 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 762 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
815 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 763 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
816 GenerateTailCallToReturnedCode(masm); | 764 GenerateTailCallToReturnedCode(masm); |
817 } | 765 } |
818 | 766 |
819 | 767 |
| 768 |
820 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { | 769 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { |
821 FrameScope scope(masm, StackFrame::INTERNAL); | 770 FrameScope scope(masm, StackFrame::INTERNAL); |
822 // Push a copy of the function. | 771 // Push a copy of the function. |
823 __ push(edi); | 772 __ push(edi); |
824 // Function is also the parameter to the runtime call. | 773 // Function is also the parameter to the runtime call. |
825 __ push(edi); | 774 __ push(edi); |
826 // Whether to compile in a background thread. | 775 // Whether to compile in a background thread. |
827 __ Push(masm->isolate()->factory()->ToBoolean(concurrent)); | 776 __ Push(masm->isolate()->factory()->ToBoolean(concurrent)); |
828 | 777 |
829 __ CallRuntime(Runtime::kCompileOptimized, 2); | 778 __ CallRuntime(Runtime::kCompileOptimized, 2); |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 | 1858 |
1910 __ bind(&ok); | 1859 __ bind(&ok); |
1911 __ ret(0); | 1860 __ ret(0); |
1912 } | 1861 } |
1913 | 1862 |
1914 #undef __ | 1863 #undef __ |
1915 } // namespace internal | 1864 } // namespace internal |
1916 } // namespace v8 | 1865 } // namespace v8 |
1917 | 1866 |
1918 #endif // V8_TARGET_ARCH_IA32 | 1867 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |