5 #include "src/interface-descriptors.h" 7 #include "src/macro-assembler.h" 12 void CallInterfaceDescriptorData::InitializePlatformSpecific(
13 int register_parameter_count,
const Register* registers) {
14 DCHECK(!IsInitializedPlatformIndependent());
16 register_param_count_ = register_parameter_count;
19 register_params_ = NewArray<Register>(register_parameter_count, no_reg);
20 for (
int i = 0;
i < register_parameter_count;
i++) {
23 DCHECK_NE(registers[
i], kRootRegister);
24 register_params_[
i] = registers[
i];
28 void CallInterfaceDescriptorData::InitializePlatformIndependent(
29 Flags flags,
int return_count,
int parameter_count,
30 const MachineType* machine_types,
int machine_types_length) {
31 DCHECK(IsInitializedPlatformSpecific());
34 return_count_ = return_count;
35 param_count_ = parameter_count;
36 const int types_length = return_count_ + param_count_;
39 if (machine_types ==
nullptr) {
41 NewArray<MachineType>(types_length, MachineType::AnyTagged());
43 DCHECK_EQ(machine_types_length, types_length);
44 machine_types_ = NewArray<MachineType>(types_length);
45 for (
int i = 0;
i < types_length;
i++) machine_types_[
i] = machine_types[
i];
48 DCHECK(AllStackParametersAreTagged());
52 bool CallInterfaceDescriptorData::AllStackParametersAreTagged()
const {
53 DCHECK(IsInitialized());
54 const int types_length = return_count_ + param_count_;
55 const int first_stack_param = return_count_ + register_param_count_;
56 for (
int i = first_stack_param;
i < types_length;
i++) {
57 if (!machine_types_[
i].IsTagged())
return false;
63 void CallInterfaceDescriptorData::Reset() {
64 delete[] machine_types_;
65 machine_types_ =
nullptr;
66 delete[] register_params_;
67 register_params_ =
nullptr;
71 CallInterfaceDescriptorData
72 CallDescriptors::call_descriptor_data_[NUMBER_OF_DESCRIPTORS];
74 void CallDescriptors::InitializeOncePerProcess() {
75 #define INTERFACE_DESCRIPTOR(name, ...) \ 76 name##Descriptor().Initialize(&call_descriptor_data_[CallDescriptors::name]); 77 INTERFACE_DESCRIPTOR_LIST(INTERFACE_DESCRIPTOR)
78 #undef INTERFACE_DESCRIPTOR 80 DCHECK(ContextOnlyDescriptor{}.HasContextParameter());
81 DCHECK(!NoContextDescriptor{}.HasContextParameter());
82 DCHECK(!AllocateDescriptor{}.HasContextParameter());
83 DCHECK(!AllocateHeapNumberDescriptor{}.HasContextParameter());
84 DCHECK(!AbortDescriptor{}.HasContextParameter());
87 void CallDescriptors::TearDown() {
88 for (CallInterfaceDescriptorData& data : call_descriptor_data_) {
93 void CallInterfaceDescriptor::JSDefaultInitializePlatformSpecific(
94 CallInterfaceDescriptorData* data,
int non_js_register_parameter_count) {
95 DCHECK_LE(static_cast<unsigned>(non_js_register_parameter_count), 1);
98 int register_parameter_count = 3 + non_js_register_parameter_count;
101 kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
102 kJavaScriptCallArgCountRegister, kJavaScriptCallExtraArg1Register));
104 const Register default_js_stub_registers[] = {
105 kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
106 kJavaScriptCallArgCountRegister, kJavaScriptCallExtraArg1Register};
108 CHECK_LE(static_cast<size_t>(register_parameter_count),
109 arraysize(default_js_stub_registers));
110 data->InitializePlatformSpecific(register_parameter_count,
111 default_js_stub_registers);
114 const char* CallInterfaceDescriptor::DebugName()
const {
115 CallDescriptors::Key key = CallDescriptors::GetKey(data_);
117 #define DEF_CASE(name, ...) \ 118 case CallDescriptors::name: \ 119 return #name " Descriptor"; 120 INTERFACE_DESCRIPTOR_LIST(DEF_CASE)
122 case CallDescriptors::NUMBER_OF_DESCRIPTORS:
129 void VoidDescriptor::InitializePlatformSpecific(
130 CallInterfaceDescriptorData* data) {
131 data->InitializePlatformSpecific(0,
nullptr);
134 void AllocateDescriptor::InitializePlatformSpecific(
135 CallInterfaceDescriptorData* data) {
136 Register registers[] = {kAllocateSizeRegister};
137 data->InitializePlatformSpecific(arraysize(registers), registers);
140 void CEntry1ArgvOnStackDescriptor::InitializePlatformSpecific(
141 CallInterfaceDescriptorData* data) {
142 Register registers[] = {kRuntimeCallArgCountRegister,
143 kRuntimeCallFunctionRegister};
144 data->InitializePlatformSpecific(arraysize(registers), registers);
149 void InterpreterCEntryDescriptor_InitializePlatformSpecific(
150 CallInterfaceDescriptorData* data) {
151 Register registers[] = {kRuntimeCallArgCountRegister,
152 kRuntimeCallArgvRegister,
153 kRuntimeCallFunctionRegister};
154 data->InitializePlatformSpecific(arraysize(registers), registers);
159 void InterpreterCEntry1Descriptor::InitializePlatformSpecific(
160 CallInterfaceDescriptorData* data) {
161 InterpreterCEntryDescriptor_InitializePlatformSpecific(data);
164 void InterpreterCEntry2Descriptor::InitializePlatformSpecific(
165 CallInterfaceDescriptorData* data) {
166 InterpreterCEntryDescriptor_InitializePlatformSpecific(data);
169 void FastNewFunctionContextDescriptor::InitializePlatformSpecific(
170 CallInterfaceDescriptorData* data) {
171 Register registers[] = {ScopeInfoRegister(), SlotsRegister()};
172 data->InitializePlatformSpecific(arraysize(registers), registers);
175 void FastNewObjectDescriptor::InitializePlatformSpecific(
176 CallInterfaceDescriptorData* data) {
177 Register registers[] = {TargetRegister(), NewTargetRegister()};
178 data->InitializePlatformSpecific(arraysize(registers), registers);
181 const Register FastNewObjectDescriptor::TargetRegister() {
182 return kJSFunctionRegister;
185 const Register FastNewObjectDescriptor::NewTargetRegister() {
186 return kJavaScriptCallNewTargetRegister;
190 void LoadDescriptor::InitializePlatformSpecific(
191 CallInterfaceDescriptorData* data) {
192 Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister()};
193 data->InitializePlatformSpecific(arraysize(registers), registers);
196 void LoadGlobalDescriptor::InitializePlatformSpecific(
197 CallInterfaceDescriptorData* data) {
198 Register registers[] = {NameRegister(), SlotRegister()};
199 data->InitializePlatformSpecific(arraysize(registers), registers);
202 void LoadGlobalWithVectorDescriptor::InitializePlatformSpecific(
203 CallInterfaceDescriptorData* data) {
204 Register registers[] = {NameRegister(), SlotRegister(), VectorRegister()};
205 data->InitializePlatformSpecific(arraysize(registers), registers);
208 void StoreGlobalDescriptor::InitializePlatformSpecific(
209 CallInterfaceDescriptorData* data) {
210 Register registers[] = {NameRegister(), ValueRegister(), SlotRegister()};
212 int len = arraysize(registers) - kStackArgumentsCount;
213 data->InitializePlatformSpecific(len, registers);
216 void StoreGlobalWithVectorDescriptor::InitializePlatformSpecific(
217 CallInterfaceDescriptorData* data) {
218 Register registers[] = {NameRegister(), ValueRegister(), SlotRegister(),
220 int len = arraysize(registers) - kStackArgumentsCount;
221 data->InitializePlatformSpecific(len, registers);
224 void StoreDescriptor::InitializePlatformSpecific(
225 CallInterfaceDescriptorData* data) {
226 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
229 int len = arraysize(registers) - kStackArgumentsCount;
230 data->InitializePlatformSpecific(len, registers);
233 void StoreTransitionDescriptor::InitializePlatformSpecific(
234 CallInterfaceDescriptorData* data) {
235 Register registers[] = {
236 ReceiverRegister(), NameRegister(), MapRegister(),
237 ValueRegister(), SlotRegister(), VectorRegister(),
239 int len = arraysize(registers) - kStackArgumentsCount;
240 data->InitializePlatformSpecific(len, registers);
243 void StringAtDescriptor::InitializePlatformSpecific(
244 CallInterfaceDescriptorData* data) {
245 DefaultInitializePlatformSpecific(data, kParameterCount);
248 void StringSubstringDescriptor::InitializePlatformSpecific(
249 CallInterfaceDescriptorData* data) {
250 DefaultInitializePlatformSpecific(data, kParameterCount);
253 void TypeConversionDescriptor::InitializePlatformSpecific(
254 CallInterfaceDescriptorData* data) {
255 Register registers[] = {ArgumentRegister()};
256 data->InitializePlatformSpecific(arraysize(registers), registers);
259 void TypeConversionStackParameterDescriptor::InitializePlatformSpecific(
260 CallInterfaceDescriptorData* data) {
261 data->InitializePlatformSpecific(0,
nullptr);
264 void AsyncFunctionStackParameterDescriptor::InitializePlatformSpecific(
265 CallInterfaceDescriptorData* data) {
266 data->InitializePlatformSpecific(0,
nullptr);
269 void LoadWithVectorDescriptor::InitializePlatformSpecific(
270 CallInterfaceDescriptorData* data) {
271 Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister(),
277 int len = arraysize(registers) - kStackArgumentsCount;
278 data->InitializePlatformSpecific(len, registers);
281 void StoreWithVectorDescriptor::InitializePlatformSpecific(
282 CallInterfaceDescriptorData* data) {
283 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
284 SlotRegister(), VectorRegister()};
288 int len = arraysize(registers) - kStackArgumentsCount;
289 data->InitializePlatformSpecific(len, registers);
292 const Register ApiGetterDescriptor::ReceiverRegister() {
293 return LoadDescriptor::ReceiverRegister();
296 void ApiGetterDescriptor::InitializePlatformSpecific(
297 CallInterfaceDescriptorData* data) {
298 Register registers[] = {ReceiverRegister(), HolderRegister(),
300 data->InitializePlatformSpecific(arraysize(registers), registers);
303 void ContextOnlyDescriptor::InitializePlatformSpecific(
304 CallInterfaceDescriptorData* data) {
305 data->InitializePlatformSpecific(0,
nullptr);
308 void NoContextDescriptor::InitializePlatformSpecific(
309 CallInterfaceDescriptorData* data) {
310 data->InitializePlatformSpecific(0,
nullptr);
313 void GrowArrayElementsDescriptor::InitializePlatformSpecific(
314 CallInterfaceDescriptorData* data) {
315 Register registers[] = {ObjectRegister(), KeyRegister()};
316 data->InitializePlatformSpecific(arraysize(registers), registers);
319 void NewArgumentsElementsDescriptor::InitializePlatformSpecific(
320 CallInterfaceDescriptorData* data) {
321 DefaultInitializePlatformSpecific(data, 3);
324 void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
325 CallInterfaceDescriptorData* data) {
328 ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(data);
331 void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
332 CallInterfaceDescriptorData* data) {
335 ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(data);
338 void ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(
339 CallInterfaceDescriptorData* data) {
343 Register registers[] = {kJavaScriptCallTargetRegister,
344 kJavaScriptCallExtraArg1Register,
345 kJavaScriptCallArgCountRegister};
346 data->InitializePlatformSpecific(arraysize(registers), registers);
349 void WasmMemoryGrowDescriptor::InitializePlatformSpecific(
350 CallInterfaceDescriptorData* data) {
351 DefaultInitializePlatformSpecific(data, kParameterCount);
354 void WasmThrowDescriptor::InitializePlatformSpecific(
355 CallInterfaceDescriptorData* data) {
356 DefaultInitializePlatformSpecific(data, kParameterCount);
359 void WasmAtomicWakeDescriptor::InitializePlatformSpecific(
360 CallInterfaceDescriptorData* data) {
361 DefaultInitializePlatformSpecific(data, kParameterCount);
364 void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
365 CallInterfaceDescriptorData* data) {
366 DefaultInitializePlatformSpecific(data, kParameterCount);
369 void CloneObjectWithVectorDescriptor::InitializePlatformSpecific(
370 CallInterfaceDescriptorData* data) {
371 DefaultInitializePlatformSpecific(data, kParameterCount);