Chromium Code Reviews| Index: src/compiler/wasm-linkage.cc |
| diff --git a/src/compiler/wasm-linkage.cc b/src/compiler/wasm-linkage.cc |
| index cfeb6c523f03d5f721d3b260858c82cc6cadc7ed..fcf0ef3132bf53afa05267e13a7ad00c30051aec 100644 |
| --- a/src/compiler/wasm-linkage.cc |
| +++ b/src/compiler/wasm-linkage.cc |
| @@ -22,6 +22,7 @@ using compiler::CallDescriptor; |
| using compiler::LinkageLocation; |
| namespace { |
| + |
| MachineType MachineTypeFor(LocalType type) { |
| switch (type) { |
| case kAstI32: |
| @@ -40,20 +41,17 @@ MachineType MachineTypeFor(LocalType type) { |
| } |
| } |
| - |
| // Platform-specific configuration for C calling convention. |
|
titzer
2016/07/08 07:46:23
Comment is wrong here.
danno
2016/07/08 15:22:10
Done.
|
| -LinkageLocation regloc(Register reg) { |
| - return LinkageLocation::ForRegister(reg.code()); |
| +LinkageLocation regloc(Register reg, MachineType type) { |
| + return LinkageLocation::ForRegister(reg.code(), type); |
| } |
| - |
| -LinkageLocation regloc(DoubleRegister reg) { |
| - return LinkageLocation::ForRegister(reg.code()); |
| +LinkageLocation regloc(DoubleRegister reg, MachineType type) { |
| + return LinkageLocation::ForRegister(reg.code(), type); |
| } |
| - |
| -LinkageLocation stackloc(int i) { |
| - return LinkageLocation::ForCallerFrameSlot(i); |
| +LinkageLocation stackloc(int i, MachineType type) { |
| + return LinkageLocation::ForCallerFrameSlot(i, type); |
| } |
| @@ -187,23 +185,24 @@ struct Allocator { |
| if (type == kAstF32) { |
| int float_reg_code = reg.code() * 2; |
| DCHECK(float_reg_code < RegisterConfiguration::kMaxFPRegisters); |
| - return regloc(DoubleRegister::from_code(float_reg_code)); |
| + return regloc(DoubleRegister::from_code(float_reg_code), |
| + MachineTypeFor(type)); |
| } |
| #endif |
| - return regloc(reg); |
| + return regloc(reg, MachineTypeFor(type)); |
| } else { |
| int offset = -1 - stack_offset; |
| stack_offset += Words(type); |
| - return stackloc(offset); |
| + return stackloc(offset, MachineTypeFor(type)); |
| } |
| } else { |
| // Allocate a general purpose register/stack location. |
| if (gp_offset < gp_count) { |
| - return regloc(gp_regs[gp_offset++]); |
| + return regloc(gp_regs[gp_offset++], MachineTypeFor(type)); |
| } else { |
| int offset = -1 - stack_offset; |
| stack_offset += Words(type); |
| - return stackloc(offset); |
| + return stackloc(offset, MachineTypeFor(type)); |
| } |
| } |
| } |
| @@ -272,8 +271,6 @@ static Allocator GetParameterRegisters() { |
| // General code uses the above configuration data. |
| CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, |
| FunctionSig* fsig) { |
| - MachineSignature::Builder msig(zone, fsig->return_count(), |
| - fsig->parameter_count()); |
| LocationSignature::Builder locations(zone, fsig->return_count(), |
| fsig->parameter_count()); |
| @@ -283,7 +280,6 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, |
| const int return_count = static_cast<int>(locations.return_count_); |
| for (int i = 0; i < return_count; i++) { |
| LocalType ret = fsig->GetReturn(i); |
| - msig.AddReturn(MachineTypeFor(ret)); |
| locations.AddReturn(rets.Next(ret)); |
| } |
| @@ -293,7 +289,6 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, |
| const int parameter_count = static_cast<int>(fsig->parameter_count()); |
| for (int i = 0; i < parameter_count; i++) { |
| LocalType param = fsig->GetParam(i); |
| - msig.AddParam(MachineTypeFor(param)); |
| locations.AddParam(params.Next(param)); |
| } |
| @@ -302,13 +297,12 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, |
| // The target for WASM calls is always a code object. |
| MachineType target_type = MachineType::AnyTagged(); |
| - LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
| + LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type); |
| return new (zone) CallDescriptor( // -- |
| CallDescriptor::kCallCodeObject, // kind |
| target_type, // target MachineType |
| target_loc, // target location |
| - msig.Build(), // machine_sig |
| locations.Build(), // location_sig |
| params.stack_offset, // stack_parameter_count |
| compiler::Operator::kNoProperties, // properties |
| @@ -320,58 +314,52 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, |
| CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
| Zone* zone, CallDescriptor* descriptor) { |
| - const MachineSignature* signature = descriptor->GetMachineSignature(); |
| - size_t parameter_count = signature->parameter_count(); |
| - size_t return_count = signature->return_count(); |
| - for (size_t i = 0; i < signature->parameter_count(); i++) { |
| - if (signature->GetParam(i) == MachineType::Int64()) { |
| + 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++; |
| } |
| } |
| - for (size_t i = 0; i < signature->return_count(); i++) { |
| - if (signature->GetReturn(i) == MachineType::Int64()) { |
| + 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 (parameter_count == signature->parameter_count() && |
| - return_count == signature->return_count()) { |
| + 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; |
| } |
| - MachineSignature::Builder msig(zone, return_count, parameter_count); |
| LocationSignature::Builder locations(zone, return_count, parameter_count); |
| Allocator rets = GetReturnRegisters(); |
| - for (size_t i = 0; i < signature->return_count(); i++) { |
| - if (signature->GetReturn(i) == MachineType::Int64()) { |
| + for (size_t i = 0; i < descriptor->ReturnCount(); i++) { |
| + if (descriptor->GetReturnType(i) == MachineType::Int64()) { |
| // For each int64 return we get two int32 returns. |
| - msig.AddReturn(MachineType::Int32()); |
| - msig.AddReturn(MachineType::Int32()); |
| locations.AddReturn(rets.Next(MachineRepresentation::kWord32)); |
| locations.AddReturn(rets.Next(MachineRepresentation::kWord32)); |
| } else { |
| - msig.AddReturn(signature->GetReturn(i)); |
| - locations.AddReturn(rets.Next(signature->GetReturn(i).representation())); |
| + locations.AddReturn( |
| + rets.Next(descriptor->GetReturnType(i).representation())); |
| } |
| } |
| Allocator params = GetParameterRegisters(); |
| - for (size_t i = 0; i < signature->parameter_count(); i++) { |
| - if (signature->GetParam(i) == MachineType::Int64()) { |
| + for (size_t i = 0; i < descriptor->ParameterCount(); i++) { |
| + if (descriptor->GetParameterType(i) == MachineType::Int64()) { |
| // For each int64 input we get two int32 inputs. |
| - msig.AddParam(MachineType::Int32()); |
| - msig.AddParam(MachineType::Int32()); |
| locations.AddParam(params.Next(MachineRepresentation::kWord32)); |
| locations.AddParam(params.Next(MachineRepresentation::kWord32)); |
| } else { |
| - msig.AddParam(signature->GetParam(i)); |
| - locations.AddParam(params.Next(signature->GetParam(i).representation())); |
| + locations.AddParam( |
| + params.Next(descriptor->GetParameterType(i).representation())); |
| } |
| } |
| @@ -379,7 +367,6 @@ CallDescriptor* ModuleEnv::GetI32WasmCallDescriptor( |
| descriptor->kind(), // kind |
| descriptor->GetInputType(0), // target MachineType |
| descriptor->GetInputLocation(0), // target location |
| - msig.Build(), // machine_sig |
| locations.Build(), // location_sig |
| params.stack_offset, // stack_parameter_count |
| descriptor->properties(), // properties |