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