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