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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 __ bind(&loop_header); | 748 __ bind(&loop_header); |
749 __ Push(Operand(rbx, 0)); | 749 __ Push(Operand(rbx, 0)); |
750 __ subp(rbx, Immediate(kPointerSize)); | 750 __ subp(rbx, Immediate(kPointerSize)); |
751 __ bind(&loop_check); | 751 __ bind(&loop_check); |
752 __ cmpp(rbx, rcx); | 752 __ cmpp(rbx, rcx); |
753 __ j(greater, &loop_header, Label::kNear); | 753 __ j(greater, &loop_header, Label::kNear); |
754 } | 754 } |
755 | 755 |
756 | 756 |
757 // static | 757 // static |
758 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { | 758 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
| 759 MacroAssembler* masm, TailCallMode tail_call_mode) { |
759 // ----------- S t a t e ------------- | 760 // ----------- S t a t e ------------- |
760 // -- rax : the number of arguments (not including the receiver) | 761 // -- rax : the number of arguments (not including the receiver) |
761 // -- rbx : the address of the first argument to be pushed. Subsequent | 762 // -- rbx : the address of the first argument to be pushed. Subsequent |
762 // arguments should be consecutive above this, in the same order as | 763 // arguments should be consecutive above this, in the same order as |
763 // they are to be pushed onto the stack. | 764 // they are to be pushed onto the stack. |
764 // -- rdi : the target to call (can be any Object). | 765 // -- rdi : the target to call (can be any Object). |
765 // ----------------------------------- | 766 // ----------------------------------- |
766 | 767 |
767 // Pop return address to allow tail-call after pushing arguments. | 768 // Pop return address to allow tail-call after pushing arguments. |
768 __ PopReturnAddressTo(kScratchRegister); | 769 __ PopReturnAddressTo(kScratchRegister); |
769 | 770 |
770 Generate_InterpreterPushArgs(masm, true); | 771 Generate_InterpreterPushArgs(masm, true); |
771 | 772 |
772 // Call the target. | 773 // Call the target. |
773 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. | 774 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. |
774 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 775 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
| 776 tail_call_mode), |
| 777 RelocInfo::CODE_TARGET); |
775 } | 778 } |
776 | 779 |
777 | 780 |
778 // static | 781 // static |
779 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 782 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
780 // ----------- S t a t e ------------- | 783 // ----------- S t a t e ------------- |
781 // -- rax : the number of arguments (not including the receiver) | 784 // -- rax : the number of arguments (not including the receiver) |
782 // -- rdx : the new target (either the same as the constructor or | 785 // -- rdx : the new target (either the same as the constructor or |
783 // the JSFunction on which new was invoked initially) | 786 // the JSFunction on which new was invoked initially) |
784 // -- rdi : the constructor to call (can be any Object) | 787 // -- rdi : the constructor to call (can be any Object) |
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 Register scratch3) { | 2183 Register scratch3) { |
2181 DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); | 2184 DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); |
2182 Comment cmnt(masm, "[ PrepareForTailCall"); | 2185 Comment cmnt(masm, "[ PrepareForTailCall"); |
2183 | 2186 |
2184 // Prepare for tail call only if the debugger is not active. | 2187 // Prepare for tail call only if the debugger is not active. |
2185 Label done; | 2188 Label done; |
2186 ExternalReference debug_is_active = | 2189 ExternalReference debug_is_active = |
2187 ExternalReference::debug_is_active_address(masm->isolate()); | 2190 ExternalReference::debug_is_active_address(masm->isolate()); |
2188 __ Move(kScratchRegister, debug_is_active); | 2191 __ Move(kScratchRegister, debug_is_active); |
2189 __ cmpb(Operand(kScratchRegister, 0), Immediate(0)); | 2192 __ cmpb(Operand(kScratchRegister, 0), Immediate(0)); |
2190 __ j(not_equal, &done, Label::kNear); | 2193 __ j(not_equal, &done); |
| 2194 |
| 2195 // Drop possible interpreter handler/stub frame. |
| 2196 { |
| 2197 Label no_interpreter_frame; |
| 2198 __ Cmp(Operand(rbp, StandardFrameConstants::kMarkerOffset), |
| 2199 Smi::FromInt(StackFrame::STUB)); |
| 2200 __ j(not_equal, &no_interpreter_frame, Label::kNear); |
| 2201 __ movp(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 2202 __ bind(&no_interpreter_frame); |
| 2203 } |
2191 | 2204 |
2192 // Check if next frame is an arguments adaptor frame. | 2205 // Check if next frame is an arguments adaptor frame. |
2193 Label no_arguments_adaptor, formal_parameter_count_loaded; | 2206 Label no_arguments_adaptor, formal_parameter_count_loaded; |
2194 __ movp(scratch2, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 2207 __ movp(scratch2, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
2195 __ Cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), | 2208 __ Cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), |
2196 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 2209 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
2197 __ j(not_equal, &no_arguments_adaptor, Label::kNear); | 2210 __ j(not_equal, &no_arguments_adaptor, Label::kNear); |
2198 | 2211 |
2199 // Drop arguments adaptor frame and load arguments count. | 2212 // Drop arguments adaptor frame and load arguments count. |
2200 __ movp(rbp, scratch2); | 2213 __ movp(rbp, scratch2); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2847 __ ret(0); | 2860 __ ret(0); |
2848 } | 2861 } |
2849 | 2862 |
2850 | 2863 |
2851 #undef __ | 2864 #undef __ |
2852 | 2865 |
2853 } // namespace internal | 2866 } // namespace internal |
2854 } // namespace v8 | 2867 } // namespace v8 |
2855 | 2868 |
2856 #endif // V8_TARGET_ARCH_X64 | 2869 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |