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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
77 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { | 77 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { |
78 DCHECK_EQ(IrOpcode::kStore, op->opcode()); | 78 DCHECK_EQ(IrOpcode::kStore, op->opcode()); |
79 return OpParameter<StoreRepresentation>(op); | 79 return OpParameter<StoreRepresentation>(op); |
80 } | 80 } |
81 | 81 |
| 82 UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const* op) { |
| 83 DCHECK_EQ(IrOpcode::kUnalignedLoad, op->opcode()); |
| 84 return OpParameter<UnalignedLoadRepresentation>(op); |
| 85 } |
| 86 |
| 87 UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf( |
| 88 Operator const* op) { |
| 89 DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode()); |
| 90 return OpParameter<UnalignedStoreRepresentation>(op); |
| 91 } |
82 | 92 |
83 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) { | 93 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) { |
84 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); | 94 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); |
85 return OpParameter<CheckedLoadRepresentation>(op); | 95 return OpParameter<CheckedLoadRepresentation>(op); |
86 } | 96 } |
87 | 97 |
88 | 98 |
89 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { | 99 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
90 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); | 100 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); |
91 return OpParameter<CheckedStoreRepresentation>(op); | 101 return OpParameter<CheckedStoreRepresentation>(op); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 TruncateFloat64ToInt32Operator<TruncationMode::kRoundToZero> | 287 TruncateFloat64ToInt32Operator<TruncationMode::kRoundToZero> |
278 kTruncateFloat64ToInt32RoundToZero; | 288 kTruncateFloat64ToInt32RoundToZero; |
279 | 289 |
280 #define LOAD(Type) \ | 290 #define LOAD(Type) \ |
281 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ | 291 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ |
282 Load##Type##Operator() \ | 292 Load##Type##Operator() \ |
283 : Operator1<LoadRepresentation>( \ | 293 : Operator1<LoadRepresentation>( \ |
284 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ | 294 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ |
285 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 295 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
286 }; \ | 296 }; \ |
| 297 struct UnalignedLoad##Type##Operator final \ |
| 298 : public Operator1<UnalignedLoadRepresentation> { \ |
| 299 UnalignedLoad##Type##Operator() \ |
| 300 : Operator1<UnalignedLoadRepresentation>( \ |
| 301 IrOpcode::kUnalignedLoad, \ |
| 302 Operator::kNoThrow | Operator::kNoWrite, "UnalignedLoad", 2, 1, \ |
| 303 1, 1, 1, 0, MachineType::Type()) {} \ |
| 304 }; \ |
287 struct CheckedLoad##Type##Operator final \ | 305 struct CheckedLoad##Type##Operator final \ |
288 : public Operator1<CheckedLoadRepresentation> { \ | 306 : public Operator1<CheckedLoadRepresentation> { \ |
289 CheckedLoad##Type##Operator() \ | 307 CheckedLoad##Type##Operator() \ |
290 : Operator1<CheckedLoadRepresentation>( \ | 308 : Operator1<CheckedLoadRepresentation>( \ |
291 IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite, \ | 309 IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite, \ |
292 "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 310 "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
293 }; \ | 311 }; \ |
294 Load##Type##Operator kLoad##Type; \ | 312 Load##Type##Operator kLoad##Type; \ |
| 313 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ |
295 CheckedLoad##Type##Operator kCheckedLoad##Type; | 314 CheckedLoad##Type##Operator kCheckedLoad##Type; |
296 MACHINE_TYPE_LIST(LOAD) | 315 MACHINE_TYPE_LIST(LOAD) |
297 #undef LOAD | 316 #undef LOAD |
298 | 317 |
299 #define STACKSLOT(Type) \ | 318 #define STACKSLOT(Type) \ |
300 struct StackSlot##Type##Operator final \ | 319 struct StackSlot##Type##Operator final \ |
301 : public Operator1<MachineRepresentation> { \ | 320 : public Operator1<MachineRepresentation> { \ |
302 StackSlot##Type##Operator() \ | 321 StackSlot##Type##Operator() \ |
303 : Operator1<MachineRepresentation>( \ | 322 : Operator1<MachineRepresentation>( \ |
304 IrOpcode::kStackSlot, Operator::kNoThrow, "StackSlot", 0, 0, 0, \ | 323 IrOpcode::kStackSlot, Operator::kNoThrow, "StackSlot", 0, 0, 0, \ |
(...skipping 25 matching lines...) Expand all Loading... |
330 struct Store##Type##PointerWriteBarrier##Operator final \ | 349 struct Store##Type##PointerWriteBarrier##Operator final \ |
331 : public Store##Type##Operator { \ | 350 : public Store##Type##Operator { \ |
332 Store##Type##PointerWriteBarrier##Operator() \ | 351 Store##Type##PointerWriteBarrier##Operator() \ |
333 : Store##Type##Operator(kPointerWriteBarrier) {} \ | 352 : Store##Type##Operator(kPointerWriteBarrier) {} \ |
334 }; \ | 353 }; \ |
335 struct Store##Type##FullWriteBarrier##Operator final \ | 354 struct Store##Type##FullWriteBarrier##Operator final \ |
336 : public Store##Type##Operator { \ | 355 : public Store##Type##Operator { \ |
337 Store##Type##FullWriteBarrier##Operator() \ | 356 Store##Type##FullWriteBarrier##Operator() \ |
338 : Store##Type##Operator(kFullWriteBarrier) {} \ | 357 : Store##Type##Operator(kFullWriteBarrier) {} \ |
339 }; \ | 358 }; \ |
| 359 struct UnalignedStore##Type##Operator final \ |
| 360 : public Operator1<UnalignedStoreRepresentation> { \ |
| 361 UnalignedStore##Type##Operator() \ |
| 362 : Operator1<UnalignedStoreRepresentation>( \ |
| 363 IrOpcode::kUnalignedStore, \ |
| 364 Operator::kNoRead | Operator::kNoThrow, "UnalignedStore", 3, 1, \ |
| 365 1, 0, 1, 0, MachineRepresentation::Type) {} \ |
| 366 }; \ |
340 struct CheckedStore##Type##Operator final \ | 367 struct CheckedStore##Type##Operator final \ |
341 : public Operator1<CheckedStoreRepresentation> { \ | 368 : public Operator1<CheckedStoreRepresentation> { \ |
342 CheckedStore##Type##Operator() \ | 369 CheckedStore##Type##Operator() \ |
343 : Operator1<CheckedStoreRepresentation>( \ | 370 : Operator1<CheckedStoreRepresentation>( \ |
344 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, \ | 371 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, \ |
345 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ | 372 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ |
346 } \ | 373 } \ |
347 }; \ | 374 }; \ |
348 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 375 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
349 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 376 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
350 Store##Type##PointerWriteBarrier##Operator \ | 377 Store##Type##PointerWriteBarrier##Operator \ |
351 kStore##Type##PointerWriteBarrier; \ | 378 kStore##Type##PointerWriteBarrier; \ |
352 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 379 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
| 380 UnalignedStore##Type##Operator kUnalignedStore##Type; \ |
353 CheckedStore##Type##Operator kCheckedStore##Type; | 381 CheckedStore##Type##Operator kCheckedStore##Type; |
354 MACHINE_REPRESENTATION_LIST(STORE) | 382 MACHINE_REPRESENTATION_LIST(STORE) |
355 #undef STORE | 383 #undef STORE |
356 }; | 384 }; |
357 | 385 |
358 | 386 |
359 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 387 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
360 LAZY_INSTANCE_INITIALIZER; | 388 LAZY_INSTANCE_INITIALIZER; |
361 | 389 |
362 | 390 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 MACHINE_REPRESENTATION_LIST(STORE) | 465 MACHINE_REPRESENTATION_LIST(STORE) |
438 #undef STORE | 466 #undef STORE |
439 case MachineRepresentation::kBit: | 467 case MachineRepresentation::kBit: |
440 case MachineRepresentation::kNone: | 468 case MachineRepresentation::kNone: |
441 break; | 469 break; |
442 } | 470 } |
443 UNREACHABLE(); | 471 UNREACHABLE(); |
444 return nullptr; | 472 return nullptr; |
445 } | 473 } |
446 | 474 |
| 475 const OptionalOperator MachineOperatorBuilder::UnalignedLoad( |
| 476 UnalignedLoadRepresentation rep) { |
| 477 #define LOAD(Type) \ |
| 478 if (rep == MachineType::Type()) { \ |
| 479 return OptionalOperator( \ |
| 480 flags_ & kUnalignedLoad ? &cache_.kUnalignedLoad##Type : nullptr); \ |
| 481 } |
| 482 MACHINE_TYPE_LIST(LOAD) |
| 483 #undef LOAD |
| 484 UNREACHABLE(); |
| 485 return OptionalOperator(nullptr); |
| 486 } |
| 487 |
| 488 const OptionalOperator MachineOperatorBuilder::UnalignedStore( |
| 489 UnalignedStoreRepresentation rep) { |
| 490 switch (rep) { |
| 491 #define STORE(kRep) \ |
| 492 case MachineRepresentation::kRep: \ |
| 493 return OptionalOperator( \ |
| 494 flags_ & kUnalignedStore ? &cache_.kUnalignedStore##kRep : nullptr); |
| 495 MACHINE_REPRESENTATION_LIST(STORE) |
| 496 #undef STORE |
| 497 case MachineRepresentation::kBit: |
| 498 case MachineRepresentation::kNone: |
| 499 break; |
| 500 } |
| 501 UNREACHABLE(); |
| 502 return OptionalOperator(nullptr); |
| 503 } |
447 | 504 |
448 const Operator* MachineOperatorBuilder::CheckedLoad( | 505 const Operator* MachineOperatorBuilder::CheckedLoad( |
449 CheckedLoadRepresentation rep) { | 506 CheckedLoadRepresentation rep) { |
450 #define LOAD(Type) \ | 507 #define LOAD(Type) \ |
451 if (rep == MachineType::Type()) { \ | 508 if (rep == MachineType::Type()) { \ |
452 return &cache_.kCheckedLoad##Type; \ | 509 return &cache_.kCheckedLoad##Type; \ |
453 } | 510 } |
454 MACHINE_TYPE_LIST(LOAD) | 511 MACHINE_TYPE_LIST(LOAD) |
455 #undef LOAD | 512 #undef LOAD |
456 UNREACHABLE(); | 513 UNREACHABLE(); |
(...skipping 26 matching lines...) Expand all Loading... |
483 | 540 |
484 // On 32 bit platforms we need to get a reference to optional operators of | 541 // On 32 bit platforms we need to get a reference to optional operators of |
485 // 64-bit instructions for later Int64Lowering, even though 32 bit platforms | 542 // 64-bit instructions for later Int64Lowering, even though 32 bit platforms |
486 // don't support the original 64-bit instruction. | 543 // don't support the original 64-bit instruction. |
487 const Operator* MachineOperatorBuilder::Word64CtzPlaceholder() { | 544 const Operator* MachineOperatorBuilder::Word64CtzPlaceholder() { |
488 return &cache_.kWord64Ctz; | 545 return &cache_.kWord64Ctz; |
489 } | 546 } |
490 } // namespace compiler | 547 } // namespace compiler |
491 } // namespace internal | 548 } // namespace internal |
492 } // namespace v8 | 549 } // namespace v8 |
OLD | NEW |