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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 __ sub(scratch1, Immediate(1)); | 838 __ sub(scratch1, Immediate(1)); |
839 __ bind(&loop_check); | 839 __ bind(&loop_check); |
840 __ cmp(scratch1, Immediate(0)); | 840 __ cmp(scratch1, Immediate(0)); |
841 __ j(greater, &loop_header, Label::kNear); | 841 __ j(greater, &loop_header, Label::kNear); |
842 } | 842 } |
843 | 843 |
844 } // end anonymous namespace | 844 } // end anonymous namespace |
845 | 845 |
846 // static | 846 // static |
847 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 847 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
848 MacroAssembler* masm, CallableType construct_type) { | 848 MacroAssembler* masm, PushArgsConstructMode mode) { |
849 // ----------- S t a t e ------------- | 849 // ----------- S t a t e ------------- |
850 // -- eax : the number of arguments (not including the receiver) | 850 // -- eax : the number of arguments (not including the receiver) |
851 // -- edx : the new target | 851 // -- edx : the new target |
852 // -- edi : the constructor | 852 // -- edi : the constructor |
853 // -- ebx : allocation site feedback (if available or undefined) | 853 // -- ebx : allocation site feedback (if available or undefined) |
854 // -- ecx : the address of the first argument to be pushed. Subsequent | 854 // -- ecx : the address of the first argument to be pushed. Subsequent |
855 // arguments should be consecutive above this, in the same order as | 855 // arguments should be consecutive above this, in the same order as |
856 // they are to be pushed onto the stack. | 856 // they are to be pushed onto the stack. |
857 // ----------------------------------- | 857 // ----------------------------------- |
858 Label stack_overflow; | 858 Label stack_overflow; |
859 // We need two scratch registers. Push edi and edx onto stack. | 859 // We need two scratch registers. Push edi and edx onto stack. |
860 __ Push(edi); | 860 __ Push(edi); |
861 __ Push(edx); | 861 __ Push(edx); |
862 | 862 |
863 // Push arguments and move return address to the top of stack. | 863 // Push arguments and move return address to the top of stack. |
864 // The eax register is readonly. The ecx register will be modified. The edx | 864 // The eax register is readonly. The ecx register will be modified. The edx |
865 // and edi registers will be modified but restored to their original values. | 865 // and edi registers will be modified but restored to their original values. |
866 Generate_InterpreterPushArgsAndReturnAddress(masm, eax, ecx, edx, edi, false, | 866 Generate_InterpreterPushArgsAndReturnAddress(masm, eax, ecx, edx, edi, false, |
867 2, &stack_overflow); | 867 2, &stack_overflow); |
868 | 868 |
869 // Restore edi and edx | 869 // Restore edi and edx |
870 __ Pop(edx); | 870 __ Pop(edx); |
871 __ Pop(edi); | 871 __ Pop(edi); |
872 | 872 |
873 __ AssertUndefinedOrAllocationSite(ebx); | 873 __ AssertUndefinedOrAllocationSite(ebx); |
874 if (construct_type == CallableType::kJSFunction) { | 874 if (mode == PushArgsConstructMode::kJSFunction) { |
875 // Tail call to the function-specific construct stub (still in the caller | 875 // Tail call to the function-specific construct stub (still in the caller |
876 // context at this point). | 876 // context at this point). |
877 __ AssertFunction(edi); | 877 __ AssertFunction(edi); |
878 | 878 |
879 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 879 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
880 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); | 880 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); |
881 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); | 881 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); |
882 __ jmp(ecx); | 882 __ jmp(ecx); |
| 883 } else if (mode == PushArgsConstructMode::kWithFinalSpread) { |
| 884 // Call the constructor with unmodified eax, edi, edx values. |
| 885 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), |
| 886 RelocInfo::CODE_TARGET); |
883 } else { | 887 } else { |
884 DCHECK_EQ(construct_type, CallableType::kAny); | 888 DCHECK_EQ(PushArgsConstructMode::kOther, mode); |
885 | |
886 // Call the constructor with unmodified eax, edi, edx values. | 889 // Call the constructor with unmodified eax, edi, edx values. |
887 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 890 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
888 } | 891 } |
889 | 892 |
890 __ bind(&stack_overflow); | 893 __ bind(&stack_overflow); |
891 { | 894 { |
892 // Pop the temporary registers, so that return address is on top of stack. | 895 // Pop the temporary registers, so that return address is on top of stack. |
893 __ Pop(edx); | 896 __ Pop(edx); |
894 __ Pop(edi); | 897 __ Pop(edi); |
895 | 898 |
(...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 | 3130 |
3128 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3131 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3129 Generate_OnStackReplacementHelper(masm, true); | 3132 Generate_OnStackReplacementHelper(masm, true); |
3130 } | 3133 } |
3131 | 3134 |
3132 #undef __ | 3135 #undef __ |
3133 } // namespace internal | 3136 } // namespace internal |
3134 } // namespace v8 | 3137 } // namespace v8 |
3135 | 3138 |
3136 #endif // V8_TARGET_ARCH_X87 | 3139 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |