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