| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/assembler.h" | 5 #include "src/assembler.h" |
| 6 #include "src/base/lazy-instance.h" | 6 #include "src/base/lazy-instance.h" |
| 7 #include "src/macro-assembler.h" | 7 #include "src/macro-assembler.h" |
| 8 #include "src/register-configuration.h" | 8 #include "src/register-configuration.h" |
| 9 | 9 |
| 10 #include "src/wasm/wasm-module.h" | 10 #include "src/wasm/wasm-module.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 target_loc, // target location | 300 target_loc, // target location |
| 301 locations.Build(), // location_sig | 301 locations.Build(), // location_sig |
| 302 params.stack_offset, // stack_parameter_count | 302 params.stack_offset, // stack_parameter_count |
| 303 compiler::Operator::kNoProperties, // properties | 303 compiler::Operator::kNoProperties, // properties |
| 304 kCalleeSaveRegisters, // callee-saved registers | 304 kCalleeSaveRegisters, // callee-saved registers |
| 305 kCalleeSaveFPRegisters, // callee-saved fp regs | 305 kCalleeSaveFPRegisters, // callee-saved fp regs |
| 306 CallDescriptor::kUseNativeStack, // flags | 306 CallDescriptor::kUseNativeStack, // flags |
| 307 "wasm-call"); | 307 "wasm-call"); |
| 308 } | 308 } |
| 309 | 309 |
| 310 CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( | 310 CallDescriptor* ReplaceTypeInCallDescriptorWith( |
| 311 Zone* zone, CallDescriptor* descriptor) { | 311 Zone* zone, CallDescriptor* descriptor, size_t num_replacements, |
| 312 MachineType input_type, MachineRepresentation output_type) { |
| 312 size_t parameter_count = descriptor->ParameterCount(); | 313 size_t parameter_count = descriptor->ParameterCount(); |
| 313 size_t return_count = descriptor->ReturnCount(); | 314 size_t return_count = descriptor->ReturnCount(); |
| 314 for (size_t i = 0; i < descriptor->ParameterCount(); i++) { | 315 for (size_t i = 0; i < descriptor->ParameterCount(); i++) { |
| 315 if (descriptor->GetParameterType(i) == MachineType::Int64()) { | 316 if (descriptor->GetParameterType(i) == input_type) { |
| 316 // For each int64 input we get two int32 inputs. | 317 parameter_count += num_replacements - 1; |
| 317 parameter_count++; | |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 for (size_t i = 0; i < descriptor->ReturnCount(); i++) { | 320 for (size_t i = 0; i < descriptor->ReturnCount(); i++) { |
| 321 if (descriptor->GetReturnType(i) == MachineType::Int64()) { | 321 if (descriptor->GetReturnType(i) == input_type) { |
| 322 // For each int64 return we get two int32 returns. | 322 return_count += num_replacements - 1; |
| 323 return_count++; | |
| 324 } | 323 } |
| 325 } | 324 } |
| 326 if (parameter_count == descriptor->ParameterCount() && | 325 if (parameter_count == descriptor->ParameterCount() && |
| 327 return_count == descriptor->ReturnCount()) { | 326 return_count == descriptor->ReturnCount()) { |
| 328 // If there is no int64 parameter or return value, we can just return the | |
| 329 // original descriptor. | |
| 330 return descriptor; | 327 return descriptor; |
| 331 } | 328 } |
| 332 | 329 |
| 333 LocationSignature::Builder locations(zone, return_count, parameter_count); | 330 LocationSignature::Builder locations(zone, return_count, parameter_count); |
| 334 | 331 |
| 335 Allocator rets = return_registers.Get(); | 332 Allocator rets = return_registers.Get(); |
| 336 | 333 |
| 337 for (size_t i = 0; i < descriptor->ReturnCount(); i++) { | 334 for (size_t i = 0; i < descriptor->ReturnCount(); i++) { |
| 338 if (descriptor->GetReturnType(i) == MachineType::Int64()) { | 335 if (descriptor->GetReturnType(i) == input_type) { |
| 339 // For each int64 return we get two int32 returns. | 336 for (size_t j = 0; j < num_replacements; j++) { |
| 340 locations.AddReturn(rets.Next(MachineRepresentation::kWord32)); | 337 locations.AddReturn(rets.Next(output_type)); |
| 341 locations.AddReturn(rets.Next(MachineRepresentation::kWord32)); | 338 } |
| 342 } else { | 339 } else { |
| 343 locations.AddReturn( | 340 locations.AddReturn( |
| 344 rets.Next(descriptor->GetReturnType(i).representation())); | 341 rets.Next(descriptor->GetReturnType(i).representation())); |
| 345 } | 342 } |
| 346 } | 343 } |
| 347 | 344 |
| 348 Allocator params = parameter_registers.Get(); | 345 Allocator params = parameter_registers.Get(); |
| 349 | 346 |
| 350 for (size_t i = 0; i < descriptor->ParameterCount(); i++) { | 347 for (size_t i = 0; i < descriptor->ParameterCount(); i++) { |
| 351 if (descriptor->GetParameterType(i) == MachineType::Int64()) { | 348 if (descriptor->GetParameterType(i) == input_type) { |
| 352 // For each int64 input we get two int32 inputs. | 349 for (size_t j = 0; j < num_replacements; j++) { |
| 353 locations.AddParam(params.Next(MachineRepresentation::kWord32)); | 350 locations.AddParam(params.Next(output_type)); |
| 354 locations.AddParam(params.Next(MachineRepresentation::kWord32)); | 351 } |
| 355 } else { | 352 } else { |
| 356 locations.AddParam( | 353 locations.AddParam( |
| 357 params.Next(descriptor->GetParameterType(i).representation())); | 354 params.Next(descriptor->GetParameterType(i).representation())); |
| 358 } | 355 } |
| 359 } | 356 } |
| 360 | 357 |
| 361 return new (zone) CallDescriptor( // -- | 358 return new (zone) CallDescriptor( // -- |
| 362 descriptor->kind(), // kind | 359 descriptor->kind(), // kind |
| 363 descriptor->GetInputType(0), // target MachineType | 360 descriptor->GetInputType(0), // target MachineType |
| 364 descriptor->GetInputLocation(0), // target location | 361 descriptor->GetInputLocation(0), // target location |
| 365 locations.Build(), // location_sig | 362 locations.Build(), // location_sig |
| 366 params.stack_offset, // stack_parameter_count | 363 params.stack_offset, // stack_parameter_count |
| 367 descriptor->properties(), // properties | 364 descriptor->properties(), // properties |
| 368 descriptor->CalleeSavedRegisters(), // callee-saved registers | 365 descriptor->CalleeSavedRegisters(), // callee-saved registers |
| 369 descriptor->CalleeSavedFPRegisters(), // callee-saved fp regs | 366 descriptor->CalleeSavedFPRegisters(), // callee-saved fp regs |
| 370 descriptor->flags(), // flags | 367 descriptor->flags(), // flags |
| 371 descriptor->debug_name()); | 368 descriptor->debug_name()); |
| 369 } |
| 372 | 370 |
| 373 return descriptor; | 371 CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
| 372 Zone* zone, CallDescriptor* descriptor) { |
| 373 return ReplaceTypeInCallDescriptorWith(zone, descriptor, 2, |
| 374 MachineType::Int64(), |
| 375 MachineRepresentation::kWord32); |
| 376 } |
| 377 |
| 378 CallDescriptor* ModuleEnv::GetI32WasmCallDescriptorForSimd( |
| 379 Zone* zone, CallDescriptor* descriptor) { |
| 380 return ReplaceTypeInCallDescriptorWith(zone, descriptor, 4, |
| 381 MachineType::Simd128(), |
| 382 MachineRepresentation::kWord32); |
| 374 } | 383 } |
| 375 | 384 |
| 376 } // namespace wasm | 385 } // namespace wasm |
| 377 } // namespace internal | 386 } // namespace internal |
| 378 } // namespace v8 | 387 } // namespace v8 |
| OLD | NEW |