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 : namespace v8 {
10 : namespace internal {
11 :
12 0 : const Register CallInterfaceDescriptor::ContextRegister() { return rsi; }
13 :
14 2859948 : void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
15 : CallInterfaceDescriptorData* data, int register_parameter_count) {
16 2859948 : const Register default_stub_registers[] = {rax, rbx, rcx, rdx, rdi};
17 2859948 : CHECK_LE(static_cast<size_t>(register_parameter_count),
18 : arraysize(default_stub_registers));
19 : data->InitializePlatformSpecific(register_parameter_count,
20 2859948 : default_stub_registers);
21 2859948 : }
22 :
23 54999 : void RecordWriteDescriptor::InitializePlatformSpecific(
24 : CallInterfaceDescriptorData* data) {
25 : const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
26 54999 : arg_reg_4, kReturnRegister0};
27 :
28 : data->RestrictAllocatableRegisters(default_stub_registers,
29 : arraysize(default_stub_registers));
30 :
31 : CHECK_LE(static_cast<size_t>(kParameterCount),
32 : arraysize(default_stub_registers));
33 54999 : data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
34 54999 : }
35 :
36 54999 : const Register FastNewFunctionContextDescriptor::FunctionRegister() {
37 54999 : return rdi;
38 : }
39 54999 : const Register FastNewFunctionContextDescriptor::SlotsRegister() { return rax; }
40 :
41 278986 : const Register LoadDescriptor::ReceiverRegister() { return rdx; }
42 333954 : const Register LoadDescriptor::NameRegister() { return rcx; }
43 282019 : const Register LoadDescriptor::SlotRegister() { return rax; }
44 :
45 172021 : const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }
46 :
47 54999 : const Register LoadICProtoArrayDescriptor::HandlerRegister() { return rdi; }
48 :
49 219996 : const Register StoreDescriptor::ReceiverRegister() { return rdx; }
50 219996 : const Register StoreDescriptor::NameRegister() { return rcx; }
51 603531 : const Register StoreDescriptor::ValueRegister() { return rax; }
52 594356 : const Register StoreDescriptor::SlotRegister() { return rdi; }
53 :
54 539357 : const Register StoreWithVectorDescriptor::VectorRegister() { return rbx; }
55 :
56 109998 : const Register StoreTransitionDescriptor::SlotRegister() { return rdi; }
57 109998 : const Register StoreTransitionDescriptor::VectorRegister() { return rbx; }
58 109998 : const Register StoreTransitionDescriptor::MapRegister() { return r11; }
59 :
60 54999 : const Register StringCompareDescriptor::LeftRegister() { return rdx; }
61 54999 : const Register StringCompareDescriptor::RightRegister() { return rax; }
62 :
63 55030 : const Register ApiGetterDescriptor::HolderRegister() { return rcx; }
64 55030 : const Register ApiGetterDescriptor::CallbackRegister() { return rbx; }
65 :
66 55030 : const Register MathPowTaggedDescriptor::exponent() { return rdx; }
67 :
68 54999 : const Register MathPowIntegerDescriptor::exponent() {
69 54999 : return MathPowTaggedDescriptor::exponent();
70 : }
71 :
72 :
73 54999 : const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
74 54999 : const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
75 :
76 :
77 54999 : void FastNewClosureDescriptor::InitializePlatformSpecific(
78 : CallInterfaceDescriptorData* data) {
79 : // SharedFunctionInfo, vector, slot index.
80 54999 : Register registers[] = {rbx, rcx, rdx};
81 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
82 54999 : }
83 :
84 54999 : void TypeofDescriptor::InitializePlatformSpecific(
85 : CallInterfaceDescriptorData* data) {
86 54999 : Register registers[] = {rbx};
87 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
88 54999 : }
89 :
90 :
91 : // static
92 54999 : const Register TypeConversionDescriptor::ArgumentRegister() { return rax; }
93 :
94 54999 : void CallFunctionDescriptor::InitializePlatformSpecific(
95 : CallInterfaceDescriptorData* data) {
96 54999 : Register registers[] = {rdi};
97 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
98 54999 : }
99 :
100 54999 : void CallTrampolineDescriptor::InitializePlatformSpecific(
101 : CallInterfaceDescriptorData* data) {
102 : // rax : number of arguments
103 : // rdi : the target to call
104 54999 : Register registers[] = {rdi, rax};
105 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
106 54999 : }
107 :
108 54999 : void CallVarargsDescriptor::InitializePlatformSpecific(
109 : CallInterfaceDescriptorData* data) {
110 : // rax : number of arguments (on the stack, not including receiver)
111 : // rdi : the target to call
112 : // rbx : arguments list (FixedArray)
113 : // rcx : arguments list length (untagged)
114 54999 : Register registers[] = {rdi, rax, rbx, rcx};
115 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
116 54999 : }
117 :
118 54999 : void CallForwardVarargsDescriptor::InitializePlatformSpecific(
119 : CallInterfaceDescriptorData* data) {
120 : // rax : number of arguments
121 : // rcx : start index (to support rest parameters)
122 : // rdi : the target to call
123 54999 : Register registers[] = {rdi, rax, rcx};
124 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
125 54999 : }
126 :
127 54999 : void CallWithSpreadDescriptor::InitializePlatformSpecific(
128 : CallInterfaceDescriptorData* data) {
129 : // rax : number of arguments (on the stack, not including receiver)
130 : // rdi : the target to call
131 : // rbx : the object to spread
132 54999 : Register registers[] = {rdi, rax, rbx};
133 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
134 54999 : }
135 :
136 54999 : void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
137 : CallInterfaceDescriptorData* data) {
138 : // rdi : the target to call
139 : // rbx : the arguments list
140 54999 : Register registers[] = {rdi, rbx};
141 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
142 54999 : }
143 :
144 54999 : void ConstructVarargsDescriptor::InitializePlatformSpecific(
145 : CallInterfaceDescriptorData* data) {
146 : // rax : number of arguments (on the stack, not including receiver)
147 : // rdi : the target to call
148 : // rdx : the new target
149 : // rbx : arguments list (FixedArray)
150 : // rcx : arguments list length (untagged)
151 54999 : Register registers[] = {rdi, rdx, rax, rbx, rcx};
152 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
153 54999 : }
154 :
155 54999 : void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
156 : CallInterfaceDescriptorData* data) {
157 : // rax : number of arguments
158 : // rdx : the new target
159 : // rcx : start index (to support rest parameters)
160 : // rdi : the target to call
161 54999 : Register registers[] = {rdi, rdx, rax, rcx};
162 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
163 54999 : }
164 :
165 54999 : void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
166 : CallInterfaceDescriptorData* data) {
167 : // rax : number of arguments (on the stack, not including receiver)
168 : // rdi : the target to call
169 : // rdx : the new target
170 : // rbx : the object to spread
171 54999 : Register registers[] = {rdi, rdx, rax, rbx};
172 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
173 54999 : }
174 :
175 54999 : void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
176 : CallInterfaceDescriptorData* data) {
177 : // rdi : the target to call
178 : // rdx : the new target
179 : // rbx : the arguments list
180 54999 : Register registers[] = {rdi, rdx, rbx};
181 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
182 54999 : }
183 :
184 54999 : void ConstructStubDescriptor::InitializePlatformSpecific(
185 : CallInterfaceDescriptorData* data) {
186 : // rax : number of arguments
187 : // rdx : the new target
188 : // rdi : the target to call
189 : // rbx : allocation site or undefined
190 54999 : Register registers[] = {rdi, rdx, rax, rbx};
191 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
192 54999 : }
193 :
194 :
195 54999 : void ConstructTrampolineDescriptor::InitializePlatformSpecific(
196 : CallInterfaceDescriptorData* data) {
197 : // rax : number of arguments
198 : // rdx : the new target
199 : // rdi : the target to call
200 54999 : Register registers[] = {rdi, rdx, rax};
201 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
202 54999 : }
203 :
204 :
205 54999 : void TransitionElementsKindDescriptor::InitializePlatformSpecific(
206 : CallInterfaceDescriptorData* data) {
207 54999 : Register registers[] = {rax, rbx};
208 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
209 54999 : }
210 :
211 :
212 54999 : void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
213 : CallInterfaceDescriptorData* data) {
214 54999 : data->InitializePlatformSpecific(0, nullptr, nullptr);
215 54999 : }
216 :
217 54999 : void ArrayConstructorDescriptor::InitializePlatformSpecific(
218 : CallInterfaceDescriptorData* data) {
219 : // kTarget, kNewTarget, kActualArgumentsCount, kAllocationSite
220 54999 : Register registers[] = {rdi, rdx, rax, rbx};
221 54999 : data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
222 54999 : }
223 :
224 54999 : void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
225 : CallInterfaceDescriptorData* data) {
226 : // register state
227 : // rax -- number of arguments
228 : // rdi -- function
229 : // rbx -- allocation site with elements kind
230 54999 : Register registers[] = {rdi, rbx, rax};
231 54999 : data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
232 54999 : }
233 :
234 54999 : void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
235 : CallInterfaceDescriptorData* data) {
236 : // register state
237 : // rax -- number of arguments
238 : // rdi -- function
239 : // rbx -- allocation site with elements kind
240 54999 : Register registers[] = {rdi, rbx, rax};
241 54999 : data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
242 54999 : }
243 :
244 54999 : void ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(
245 : CallInterfaceDescriptorData* data) {
246 : // register state
247 : // rax -- number of arguments
248 : // rdi -- function
249 : // rbx -- allocation site with elements kind
250 54999 : Register registers[] = {rdi, rbx, rax};
251 54999 : data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
252 54999 : }
253 :
254 54999 : void CompareDescriptor::InitializePlatformSpecific(
255 : CallInterfaceDescriptorData* data) {
256 54999 : Register registers[] = {rdx, rax};
257 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
258 54999 : }
259 :
260 :
261 54999 : void BinaryOpDescriptor::InitializePlatformSpecific(
262 : CallInterfaceDescriptorData* data) {
263 54999 : Register registers[] = {rdx, rax};
264 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
265 54999 : }
266 :
267 54999 : void StringAddDescriptor::InitializePlatformSpecific(
268 : CallInterfaceDescriptorData* data) {
269 54999 : Register registers[] = {rdx, rax};
270 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
271 54999 : }
272 :
273 54999 : void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
274 : CallInterfaceDescriptorData* data) {
275 : Register registers[] = {
276 : rdi, // JSFunction
277 : rdx, // the new target
278 : rax, // actual number of arguments
279 : rbx, // expected number of arguments
280 54999 : };
281 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
282 54999 : }
283 :
284 54999 : void ApiCallbackDescriptor::InitializePlatformSpecific(
285 : CallInterfaceDescriptorData* data) {
286 : Register registers[] = {
287 : rdi, // callee
288 : rbx, // call_data
289 : rcx, // holder
290 : rdx, // api_function_address
291 54999 : };
292 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
293 54999 : }
294 :
295 54999 : void InterpreterDispatchDescriptor::InitializePlatformSpecific(
296 : CallInterfaceDescriptorData* data) {
297 : Register registers[] = {
298 : kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
299 54999 : kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
300 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
301 54999 : }
302 :
303 54999 : void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
304 : CallInterfaceDescriptorData* data) {
305 : Register registers[] = {
306 : rax, // argument count (not including receiver)
307 : rbx, // address of first argument
308 : rdi // the target callable to be call
309 54999 : };
310 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
311 54999 : }
312 :
313 54999 : void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
314 : CallInterfaceDescriptorData* data) {
315 : Register registers[] = {
316 : rax, // argument count (not including receiver)
317 : rdx, // new target
318 : rdi, // constructor
319 : rbx, // allocation site feedback if available, undefined otherwise
320 : rcx, // address of first argument
321 54999 : };
322 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
323 54999 : }
324 :
325 54999 : void InterpreterCEntryDescriptor::InitializePlatformSpecific(
326 : CallInterfaceDescriptorData* data) {
327 : Register registers[] = {
328 : rax, // argument count (argc)
329 : r15, // address of first argument (argv)
330 : rbx // the runtime function to call
331 54999 : };
332 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
333 54999 : }
334 :
335 54999 : void ResumeGeneratorDescriptor::InitializePlatformSpecific(
336 : CallInterfaceDescriptorData* data) {
337 : Register registers[] = {
338 : rax, // the value to pass to the generator
339 : rbx, // the JSGeneratorObject / JSAsyncGeneratorObject to resume
340 : rdx // the resume mode (tagged)
341 54999 : };
342 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
343 54999 : }
344 :
345 54999 : void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
346 : CallInterfaceDescriptorData* data) {
347 : Register registers[] = {
348 : rbx, // loaded new FP
349 54999 : };
350 54999 : data->InitializePlatformSpecific(arraysize(registers), registers);
351 54999 : }
352 :
353 : } // namespace internal
354 : } // namespace v8
355 :
356 : #endif // V8_TARGET_ARCH_X64
|