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 11527488 : void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
17 : CallInterfaceDescriptorData* data, int register_parameter_count) {
18 11527488 : const Register default_stub_registers[] = {rax, rbx, rcx, rdx, rdi};
19 11527488 : CHECK_LE(static_cast<size_t>(register_parameter_count),
20 : arraysize(default_stub_registers));
21 : data->InitializePlatformSpecific(register_parameter_count,
22 11527488 : default_stub_registers);
23 11527488 : }
24 :
25 60992 : void RecordWriteDescriptor::InitializePlatformSpecific(
26 : CallInterfaceDescriptorData* data) {
27 : const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
28 60992 : 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 60992 : data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
36 60992 : }
37 :
38 60992 : void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
39 : CallInterfaceDescriptorData* data) {
40 : const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
41 60992 : 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 60992 : data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
49 60992 : }
50 :
51 60992 : const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
52 60992 : return rdi;
53 : }
54 60992 : const Register FastNewFunctionContextDescriptor::SlotsRegister() { return rax; }
55 :
56 183032 : const Register LoadDescriptor::ReceiverRegister() { return rdx; }
57 243968 : const Register LoadDescriptor::NameRegister() { return rcx; }
58 243968 : const Register LoadDescriptor::SlotRegister() { return rax; }
59 :
60 121984 : const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }
61 :
62 182976 : const Register StoreDescriptor::ReceiverRegister() { return rdx; }
63 304960 : const Register StoreDescriptor::NameRegister() { return rcx; }
64 304960 : const Register StoreDescriptor::ValueRegister() { return rax; }
65 243968 : const Register StoreDescriptor::SlotRegister() { return rdi; }
66 :
67 121984 : const Register StoreWithVectorDescriptor::VectorRegister() { return rbx; }
68 :
69 60992 : const Register StoreTransitionDescriptor::SlotRegister() { return rdi; }
70 60992 : const Register StoreTransitionDescriptor::VectorRegister() { return rbx; }
71 60992 : const Register StoreTransitionDescriptor::MapRegister() { return r11; }
72 :
73 61048 : const Register ApiGetterDescriptor::HolderRegister() { return rcx; }
74 61048 : const Register ApiGetterDescriptor::CallbackRegister() { return rbx; }
75 :
76 60992 : const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
77 60992 : const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
78 :
79 :
80 60992 : void TypeofDescriptor::InitializePlatformSpecific(
81 : CallInterfaceDescriptorData* data) {
82 60992 : Register registers[] = {rbx};
83 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
84 60992 : }
85 :
86 :
87 : // static
88 60992 : const Register TypeConversionDescriptor::ArgumentRegister() { return rax; }
89 :
90 60992 : void CallTrampolineDescriptor::InitializePlatformSpecific(
91 : CallInterfaceDescriptorData* data) {
92 : // rax : number of arguments
93 : // rdi : the target to call
94 60992 : Register registers[] = {rdi, rax};
95 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
96 60992 : }
97 :
98 60992 : 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 60992 : Register registers[] = {rdi, rax, rcx, rbx};
105 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
106 60992 : }
107 :
108 60992 : 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 60992 : Register registers[] = {rdi, rax, rcx};
114 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
115 60992 : }
116 :
117 60992 : void CallFunctionTemplateDescriptor::InitializePlatformSpecific(
118 : CallInterfaceDescriptorData* data) {
119 : // rdx: the function template info
120 : // rcx: number of arguments (on the stack, not including receiver)
121 60992 : Register registers[] = {rdx, rcx};
122 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
123 60992 : }
124 :
125 60992 : 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 60992 : Register registers[] = {rdi, rax, rbx};
131 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
132 60992 : }
133 :
134 60992 : void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
135 : CallInterfaceDescriptorData* data) {
136 : // rdi : the target to call
137 : // rbx : the arguments list
138 60992 : Register registers[] = {rdi, rbx};
139 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
140 60992 : }
141 :
142 60992 : 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 60992 : Register registers[] = {rdi, rdx, rax, rcx, rbx};
150 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
151 60992 : }
152 :
153 60992 : 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 60992 : Register registers[] = {rdi, rdx, rax, rcx};
160 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
161 60992 : }
162 :
163 60992 : 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 60992 : Register registers[] = {rdi, rdx, rax, rbx};
170 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
171 60992 : }
172 :
173 60992 : void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
174 : CallInterfaceDescriptorData* data) {
175 : // rdi : the target to call
176 : // rdx : the new target
177 : // rbx : the arguments list
178 60992 : Register registers[] = {rdi, rdx, rbx};
179 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
180 60992 : }
181 :
182 60992 : 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 60992 : Register registers[] = {rdi, rdx, rax, rbx};
189 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
190 60992 : }
191 :
192 60992 : void AbortDescriptor::InitializePlatformSpecific(
193 : CallInterfaceDescriptorData* data) {
194 60992 : Register registers[] = {rdx};
195 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
196 60992 : }
197 :
198 60992 : void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
199 : CallInterfaceDescriptorData* data) {
200 60992 : data->InitializePlatformSpecific(0, nullptr);
201 60992 : }
202 :
203 60992 : void CompareDescriptor::InitializePlatformSpecific(
204 : CallInterfaceDescriptorData* data) {
205 60992 : Register registers[] = {rdx, rax};
206 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
207 60992 : }
208 :
209 60992 : void BinaryOpDescriptor::InitializePlatformSpecific(
210 : CallInterfaceDescriptorData* data) {
211 60992 : Register registers[] = {rdx, rax};
212 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
213 60992 : }
214 :
215 60992 : 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 60992 : };
223 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
224 60992 : }
225 :
226 60992 : 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 60992 : };
234 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
235 60992 : }
236 :
237 60992 : void InterpreterDispatchDescriptor::InitializePlatformSpecific(
238 : CallInterfaceDescriptorData* data) {
239 : Register registers[] = {
240 : kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
241 60992 : kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
242 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
243 60992 : }
244 :
245 60992 : 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 60992 : };
252 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
253 60992 : }
254 :
255 60992 : 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 60992 : };
264 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
265 60992 : }
266 :
267 60992 : 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 60992 : };
273 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
274 60992 : }
275 :
276 60992 : void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
277 : CallInterfaceDescriptorData* data) {
278 : Register registers[] = {
279 : rbx, // loaded new FP
280 60992 : };
281 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
282 60992 : }
283 :
284 60992 : void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
285 : CallInterfaceDescriptorData* data) {
286 60992 : Register registers[] = {arg_reg_1, arg_reg_2};
287 60992 : data->InitializePlatformSpecific(arraysize(registers), registers);
288 60992 : }
289 :
290 : } // namespace internal
291 122004 : } // namespace v8
292 :
293 : #endif // V8_TARGET_ARCH_X64
|