OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/machine-operator.h" | 5 #include "src/compiler/machine-operator.h" |
6 | 6 |
7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 return os << "PointerWriteBarrier"; | 40 return os << "PointerWriteBarrier"; |
41 case kFullWriteBarrier: | 41 case kFullWriteBarrier: |
42 return os << "FullWriteBarrier"; | 42 return os << "FullWriteBarrier"; |
43 } | 43 } |
44 UNREACHABLE(); | 44 UNREACHABLE(); |
45 return os; | 45 return os; |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 bool operator==(StoreRepresentation lhs, StoreRepresentation rhs) { | 49 bool operator==(StoreRepresentation lhs, StoreRepresentation rhs) { |
50 return lhs.machine_type() == rhs.machine_type() && | 50 return lhs.representation() == rhs.representation() && |
51 lhs.write_barrier_kind() == rhs.write_barrier_kind(); | 51 lhs.write_barrier_kind() == rhs.write_barrier_kind(); |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) { | 55 bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) { |
56 return !(lhs == rhs); | 56 return !(lhs == rhs); |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 size_t hash_value(StoreRepresentation rep) { | 60 size_t hash_value(StoreRepresentation rep) { |
61 return base::hash_combine(rep.machine_type(), rep.write_barrier_kind()); | 61 return base::hash_combine(rep.representation(), rep.write_barrier_kind()); |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) { | 65 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) { |
66 return os << "(" << rep.machine_type() << " : " << rep.write_barrier_kind() | 66 return os << "(" << rep.representation() << " : " << rep.write_barrier_kind() |
67 << ")"; | 67 << ")"; |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 LoadRepresentation LoadRepresentationOf(Operator const* op) { | 71 LoadRepresentation LoadRepresentationOf(Operator const* op) { |
72 DCHECK_EQ(IrOpcode::kLoad, op->opcode()); | 72 DCHECK_EQ(IrOpcode::kLoad, op->opcode()); |
73 return OpParameter<LoadRepresentation>(op); | 73 return OpParameter<LoadRepresentation>(op); |
74 } | 74 } |
75 | 75 |
76 | 76 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 V(Int16) \ | 213 V(Int16) \ |
214 V(Uint16) \ | 214 V(Uint16) \ |
215 V(Int32) \ | 215 V(Int32) \ |
216 V(Uint32) \ | 216 V(Uint32) \ |
217 V(Int64) \ | 217 V(Int64) \ |
218 V(Uint64) \ | 218 V(Uint64) \ |
219 V(Pointer) \ | 219 V(Pointer) \ |
220 V(AnyTagged) | 220 V(AnyTagged) |
221 | 221 |
222 | 222 |
| 223 #define MACHINE_REPRESENTATION_LIST(V) \ |
| 224 V(kFloat32) \ |
| 225 V(kFloat64) \ |
| 226 V(kWord8) \ |
| 227 V(kWord16) \ |
| 228 V(kWord32) \ |
| 229 V(kWord64) \ |
| 230 V(kTagged) |
| 231 |
| 232 |
223 struct MachineOperatorGlobalCache { | 233 struct MachineOperatorGlobalCache { |
224 #define PURE(Name, properties, value_input_count, control_input_count, \ | 234 #define PURE(Name, properties, value_input_count, control_input_count, \ |
225 output_count) \ | 235 output_count) \ |
226 struct Name##Operator final : public Operator { \ | 236 struct Name##Operator final : public Operator { \ |
227 Name##Operator() \ | 237 Name##Operator() \ |
228 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 238 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
229 value_input_count, 0, control_input_count, output_count, 0, \ | 239 value_input_count, 0, control_input_count, output_count, 0, \ |
230 0) {} \ | 240 0) {} \ |
231 }; \ | 241 }; \ |
232 Name##Operator k##Name; | 242 Name##Operator k##Name; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 CheckedLoad##Type##Operator kCheckedLoad##Type; | 275 CheckedLoad##Type##Operator kCheckedLoad##Type; |
266 MACHINE_TYPE_LIST(LOAD) | 276 MACHINE_TYPE_LIST(LOAD) |
267 #undef LOAD | 277 #undef LOAD |
268 | 278 |
269 #define STORE(Type) \ | 279 #define STORE(Type) \ |
270 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ | 280 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ |
271 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ | 281 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ |
272 : Operator1<StoreRepresentation>( \ | 282 : Operator1<StoreRepresentation>( \ |
273 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, \ | 283 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, \ |
274 "Store", 3, 1, 1, 0, 1, 0, \ | 284 "Store", 3, 1, 1, 0, 1, 0, \ |
275 StoreRepresentation(MachineType::Type(), write_barrier_kind)) {} \ | 285 StoreRepresentation(MachineRepresentation::Type, \ |
| 286 write_barrier_kind)) {} \ |
276 }; \ | 287 }; \ |
277 struct Store##Type##NoWriteBarrier##Operator final \ | 288 struct Store##Type##NoWriteBarrier##Operator final \ |
278 : public Store##Type##Operator { \ | 289 : public Store##Type##Operator { \ |
279 Store##Type##NoWriteBarrier##Operator() \ | 290 Store##Type##NoWriteBarrier##Operator() \ |
280 : Store##Type##Operator(kNoWriteBarrier) {} \ | 291 : Store##Type##Operator(kNoWriteBarrier) {} \ |
281 }; \ | 292 }; \ |
282 struct Store##Type##MapWriteBarrier##Operator final \ | 293 struct Store##Type##MapWriteBarrier##Operator final \ |
283 : public Store##Type##Operator { \ | 294 : public Store##Type##Operator { \ |
284 Store##Type##MapWriteBarrier##Operator() \ | 295 Store##Type##MapWriteBarrier##Operator() \ |
285 : Store##Type##Operator(kMapWriteBarrier) {} \ | 296 : Store##Type##Operator(kMapWriteBarrier) {} \ |
286 }; \ | 297 }; \ |
287 struct Store##Type##PointerWriteBarrier##Operator final \ | 298 struct Store##Type##PointerWriteBarrier##Operator final \ |
288 : public Store##Type##Operator { \ | 299 : public Store##Type##Operator { \ |
289 Store##Type##PointerWriteBarrier##Operator() \ | 300 Store##Type##PointerWriteBarrier##Operator() \ |
290 : Store##Type##Operator(kPointerWriteBarrier) {} \ | 301 : Store##Type##Operator(kPointerWriteBarrier) {} \ |
291 }; \ | 302 }; \ |
292 struct Store##Type##FullWriteBarrier##Operator final \ | 303 struct Store##Type##FullWriteBarrier##Operator final \ |
293 : public Store##Type##Operator { \ | 304 : public Store##Type##Operator { \ |
294 Store##Type##FullWriteBarrier##Operator() \ | 305 Store##Type##FullWriteBarrier##Operator() \ |
295 : Store##Type##Operator(kFullWriteBarrier) {} \ | 306 : Store##Type##Operator(kFullWriteBarrier) {} \ |
296 }; \ | 307 }; \ |
297 struct CheckedStore##Type##Operator final \ | 308 struct CheckedStore##Type##Operator final \ |
298 : public Operator1<CheckedStoreRepresentation> { \ | 309 : public Operator1<CheckedStoreRepresentation> { \ |
299 CheckedStore##Type##Operator() \ | 310 CheckedStore##Type##Operator() \ |
300 : Operator1<CheckedStoreRepresentation>( \ | 311 : Operator1<CheckedStoreRepresentation>( \ |
301 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, \ | 312 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, \ |
302 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineType::Type()) {} \ | 313 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ |
| 314 } \ |
303 }; \ | 315 }; \ |
304 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 316 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
305 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 317 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
306 Store##Type##PointerWriteBarrier##Operator \ | 318 Store##Type##PointerWriteBarrier##Operator \ |
307 kStore##Type##PointerWriteBarrier; \ | 319 kStore##Type##PointerWriteBarrier; \ |
308 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 320 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
309 CheckedStore##Type##Operator kCheckedStore##Type; | 321 CheckedStore##Type##Operator kCheckedStore##Type; |
310 MACHINE_TYPE_LIST(STORE) | 322 MACHINE_REPRESENTATION_LIST(STORE) |
311 #undef STORE | 323 #undef STORE |
312 }; | 324 }; |
313 | 325 |
314 | 326 |
315 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 327 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
316 LAZY_INSTANCE_INITIALIZER; | 328 LAZY_INSTANCE_INITIALIZER; |
317 | 329 |
318 | 330 |
319 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, | 331 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, |
320 MachineRepresentation word, | 332 MachineRepresentation word, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return &cache_.kLoad##Type; \ | 371 return &cache_.kLoad##Type; \ |
360 } | 372 } |
361 MACHINE_TYPE_LIST(LOAD) | 373 MACHINE_TYPE_LIST(LOAD) |
362 #undef LOAD | 374 #undef LOAD |
363 UNREACHABLE(); | 375 UNREACHABLE(); |
364 return nullptr; | 376 return nullptr; |
365 } | 377 } |
366 | 378 |
367 | 379 |
368 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { | 380 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { |
369 MachineType type = store_rep.machine_type(); | 381 switch (store_rep.representation()) { |
370 #define STORE(Type) \ | 382 #define STORE(kRep) \ |
371 if (type == MachineType::Type()) { \ | 383 case MachineRepresentation::kRep: \ |
372 switch (store_rep.write_barrier_kind()) { \ | 384 switch (store_rep.write_barrier_kind()) { \ |
373 case kNoWriteBarrier: \ | 385 case kNoWriteBarrier: \ |
374 return &cache_.k##Store##Type##NoWriteBarrier; \ | 386 return &cache_.k##Store##kRep##NoWriteBarrier; \ |
375 case kMapWriteBarrier: \ | 387 case kMapWriteBarrier: \ |
376 return &cache_.k##Store##Type##MapWriteBarrier; \ | 388 return &cache_.k##Store##kRep##MapWriteBarrier; \ |
377 case kPointerWriteBarrier: \ | 389 case kPointerWriteBarrier: \ |
378 return &cache_.k##Store##Type##PointerWriteBarrier; \ | 390 return &cache_.k##Store##kRep##PointerWriteBarrier; \ |
379 case kFullWriteBarrier: \ | 391 case kFullWriteBarrier: \ |
380 return &cache_.k##Store##Type##FullWriteBarrier; \ | 392 return &cache_.k##Store##kRep##FullWriteBarrier; \ |
381 } \ | 393 } \ |
| 394 break; |
| 395 MACHINE_REPRESENTATION_LIST(STORE) |
| 396 #undef STORE |
| 397 default: |
| 398 break; |
382 } | 399 } |
383 MACHINE_TYPE_LIST(STORE) | |
384 #undef STORE | |
385 UNREACHABLE(); | 400 UNREACHABLE(); |
386 return nullptr; | 401 return nullptr; |
387 } | 402 } |
388 | 403 |
389 | 404 |
390 const Operator* MachineOperatorBuilder::CheckedLoad( | 405 const Operator* MachineOperatorBuilder::CheckedLoad( |
391 CheckedLoadRepresentation rep) { | 406 CheckedLoadRepresentation rep) { |
392 #define LOAD(Type) \ | 407 #define LOAD(Type) \ |
393 if (rep == MachineType::Type()) { \ | 408 if (rep == MachineType::Type()) { \ |
394 return &cache_.kCheckedLoad##Type; \ | 409 return &cache_.kCheckedLoad##Type; \ |
395 } | 410 } |
396 MACHINE_TYPE_LIST(LOAD) | 411 MACHINE_TYPE_LIST(LOAD) |
397 #undef LOAD | 412 #undef LOAD |
398 UNREACHABLE(); | 413 UNREACHABLE(); |
399 return nullptr; | 414 return nullptr; |
400 } | 415 } |
401 | 416 |
402 | 417 |
403 const Operator* MachineOperatorBuilder::CheckedStore( | 418 const Operator* MachineOperatorBuilder::CheckedStore( |
404 CheckedStoreRepresentation rep) { | 419 CheckedStoreRepresentation rep) { |
405 #define STORE(Type) \ | 420 switch (rep) { |
406 if (rep == MachineType::Type()) { \ | 421 #define STORE(kRep) \ |
407 return &cache_.kCheckedStore##Type; \ | 422 case MachineRepresentation::kRep: \ |
| 423 return &cache_.kCheckedStore##kRep; |
| 424 MACHINE_REPRESENTATION_LIST(STORE) |
| 425 #undef STORE |
| 426 default: |
| 427 break; |
408 } | 428 } |
409 MACHINE_TYPE_LIST(STORE) | |
410 #undef STORE | |
411 UNREACHABLE(); | 429 UNREACHABLE(); |
412 return nullptr; | 430 return nullptr; |
413 } | 431 } |
414 | 432 |
415 } // namespace compiler | 433 } // namespace compiler |
416 } // namespace internal | 434 } // namespace internal |
417 } // namespace v8 | 435 } // namespace v8 |
OLD | NEW |