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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 __ bind(&loop_header); | 687 __ bind(&loop_header); |
688 __ Push(Operand(start_address, 0)); | 688 __ Push(Operand(start_address, 0)); |
689 __ sub(start_address, Immediate(kPointerSize)); | 689 __ sub(start_address, Immediate(kPointerSize)); |
690 __ bind(&loop_check); | 690 __ bind(&loop_check); |
691 __ cmp(start_address, array_limit); | 691 __ cmp(start_address, array_limit); |
692 __ j(greater, &loop_header, Label::kNear); | 692 __ j(greater, &loop_header, Label::kNear); |
693 } | 693 } |
694 | 694 |
695 // static | 695 // static |
696 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 696 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
697 MacroAssembler* masm, TailCallMode tail_call_mode, | 697 MacroAssembler* masm, TailCallMode tail_call_mode, PushArgsMode mode) { |
698 CallableType function_type) { | |
699 // ----------- S t a t e ------------- | 698 // ----------- S t a t e ------------- |
700 // -- eax : the number of arguments (not including the receiver) | 699 // -- eax : the number of arguments (not including the receiver) |
701 // -- ebx : the address of the first argument to be pushed. Subsequent | 700 // -- ebx : the address of the first argument to be pushed. Subsequent |
702 // arguments should be consecutive above this, in the same order as | 701 // arguments should be consecutive above this, in the same order as |
703 // they are to be pushed onto the stack. | 702 // they are to be pushed onto the stack. |
704 // -- edi : the target to call (can be any Object). | 703 // -- edi : the target to call (can be any Object). |
705 // ----------------------------------- | 704 // ----------------------------------- |
706 Label stack_overflow; | 705 Label stack_overflow; |
707 // Compute the expected number of arguments. | 706 // Compute the expected number of arguments. |
708 __ mov(ecx, eax); | 707 __ mov(ecx, eax); |
(...skipping 11 matching lines...) Expand all Loading... |
720 | 719 |
721 // Find the address of the last argument. | 720 // Find the address of the last argument. |
722 __ shl(ecx, kPointerSizeLog2); | 721 __ shl(ecx, kPointerSizeLog2); |
723 __ neg(ecx); | 722 __ neg(ecx); |
724 __ add(ecx, ebx); | 723 __ add(ecx, ebx); |
725 Generate_InterpreterPushArgs(masm, ecx, ebx); | 724 Generate_InterpreterPushArgs(masm, ecx, ebx); |
726 | 725 |
727 // Call the target. | 726 // Call the target. |
728 __ Push(edx); // Re-push return address. | 727 __ Push(edx); // Re-push return address. |
729 | 728 |
730 if (function_type == CallableType::kJSFunction) { | 729 if (mode == PushArgsMode::kJSFunction) { |
731 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 730 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
732 tail_call_mode), | 731 tail_call_mode), |
733 RelocInfo::CODE_TARGET); | 732 RelocInfo::CODE_TARGET); |
734 } else { | 733 } else { |
735 DCHECK_EQ(function_type, CallableType::kAny); | 734 DCHECK_EQ(mode, PushArgsMode::kOther); |
736 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 735 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
737 tail_call_mode), | 736 tail_call_mode), |
738 RelocInfo::CODE_TARGET); | 737 RelocInfo::CODE_TARGET); |
739 } | 738 } |
740 | 739 |
741 __ bind(&stack_overflow); | 740 __ bind(&stack_overflow); |
742 { | 741 { |
743 // Pop the temporary registers, so that return address is on top of stack. | 742 // Pop the temporary registers, so that return address is on top of stack. |
744 __ Pop(edi); | 743 __ Pop(edi); |
745 | 744 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 __ sub(scratch1, Immediate(1)); | 837 __ sub(scratch1, Immediate(1)); |
839 __ bind(&loop_check); | 838 __ bind(&loop_check); |
840 __ cmp(scratch1, Immediate(0)); | 839 __ cmp(scratch1, Immediate(0)); |
841 __ j(greater, &loop_header, Label::kNear); | 840 __ j(greater, &loop_header, Label::kNear); |
842 } | 841 } |
843 | 842 |
844 } // end anonymous namespace | 843 } // end anonymous namespace |
845 | 844 |
846 // static | 845 // static |
847 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 846 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
848 MacroAssembler* masm, PushArgsConstructMode mode) { | 847 MacroAssembler* masm, PushArgsMode mode) { |
849 // ----------- S t a t e ------------- | 848 // ----------- S t a t e ------------- |
850 // -- eax : the number of arguments (not including the receiver) | 849 // -- eax : the number of arguments (not including the receiver) |
851 // -- edx : the new target | 850 // -- edx : the new target |
852 // -- edi : the constructor | 851 // -- edi : the constructor |
853 // -- ebx : allocation site feedback (if available or undefined) | 852 // -- ebx : allocation site feedback (if available or undefined) |
854 // -- ecx : the address of the first argument to be pushed. Subsequent | 853 // -- ecx : the address of the first argument to be pushed. Subsequent |
855 // arguments should be consecutive above this, in the same order as | 854 // arguments should be consecutive above this, in the same order as |
856 // they are to be pushed onto the stack. | 855 // they are to be pushed onto the stack. |
857 // ----------------------------------- | 856 // ----------------------------------- |
858 Label stack_overflow; | 857 Label stack_overflow; |
859 // We need two scratch registers. Push edi and edx onto stack. | 858 // We need two scratch registers. Push edi and edx onto stack. |
860 __ Push(edi); | 859 __ Push(edi); |
861 __ Push(edx); | 860 __ Push(edx); |
862 | 861 |
863 // Push arguments and move return address to the top of stack. | 862 // 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 | 863 // 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. | 864 // and edi registers will be modified but restored to their original values. |
866 Generate_InterpreterPushArgsAndReturnAddress(masm, eax, ecx, edx, edi, false, | 865 Generate_InterpreterPushArgsAndReturnAddress(masm, eax, ecx, edx, edi, false, |
867 2, &stack_overflow); | 866 2, &stack_overflow); |
868 | 867 |
869 // Restore edi and edx | 868 // Restore edi and edx |
870 __ Pop(edx); | 869 __ Pop(edx); |
871 __ Pop(edi); | 870 __ Pop(edi); |
872 | 871 |
873 __ AssertUndefinedOrAllocationSite(ebx); | 872 __ AssertUndefinedOrAllocationSite(ebx); |
874 if (mode == PushArgsConstructMode::kJSFunction) { | 873 if (mode == PushArgsMode::kJSFunction) { |
875 // Tail call to the function-specific construct stub (still in the caller | 874 // Tail call to the function-specific construct stub (still in the caller |
876 // context at this point). | 875 // context at this point). |
877 __ AssertFunction(edi); | 876 __ AssertFunction(edi); |
878 | 877 |
879 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 878 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
880 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); | 879 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); |
881 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); | 880 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); |
882 __ jmp(ecx); | 881 __ jmp(ecx); |
883 } else if (mode == PushArgsConstructMode::kWithFinalSpread) { | 882 } else if (mode == PushArgsMode::kWithFinalSpread) { |
884 // Call the constructor with unmodified eax, edi, edx values. | 883 // Call the constructor with unmodified eax, edi, edx values. |
885 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), | 884 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), |
886 RelocInfo::CODE_TARGET); | 885 RelocInfo::CODE_TARGET); |
887 } else { | 886 } else { |
888 DCHECK_EQ(PushArgsConstructMode::kOther, mode); | 887 DCHECK_EQ(PushArgsMode::kOther, mode); |
889 // Call the constructor with unmodified eax, edi, edx values. | 888 // Call the constructor with unmodified eax, edi, edx values. |
890 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 889 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
891 } | 890 } |
892 | 891 |
893 __ bind(&stack_overflow); | 892 __ bind(&stack_overflow); |
894 { | 893 { |
895 // Pop the temporary registers, so that return address is on top of stack. | 894 // Pop the temporary registers, so that return address is on top of stack. |
896 __ Pop(edx); | 895 __ Pop(edx); |
897 __ Pop(edi); | 896 __ Pop(edi); |
898 | 897 |
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3322 | 3321 |
3323 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3322 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3324 Generate_OnStackReplacementHelper(masm, true); | 3323 Generate_OnStackReplacementHelper(masm, true); |
3325 } | 3324 } |
3326 | 3325 |
3327 #undef __ | 3326 #undef __ |
3328 } // namespace internal | 3327 } // namespace internal |
3329 } // namespace v8 | 3328 } // namespace v8 |
3330 | 3329 |
3331 #endif // V8_TARGET_ARCH_X87 | 3330 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |