Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #if V8_TARGET_ARCH_X64
6 :
7 : #include "src/interface-descriptors.h"
8 :
9 : #include "src/frames.h"
10 :
11 : namespace v8 {
12 : namespace internal {
13 :
14 53648 : const Register CallInterfaceDescriptor::ContextRegister() { return rsi; }
15 :
16 11082438 : void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
17 : CallInterfaceDescriptorData* data, int register_parameter_count) {
18 11082438 : const Register default_stub_registers[] = {rax, rbx, rcx, rdx, rdi};
19 11082438 : CHECK_LE(static_cast<size_t>(register_parameter_count),
20 : arraysize(default_stub_registers));
21 : data->InitializePlatformSpecific(register_parameter_count,
22 11082438 : default_stub_registers);
23 11082438 : }
24 :
25 59583 : void RecordWriteDescriptor::InitializePlatformSpecific(
26 : CallInterfaceDescriptorData* data) {
27 : const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
28 59583 : arg_reg_4, kReturnRegister0};
29 :
30 : data->RestrictAllocatableRegisters(default_stub_registers,
31 : arraysize(default_stub_registers));
32 :
33 : CHECK_LE(static_cast<size_t>(kParameterCount),
34 : arraysize(default_stub_registers));
35 59583 : data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
36 59583 : }
37 :
38 59583 : const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
39 59583 : return rdi;
40 : }
41 59583 : const Register FastNewFunctionContextDescriptor::SlotsRegister() { return rax; }
42 :
43 178805 : const Register LoadDescriptor::ReceiverRegister() { return rdx; }
44 238332 : const Register LoadDescriptor::NameRegister() { return rcx; }
45 238332 : const Register LoadDescriptor::SlotRegister() { return rax; }
46 :
47 119166 : const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }
48 :
49 178749 : const Register StoreDescriptor::ReceiverRegister() { return rdx; }
50 297915 : const Register StoreDescriptor::NameRegister() { return rcx; }
51 297915 : const Register StoreDescriptor::ValueRegister() { return rax; }
52 238332 : const Register StoreDescriptor::SlotRegister() { return rdi; }
53 :
54 119166 : const Register StoreWithVectorDescriptor::VectorRegister() { return rbx; }
55 :
56 59583 : const Register StoreTransitionDescriptor::SlotRegister() { return rdi; }
57 59583 : const Register StoreTransitionDescriptor::VectorRegister() { return rbx; }
58 59583 : const Register StoreTransitionDescriptor::MapRegister() { return r11; }
59 :
60 59639 : const Register ApiGetterDescriptor::HolderRegister() { return rcx; }
61 59639 : const Register ApiGetterDescriptor::CallbackRegister() { return rbx; }
62 :
63 59583 : const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
64 59583 : const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
65 :
66 :
67 59583 : void TypeofDescriptor::InitializePlatformSpecific(
68 : CallInterfaceDescriptorData* data) {
69 59583 : Register registers[] = {rbx};
70 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
71 59583 : }
72 :
73 :
74 : // static
75 59583 : const Register TypeConversionDescriptor::ArgumentRegister() { return rax; }
76 :
77 59583 : void CallTrampolineDescriptor::InitializePlatformSpecific(
78 : CallInterfaceDescriptorData* data) {
79 : // rax : number of arguments
80 : // rdi : the target to call
81 59583 : Register registers[] = {rdi, rax};
82 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
83 59583 : }
84 :
85 59583 : void CallVarargsDescriptor::InitializePlatformSpecific(
86 : CallInterfaceDescriptorData* data) {
87 : // rax : number of arguments (on the stack, not including receiver)
88 : // rdi : the target to call
89 : // rcx : arguments list length (untagged)
90 : // rbx : arguments list (FixedArray)
91 59583 : Register registers[] = {rdi, rax, rcx, rbx};
92 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
93 59583 : }
94 :
95 59583 : void CallForwardVarargsDescriptor::InitializePlatformSpecific(
96 : CallInterfaceDescriptorData* data) {
97 : // rax : number of arguments
98 : // rcx : start index (to support rest parameters)
99 : // rdi : the target to call
100 59583 : Register registers[] = {rdi, rax, rcx};
101 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
102 59583 : }
103 :
104 59583 : void CallFunctionTemplateDescriptor::InitializePlatformSpecific(
105 : CallInterfaceDescriptorData* data) {
106 : // rdx: the function template info
107 : // rcx: number of arguments (on the stack, not including receiver)
108 59583 : Register registers[] = {rdx, rcx};
109 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
110 59583 : }
111 :
112 59583 : void CallWithSpreadDescriptor::InitializePlatformSpecific(
113 : CallInterfaceDescriptorData* data) {
114 : // rax : number of arguments (on the stack, not including receiver)
115 : // rdi : the target to call
116 : // rbx : the object to spread
117 59583 : Register registers[] = {rdi, rax, rbx};
118 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
119 59583 : }
120 :
121 59583 : void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
122 : CallInterfaceDescriptorData* data) {
123 : // rdi : the target to call
124 : // rbx : the arguments list
125 59583 : Register registers[] = {rdi, rbx};
126 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
127 59583 : }
128 :
129 59583 : void ConstructVarargsDescriptor::InitializePlatformSpecific(
130 : CallInterfaceDescriptorData* data) {
131 : // rax : number of arguments (on the stack, not including receiver)
132 : // rdi : the target to call
133 : // rdx : the new target
134 : // rcx : arguments list length (untagged)
135 : // rbx : arguments list (FixedArray)
136 59583 : Register registers[] = {rdi, rdx, rax, rcx, rbx};
137 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
138 59583 : }
139 :
140 59583 : void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
141 : CallInterfaceDescriptorData* data) {
142 : // rax : number of arguments
143 : // rdx : the new target
144 : // rcx : start index (to support rest parameters)
145 : // rdi : the target to call
146 59583 : Register registers[] = {rdi, rdx, rax, rcx};
147 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
148 59583 : }
149 :
150 59583 : void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
151 : CallInterfaceDescriptorData* data) {
152 : // rax : number of arguments (on the stack, not including receiver)
153 : // rdi : the target to call
154 : // rdx : the new target
155 : // rbx : the object to spread
156 59583 : Register registers[] = {rdi, rdx, rax, rbx};
157 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
158 59583 : }
159 :
160 59583 : void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
161 : CallInterfaceDescriptorData* data) {
162 : // rdi : the target to call
163 : // rdx : the new target
164 : // rbx : the arguments list
165 59583 : Register registers[] = {rdi, rdx, rbx};
166 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
167 59583 : }
168 :
169 59583 : void ConstructStubDescriptor::InitializePlatformSpecific(
170 : CallInterfaceDescriptorData* data) {
171 : // rax : number of arguments
172 : // rdx : the new target
173 : // rdi : the target to call
174 : // rbx : allocation site or undefined
175 59583 : Register registers[] = {rdi, rdx, rax, rbx};
176 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
177 59583 : }
178 :
179 59583 : void AbortDescriptor::InitializePlatformSpecific(
180 : CallInterfaceDescriptorData* data) {
181 59583 : Register registers[] = {rdx};
182 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
183 59583 : }
184 :
185 59583 : void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
186 : CallInterfaceDescriptorData* data) {
187 59583 : data->InitializePlatformSpecific(0, nullptr);
188 59583 : }
189 :
190 59583 : void CompareDescriptor::InitializePlatformSpecific(
191 : CallInterfaceDescriptorData* data) {
192 59583 : Register registers[] = {rdx, rax};
193 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
194 59583 : }
195 :
196 59583 : void BinaryOpDescriptor::InitializePlatformSpecific(
197 : CallInterfaceDescriptorData* data) {
198 59583 : Register registers[] = {rdx, rax};
199 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
200 59583 : }
201 :
202 59583 : void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
203 : CallInterfaceDescriptorData* data) {
204 : Register registers[] = {
205 : rdi, // JSFunction
206 : rdx, // the new target
207 : rax, // actual number of arguments
208 : rbx, // expected number of arguments
209 59583 : };
210 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
211 59583 : }
212 :
213 59583 : void ApiCallbackDescriptor::InitializePlatformSpecific(
214 : CallInterfaceDescriptorData* data) {
215 : Register registers[] = {
216 : rdx, // api function address
217 : rcx, // argument count (not including receiver)
218 : rbx, // call data
219 : rdi, // holder
220 59583 : };
221 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
222 59583 : }
223 :
224 59583 : void InterpreterDispatchDescriptor::InitializePlatformSpecific(
225 : CallInterfaceDescriptorData* data) {
226 : Register registers[] = {
227 : kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
228 59583 : kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
229 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
230 59583 : }
231 :
232 59583 : void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
233 : CallInterfaceDescriptorData* data) {
234 : Register registers[] = {
235 : rax, // argument count (not including receiver)
236 : rbx, // address of first argument
237 : rdi // the target callable to be call
238 59583 : };
239 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
240 59583 : }
241 :
242 59583 : void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
243 : CallInterfaceDescriptorData* data) {
244 : Register registers[] = {
245 : rax, // argument count (not including receiver)
246 : rcx, // address of first argument
247 : rdi, // constructor to call
248 : rdx, // new target
249 : rbx, // allocation site feedback if available, undefined otherwise
250 59583 : };
251 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
252 59583 : }
253 :
254 59583 : void ResumeGeneratorDescriptor::InitializePlatformSpecific(
255 : CallInterfaceDescriptorData* data) {
256 : Register registers[] = {
257 : rax, // the value to pass to the generator
258 : rdx // the JSGeneratorObject / JSAsyncGeneratorObject to resume
259 59583 : };
260 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
261 59583 : }
262 :
263 59583 : void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
264 : CallInterfaceDescriptorData* data) {
265 : Register registers[] = {
266 : rbx, // loaded new FP
267 59583 : };
268 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
269 59583 : }
270 :
271 59583 : void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
272 : CallInterfaceDescriptorData* data) {
273 59583 : Register registers[] = {arg_reg_1, arg_reg_2};
274 59583 : data->InitializePlatformSpecific(arraysize(registers), registers);
275 59583 : }
276 :
277 : } // namespace internal
278 178779 : } // namespace v8
279 :
280 : #endif // V8_TARGET_ARCH_X64
|