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