Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/wasm-linkage.cc

Issue 2594993002: [wasm] Rename wasm::LocalType to wasm::ValueType and kAst* to kWasm* (Closed)
Patch Set: Fix inspector tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/function-body-decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 #include "src/compiler/linkage.h" 12 #include "src/compiler/linkage.h"
13 13
14 #include "src/zone/zone.h" 14 #include "src/zone/zone.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 // TODO(titzer): this should not be in the WASM namespace. 18 // TODO(titzer): this should not be in the WASM namespace.
19 namespace wasm { 19 namespace wasm {
20 20
21 using compiler::LocationSignature; 21 using compiler::LocationSignature;
22 using compiler::CallDescriptor; 22 using compiler::CallDescriptor;
23 using compiler::LinkageLocation; 23 using compiler::LinkageLocation;
24 24
25 namespace { 25 namespace {
26 26
27 MachineType MachineTypeFor(LocalType type) { 27 MachineType MachineTypeFor(ValueType type) {
28 switch (type) { 28 switch (type) {
29 case kAstI32: 29 case kWasmI32:
30 return MachineType::Int32(); 30 return MachineType::Int32();
31 case kAstI64: 31 case kWasmI64:
32 return MachineType::Int64(); 32 return MachineType::Int64();
33 case kAstF64: 33 case kWasmF64:
34 return MachineType::Float64(); 34 return MachineType::Float64();
35 case kAstF32: 35 case kWasmF32:
36 return MachineType::Float32(); 36 return MachineType::Float32();
37 case kAstS128: 37 case kWasmS128:
38 return MachineType::Simd128(); 38 return MachineType::Simd128();
39 default: 39 default:
40 UNREACHABLE(); 40 UNREACHABLE();
41 return MachineType::AnyTagged(); 41 return MachineType::AnyTagged();
42 } 42 }
43 } 43 }
44 44
45 LinkageLocation regloc(Register reg, MachineType type) { 45 LinkageLocation regloc(Register reg, MachineType type) {
46 return LinkageLocation::ForRegister(reg.code(), type); 46 return LinkageLocation::ForRegister(reg.code(), type);
47 } 47 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 int gp_count; 166 int gp_count;
167 int gp_offset; 167 int gp_offset;
168 const Register* gp_regs; 168 const Register* gp_regs;
169 169
170 int fp_count; 170 int fp_count;
171 int fp_offset; 171 int fp_offset;
172 const DoubleRegister* fp_regs; 172 const DoubleRegister* fp_regs;
173 173
174 int stack_offset; 174 int stack_offset;
175 175
176 LinkageLocation Next(LocalType type) { 176 LinkageLocation Next(ValueType type) {
177 if (IsFloatingPoint(type)) { 177 if (IsFloatingPoint(type)) {
178 // Allocate a floating point register/stack location. 178 // Allocate a floating point register/stack location.
179 if (fp_offset < fp_count) { 179 if (fp_offset < fp_count) {
180 DoubleRegister reg = fp_regs[fp_offset++]; 180 DoubleRegister reg = fp_regs[fp_offset++];
181 #if V8_TARGET_ARCH_ARM 181 #if V8_TARGET_ARCH_ARM
182 // Allocate floats using a double register, but modify the code to 182 // Allocate floats using a double register, but modify the code to
183 // reflect how ARM FP registers alias. 183 // reflect how ARM FP registers alias.
184 // TODO(bbudge) Modify wasm linkage to allow use of all float regs. 184 // TODO(bbudge) Modify wasm linkage to allow use of all float regs.
185 if (type == kAstF32) { 185 if (type == kWasmF32) {
186 int float_reg_code = reg.code() * 2; 186 int float_reg_code = reg.code() * 2;
187 DCHECK(float_reg_code < RegisterConfiguration::kMaxFPRegisters); 187 DCHECK(float_reg_code < RegisterConfiguration::kMaxFPRegisters);
188 return regloc(DoubleRegister::from_code(float_reg_code), 188 return regloc(DoubleRegister::from_code(float_reg_code),
189 MachineTypeFor(type)); 189 MachineTypeFor(type));
190 } 190 }
191 #endif 191 #endif
192 return regloc(reg, MachineTypeFor(type)); 192 return regloc(reg, MachineTypeFor(type));
193 } else { 193 } else {
194 int offset = -1 - stack_offset; 194 int offset = -1 - stack_offset;
195 stack_offset += Words(type); 195 stack_offset += Words(type);
196 return stackloc(offset, MachineTypeFor(type)); 196 return stackloc(offset, MachineTypeFor(type));
197 } 197 }
198 } else { 198 } else {
199 // Allocate a general purpose register/stack location. 199 // Allocate a general purpose register/stack location.
200 if (gp_offset < gp_count) { 200 if (gp_offset < gp_count) {
201 return regloc(gp_regs[gp_offset++], MachineTypeFor(type)); 201 return regloc(gp_regs[gp_offset++], MachineTypeFor(type));
202 } else { 202 } else {
203 int offset = -1 - stack_offset; 203 int offset = -1 - stack_offset;
204 stack_offset += Words(type); 204 stack_offset += Words(type);
205 return stackloc(offset, MachineTypeFor(type)); 205 return stackloc(offset, MachineTypeFor(type));
206 } 206 }
207 } 207 }
208 } 208 }
209 bool IsFloatingPoint(LocalType type) { 209 bool IsFloatingPoint(ValueType type) {
210 return type == kAstF32 || type == kAstF64; 210 return type == kWasmF32 || type == kWasmF64;
211 } 211 }
212 int Words(LocalType type) { 212 int Words(ValueType type) {
213 if (kPointerSize < 8 && (type == kAstI64 || type == kAstF64)) { 213 if (kPointerSize < 8 && (type == kWasmI64 || type == kWasmF64)) {
214 return 2; 214 return 2;
215 } 215 }
216 return 1; 216 return 1;
217 } 217 }
218 }; 218 };
219 } // namespace 219 } // namespace
220 220
221 struct ParameterRegistersCreateTrait { 221 struct ParameterRegistersCreateTrait {
222 static void Construct(Allocator* allocated_ptr) { 222 static void Construct(Allocator* allocated_ptr) {
223 #ifdef GP_PARAM_REGISTERS 223 #ifdef GP_PARAM_REGISTERS
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone, 278 CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone,
279 FunctionSig* fsig) { 279 FunctionSig* fsig) {
280 LocationSignature::Builder locations(zone, fsig->return_count(), 280 LocationSignature::Builder locations(zone, fsig->return_count(),
281 fsig->parameter_count()); 281 fsig->parameter_count());
282 282
283 Allocator rets = return_registers.Get(); 283 Allocator rets = return_registers.Get();
284 284
285 // Add return location(s). 285 // Add return location(s).
286 const int return_count = static_cast<int>(locations.return_count_); 286 const int return_count = static_cast<int>(locations.return_count_);
287 for (int i = 0; i < return_count; i++) { 287 for (int i = 0; i < return_count; i++) {
288 LocalType ret = fsig->GetReturn(i); 288 ValueType ret = fsig->GetReturn(i);
289 locations.AddReturn(rets.Next(ret)); 289 locations.AddReturn(rets.Next(ret));
290 } 290 }
291 291
292 Allocator params = parameter_registers.Get(); 292 Allocator params = parameter_registers.Get();
293 293
294 // Add register and/or stack parameter(s). 294 // Add register and/or stack parameter(s).
295 const int parameter_count = static_cast<int>(fsig->parameter_count()); 295 const int parameter_count = static_cast<int>(fsig->parameter_count());
296 for (int i = 0; i < parameter_count; i++) { 296 for (int i = 0; i < parameter_count; i++) {
297 LocalType param = fsig->GetParam(i); 297 ValueType param = fsig->GetParam(i);
298 locations.AddParam(params.Next(param)); 298 locations.AddParam(params.Next(param));
299 } 299 }
300 300
301 const RegList kCalleeSaveRegisters = 0; 301 const RegList kCalleeSaveRegisters = 0;
302 const RegList kCalleeSaveFPRegisters = 0; 302 const RegList kCalleeSaveFPRegisters = 0;
303 303
304 // The target for WASM calls is always a code object. 304 // The target for WASM calls is always a code object.
305 MachineType target_type = MachineType::AnyTagged(); 305 MachineType target_type = MachineType::AnyTagged();
306 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type); 306 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type);
307 307
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 CallDescriptor* ModuleEnv::GetI32WasmCallDescriptorForSimd( 389 CallDescriptor* ModuleEnv::GetI32WasmCallDescriptorForSimd(
390 Zone* zone, CallDescriptor* descriptor) { 390 Zone* zone, CallDescriptor* descriptor) {
391 return ReplaceTypeInCallDescriptorWith(zone, descriptor, 4, 391 return ReplaceTypeInCallDescriptorWith(zone, descriptor, 4,
392 MachineType::Simd128(), 392 MachineType::Simd128(),
393 MachineRepresentation::kWord32); 393 MachineRepresentation::kWord32);
394 } 394 }
395 395
396 } // namespace wasm 396 } // namespace wasm
397 } // namespace internal 397 } // namespace internal
398 } // namespace v8 398 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/function-body-decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698