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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 RelocInfo::CODE_TARGET); | 833 RelocInfo::CODE_TARGET); |
834 } else { | 834 } else { |
835 DCHECK_EQ(function_type, CallableType::kAny); | 835 DCHECK_EQ(function_type, CallableType::kAny); |
836 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 836 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
837 tail_call_mode), | 837 tail_call_mode), |
838 RelocInfo::CODE_TARGET); | 838 RelocInfo::CODE_TARGET); |
839 } | 839 } |
840 } | 840 } |
841 | 841 |
842 // static | 842 // static |
843 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 843 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
| 844 MacroAssembler* masm, CallableType construct_type) { |
844 // ----------- S t a t e ------------- | 845 // ----------- S t a t e ------------- |
845 // -- rax : the number of arguments (not including the receiver) | 846 // -- rax : the number of arguments (not including the receiver) |
846 // -- rdx : the new target (either the same as the constructor or | 847 // -- rdx : the new target (either the same as the constructor or |
847 // the JSFunction on which new was invoked initially) | 848 // the JSFunction on which new was invoked initially) |
848 // -- rdi : the constructor to call (can be any Object) | 849 // -- rdi : the constructor to call (can be any Object) |
849 // -- rbx : the address of the first argument to be pushed. Subsequent | 850 // -- rbx : the address of the first argument to be pushed. Subsequent |
850 // arguments should be consecutive above this, in the same order as | 851 // arguments should be consecutive above this, in the same order as |
851 // they are to be pushed onto the stack. | 852 // they are to be pushed onto the stack. |
852 // ----------------------------------- | 853 // ----------------------------------- |
853 | 854 |
854 // Pop return address to allow tail-call after pushing arguments. | 855 // Pop return address to allow tail-call after pushing arguments. |
855 __ PopReturnAddressTo(kScratchRegister); | 856 __ PopReturnAddressTo(kScratchRegister); |
856 | 857 |
857 // Push slot for the receiver to be constructed. | 858 // Push slot for the receiver to be constructed. |
858 __ Push(Immediate(0)); | 859 __ Push(Immediate(0)); |
859 | 860 |
860 Generate_InterpreterPushArgs(masm, false); | 861 Generate_InterpreterPushArgs(masm, false); |
861 | 862 |
862 // Push return address in preparation for the tail-call. | 863 // Push return address in preparation for the tail-call. |
863 __ PushReturnAddressFrom(kScratchRegister); | 864 __ PushReturnAddressFrom(kScratchRegister); |
864 | 865 |
865 // Call the constructor (rax, rdx, rdi passed on). | 866 if (construct_type == CallableType::kJSFunction) { |
866 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 867 // TODO(mythria): Change this when allocation site feedback is available. |
| 868 // ConstructFunction initializes allocation site to undefined. |
| 869 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
| 870 RelocInfo::CODE_TARGET); |
| 871 } else { |
| 872 DCHECK_EQ(construct_type, CallableType::kAny); |
| 873 // Call the constructor (rax, rdx, rdi passed on). |
| 874 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 875 } |
867 } | 876 } |
868 | 877 |
869 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 878 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
870 // Set the return address to the correct point in the interpreter entry | 879 // Set the return address to the correct point in the interpreter entry |
871 // trampoline. | 880 // trampoline. |
872 Smi* interpreter_entry_return_pc_offset( | 881 Smi* interpreter_entry_return_pc_offset( |
873 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 882 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
874 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 883 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
875 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 884 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
876 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + | 885 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + |
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 // And "return" to the OSR entry point of the function. | 3056 // And "return" to the OSR entry point of the function. |
3048 __ ret(0); | 3057 __ ret(0); |
3049 } | 3058 } |
3050 | 3059 |
3051 #undef __ | 3060 #undef __ |
3052 | 3061 |
3053 } // namespace internal | 3062 } // namespace internal |
3054 } // namespace v8 | 3063 } // namespace v8 |
3055 | 3064 |
3056 #endif // V8_TARGET_ARCH_X64 | 3065 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |