Index: src/compiler/wasm-linkage.cc |
diff --git a/src/compiler/wasm-linkage.cc b/src/compiler/wasm-linkage.cc |
index 574db1cfef2f7795e059db80ab15b8a76b699963..5dfcbcc552c5c08844954d84412a380cbafa7a57 100644 |
--- a/src/compiler/wasm-linkage.cc |
+++ b/src/compiler/wasm-linkage.cc |
@@ -307,26 +307,23 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, |
"wasm-call"); |
} |
-CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
- Zone* zone, CallDescriptor* descriptor) { |
+CallDescriptor* ReplaceTypeInCallDescriptorWith( |
+ Zone* zone, CallDescriptor* descriptor, size_t num_replacements, |
+ MachineType input_type, MachineRepresentation output_type) { |
size_t parameter_count = descriptor->ParameterCount(); |
size_t return_count = descriptor->ReturnCount(); |
for (size_t i = 0; i < descriptor->ParameterCount(); i++) { |
- if (descriptor->GetParameterType(i) == MachineType::Int64()) { |
- // For each int64 input we get two int32 inputs. |
- parameter_count++; |
+ if (descriptor->GetParameterType(i) == input_type) { |
+ parameter_count += num_replacements - 1; |
} |
} |
for (size_t i = 0; i < descriptor->ReturnCount(); i++) { |
- if (descriptor->GetReturnType(i) == MachineType::Int64()) { |
- // For each int64 return we get two int32 returns. |
- return_count++; |
+ if (descriptor->GetReturnType(i) == input_type) { |
+ return_count += num_replacements - 1; |
} |
} |
if (parameter_count == descriptor->ParameterCount() && |
return_count == descriptor->ReturnCount()) { |
- // If there is no int64 parameter or return value, we can just return the |
- // original descriptor. |
return descriptor; |
} |
@@ -335,10 +332,10 @@ CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
Allocator rets = return_registers.Get(); |
for (size_t i = 0; i < descriptor->ReturnCount(); i++) { |
- if (descriptor->GetReturnType(i) == MachineType::Int64()) { |
- // For each int64 return we get two int32 returns. |
- locations.AddReturn(rets.Next(MachineRepresentation::kWord32)); |
- locations.AddReturn(rets.Next(MachineRepresentation::kWord32)); |
+ if (descriptor->GetReturnType(i) == input_type) { |
+ for (size_t j = 0; j < num_replacements; j++) { |
+ locations.AddReturn(rets.Next(output_type)); |
+ } |
} else { |
locations.AddReturn( |
rets.Next(descriptor->GetReturnType(i).representation())); |
@@ -348,10 +345,10 @@ CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
Allocator params = parameter_registers.Get(); |
for (size_t i = 0; i < descriptor->ParameterCount(); i++) { |
- if (descriptor->GetParameterType(i) == MachineType::Int64()) { |
- // For each int64 input we get two int32 inputs. |
- locations.AddParam(params.Next(MachineRepresentation::kWord32)); |
- locations.AddParam(params.Next(MachineRepresentation::kWord32)); |
+ if (descriptor->GetParameterType(i) == input_type) { |
+ for (size_t j = 0; j < num_replacements; j++) { |
+ locations.AddParam(params.Next(output_type)); |
+ } |
} else { |
locations.AddParam( |
params.Next(descriptor->GetParameterType(i).representation())); |
@@ -369,8 +366,20 @@ CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
descriptor->CalleeSavedFPRegisters(), // callee-saved fp regs |
descriptor->flags(), // flags |
descriptor->debug_name()); |
+} |
- return descriptor; |
+CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
+ Zone* zone, CallDescriptor* descriptor) { |
+ return ReplaceTypeInCallDescriptorWith(zone, descriptor, 2, |
+ MachineType::Int64(), |
+ MachineRepresentation::kWord32); |
+} |
+ |
+CallDescriptor* ModuleEnv::GetI32WasmCallDescriptorForSimd( |
+ Zone* zone, CallDescriptor* descriptor) { |
+ return ReplaceTypeInCallDescriptorWith(zone, descriptor, 4, |
+ MachineType::Simd128(), |
+ MachineRepresentation::kWord32); |
} |
} // namespace wasm |