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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 | 15 |
16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
17 | 17 |
18 | 18 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) { |
19 void Builtins::Generate_Adaptor(MacroAssembler* masm, | |
20 CFunctionId id, | |
21 BuiltinExtraArguments extra_args) { | |
22 // ----------- S t a t e ------------- | 19 // ----------- S t a t e ------------- |
23 // -- rax : number of arguments excluding receiver | 20 // -- rax : number of arguments excluding receiver |
24 // -- rdi : target | 21 // -- rdi : target |
25 // -- rdx : new.target | 22 // -- rdx : new.target |
26 // -- rsp[0] : return address | 23 // -- rsp[0] : return address |
27 // -- rsp[8] : last argument | 24 // -- rsp[8] : last argument |
28 // -- ... | 25 // -- ... |
29 // -- rsp[8 * argc] : first argument | 26 // -- rsp[8 * argc] : first argument |
30 // -- rsp[8 * (argc + 1)] : receiver | 27 // -- rsp[8 * (argc + 1)] : receiver |
31 // ----------------------------------- | 28 // ----------------------------------- |
32 __ AssertFunction(rdi); | 29 __ AssertFunction(rdi); |
33 | 30 |
34 // Make sure we operate in the context of the called function (for example | 31 // Make sure we operate in the context of the called function (for example |
35 // ConstructStubs implemented in C++ will be run in the context of the caller | 32 // ConstructStubs implemented in C++ will be run in the context of the caller |
36 // instead of the callee, due to the way that [[Construct]] is defined for | 33 // instead of the callee, due to the way that [[Construct]] is defined for |
37 // ordinary functions). | 34 // ordinary functions). |
38 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 35 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
39 | 36 |
40 // Insert extra arguments. | 37 // Unconditionally insert the target and new target as extra arguments. They |
41 int num_extra_args = 0; | 38 // will be used by stack frame iterators when constructing the stack trace. |
42 if (extra_args != BuiltinExtraArguments::kNone) { | 39 const int num_extra_args = 2; |
43 __ PopReturnAddressTo(kScratchRegister); | 40 __ PopReturnAddressTo(kScratchRegister); |
44 if (extra_args & BuiltinExtraArguments::kTarget) { | 41 __ Push(rdi); |
45 ++num_extra_args; | 42 __ Push(rdx); |
46 __ Push(rdi); | 43 __ PushReturnAddressFrom(kScratchRegister); |
47 } | |
48 if (extra_args & BuiltinExtraArguments::kNewTarget) { | |
49 ++num_extra_args; | |
50 __ Push(rdx); | |
51 } | |
52 __ PushReturnAddressFrom(kScratchRegister); | |
53 } | |
54 | 44 |
55 // JumpToExternalReference expects rax to contain the number of arguments | 45 // JumpToExternalReference expects rax to contain the number of arguments |
56 // including the receiver and the extra arguments. | 46 // including the receiver and the extra arguments. |
57 __ addp(rax, Immediate(num_extra_args + 1)); | 47 __ addp(rax, Immediate(num_extra_args + 1)); |
58 | 48 |
59 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
60 } | 50 } |
61 | 51 |
62 | 52 |
63 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 53 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
(...skipping 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 __ ret(0); | 3031 __ ret(0); |
3042 } | 3032 } |
3043 | 3033 |
3044 | 3034 |
3045 #undef __ | 3035 #undef __ |
3046 | 3036 |
3047 } // namespace internal | 3037 } // namespace internal |
3048 } // namespace v8 | 3038 } // namespace v8 |
3049 | 3039 |
3050 #endif // V8_TARGET_ARCH_X64 | 3040 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |