| 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 28 matching lines...) Expand all Loading... |
| 39 IrOpcode::kAtomicLoad == op->opcode()); | 39 IrOpcode::kAtomicLoad == op->opcode()); |
| 40 return OpParameter<LoadRepresentation>(op); | 40 return OpParameter<LoadRepresentation>(op); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { | 44 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { |
| 45 DCHECK_EQ(IrOpcode::kStore, op->opcode()); | 45 DCHECK_EQ(IrOpcode::kStore, op->opcode()); |
| 46 return OpParameter<StoreRepresentation>(op); | 46 return OpParameter<StoreRepresentation>(op); |
| 47 } | 47 } |
| 48 | 48 |
| 49 UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const* op) { |
| 50 DCHECK_EQ(IrOpcode::kUnalignedLoad, op->opcode()); |
| 51 return OpParameter<UnalignedLoadRepresentation>(op); |
| 52 } |
| 53 |
| 54 UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf( |
| 55 Operator const* op) { |
| 56 DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode()); |
| 57 return OpParameter<UnalignedStoreRepresentation>(op); |
| 58 } |
| 49 | 59 |
| 50 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) { | 60 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) { |
| 51 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); | 61 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); |
| 52 return OpParameter<CheckedLoadRepresentation>(op); | 62 return OpParameter<CheckedLoadRepresentation>(op); |
| 53 } | 63 } |
| 54 | 64 |
| 55 | 65 |
| 56 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { | 66 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
| 57 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); | 67 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); |
| 58 return OpParameter<CheckedStoreRepresentation>(op); | 68 return OpParameter<CheckedStoreRepresentation>(op); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 #undef OVERFLOW_OP | 471 #undef OVERFLOW_OP |
| 462 | 472 |
| 463 #define LOAD(Type) \ | 473 #define LOAD(Type) \ |
| 464 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ | 474 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ |
| 465 Load##Type##Operator() \ | 475 Load##Type##Operator() \ |
| 466 : Operator1<LoadRepresentation>( \ | 476 : Operator1<LoadRepresentation>( \ |
| 467 IrOpcode::kLoad, \ | 477 IrOpcode::kLoad, \ |
| 468 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ | 478 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
| 469 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 479 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
| 470 }; \ | 480 }; \ |
| 481 struct UnalignedLoad##Type##Operator final \ |
| 482 : public Operator1<UnalignedLoadRepresentation> { \ |
| 483 UnalignedLoad##Type##Operator() \ |
| 484 : Operator1<UnalignedLoadRepresentation>( \ |
| 485 IrOpcode::kUnalignedLoad, \ |
| 486 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
| 487 "UnalignedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
| 488 }; \ |
| 471 struct CheckedLoad##Type##Operator final \ | 489 struct CheckedLoad##Type##Operator final \ |
| 472 : public Operator1<CheckedLoadRepresentation> { \ | 490 : public Operator1<CheckedLoadRepresentation> { \ |
| 473 CheckedLoad##Type##Operator() \ | 491 CheckedLoad##Type##Operator() \ |
| 474 : Operator1<CheckedLoadRepresentation>( \ | 492 : Operator1<CheckedLoadRepresentation>( \ |
| 475 IrOpcode::kCheckedLoad, \ | 493 IrOpcode::kCheckedLoad, \ |
| 476 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ | 494 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
| 477 "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 495 "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
| 478 }; \ | 496 }; \ |
| 479 Load##Type##Operator kLoad##Type; \ | 497 Load##Type##Operator kLoad##Type; \ |
| 498 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ |
| 480 CheckedLoad##Type##Operator kCheckedLoad##Type; | 499 CheckedLoad##Type##Operator kCheckedLoad##Type; |
| 481 MACHINE_TYPE_LIST(LOAD) | 500 MACHINE_TYPE_LIST(LOAD) |
| 482 #undef LOAD | 501 #undef LOAD |
| 483 | 502 |
| 484 #define STACKSLOT(Type) \ | 503 #define STACKSLOT(Type) \ |
| 485 struct StackSlot##Type##Operator final \ | 504 struct StackSlot##Type##Operator final \ |
| 486 : public Operator1<MachineRepresentation> { \ | 505 : public Operator1<MachineRepresentation> { \ |
| 487 StackSlot##Type##Operator() \ | 506 StackSlot##Type##Operator() \ |
| 488 : Operator1<MachineRepresentation>( \ | 507 : Operator1<MachineRepresentation>( \ |
| 489 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, \ | 508 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, \ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 517 struct Store##Type##PointerWriteBarrier##Operator final \ | 536 struct Store##Type##PointerWriteBarrier##Operator final \ |
| 518 : public Store##Type##Operator { \ | 537 : public Store##Type##Operator { \ |
| 519 Store##Type##PointerWriteBarrier##Operator() \ | 538 Store##Type##PointerWriteBarrier##Operator() \ |
| 520 : Store##Type##Operator(kPointerWriteBarrier) {} \ | 539 : Store##Type##Operator(kPointerWriteBarrier) {} \ |
| 521 }; \ | 540 }; \ |
| 522 struct Store##Type##FullWriteBarrier##Operator final \ | 541 struct Store##Type##FullWriteBarrier##Operator final \ |
| 523 : public Store##Type##Operator { \ | 542 : public Store##Type##Operator { \ |
| 524 Store##Type##FullWriteBarrier##Operator() \ | 543 Store##Type##FullWriteBarrier##Operator() \ |
| 525 : Store##Type##Operator(kFullWriteBarrier) {} \ | 544 : Store##Type##Operator(kFullWriteBarrier) {} \ |
| 526 }; \ | 545 }; \ |
| 546 struct UnalignedStore##Type##Operator final \ |
| 547 : public Operator1<UnalignedStoreRepresentation> { \ |
| 548 UnalignedStore##Type##Operator() \ |
| 549 : Operator1<UnalignedStoreRepresentation>( \ |
| 550 IrOpcode::kUnalignedStore, \ |
| 551 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
| 552 "UnalignedStore", 3, 1, 1, 0, 1, 0, \ |
| 553 MachineRepresentation::Type) {} \ |
| 554 }; \ |
| 527 struct CheckedStore##Type##Operator final \ | 555 struct CheckedStore##Type##Operator final \ |
| 528 : public Operator1<CheckedStoreRepresentation> { \ | 556 : public Operator1<CheckedStoreRepresentation> { \ |
| 529 CheckedStore##Type##Operator() \ | 557 CheckedStore##Type##Operator() \ |
| 530 : Operator1<CheckedStoreRepresentation>( \ | 558 : Operator1<CheckedStoreRepresentation>( \ |
| 531 IrOpcode::kCheckedStore, \ | 559 IrOpcode::kCheckedStore, \ |
| 532 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ | 560 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
| 533 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ | 561 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ |
| 534 } \ | 562 } \ |
| 535 }; \ | 563 }; \ |
| 536 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 564 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
| 537 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 565 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
| 538 Store##Type##PointerWriteBarrier##Operator \ | 566 Store##Type##PointerWriteBarrier##Operator \ |
| 539 kStore##Type##PointerWriteBarrier; \ | 567 kStore##Type##PointerWriteBarrier; \ |
| 540 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 568 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
| 569 UnalignedStore##Type##Operator kUnalignedStore##Type; \ |
| 541 CheckedStore##Type##Operator kCheckedStore##Type; | 570 CheckedStore##Type##Operator kCheckedStore##Type; |
| 542 MACHINE_REPRESENTATION_LIST(STORE) | 571 MACHINE_REPRESENTATION_LIST(STORE) |
| 543 #undef STORE | 572 #undef STORE |
| 544 | 573 |
| 545 #define ATOMIC_LOAD(Type) \ | 574 #define ATOMIC_LOAD(Type) \ |
| 546 struct AtomicLoad##Type##Operator final \ | 575 struct AtomicLoad##Type##Operator final \ |
| 547 : public Operator1<LoadRepresentation> { \ | 576 : public Operator1<LoadRepresentation> { \ |
| 548 AtomicLoad##Type##Operator() \ | 577 AtomicLoad##Type##Operator() \ |
| 549 : Operator1<LoadRepresentation>( \ | 578 : Operator1<LoadRepresentation>( \ |
| 550 IrOpcode::kAtomicLoad, \ | 579 IrOpcode::kAtomicLoad, \ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 AlignmentRequirements alignmentRequirements) | 619 AlignmentRequirements alignmentRequirements) |
| 591 : zone_(zone), | 620 : zone_(zone), |
| 592 cache_(kCache.Get()), | 621 cache_(kCache.Get()), |
| 593 word_(word), | 622 word_(word), |
| 594 flags_(flags), | 623 flags_(flags), |
| 595 alignment_requirements_(alignmentRequirements) { | 624 alignment_requirements_(alignmentRequirements) { |
| 596 DCHECK(word == MachineRepresentation::kWord32 || | 625 DCHECK(word == MachineRepresentation::kWord32 || |
| 597 word == MachineRepresentation::kWord64); | 626 word == MachineRepresentation::kWord64); |
| 598 } | 627 } |
| 599 | 628 |
| 629 const Operator* MachineOperatorBuilder::UnalignedLoad( |
| 630 UnalignedLoadRepresentation rep) { |
| 631 #define LOAD(Type) \ |
| 632 if (rep == MachineType::Type()) { \ |
| 633 return &cache_.kUnalignedLoad##Type; \ |
| 634 } |
| 635 MACHINE_TYPE_LIST(LOAD) |
| 636 #undef LOAD |
| 637 UNREACHABLE(); |
| 638 return nullptr; |
| 639 } |
| 640 |
| 641 const Operator* MachineOperatorBuilder::UnalignedStore( |
| 642 UnalignedStoreRepresentation rep) { |
| 643 switch (rep) { |
| 644 #define STORE(kRep) \ |
| 645 case MachineRepresentation::kRep: \ |
| 646 return &cache_.kUnalignedStore##kRep; |
| 647 MACHINE_REPRESENTATION_LIST(STORE) |
| 648 #undef STORE |
| 649 case MachineRepresentation::kBit: |
| 650 case MachineRepresentation::kNone: |
| 651 break; |
| 652 } |
| 653 UNREACHABLE(); |
| 654 return nullptr; |
| 655 } |
| 600 | 656 |
| 601 #define PURE(Name, properties, value_input_count, control_input_count, \ | 657 #define PURE(Name, properties, value_input_count, control_input_count, \ |
| 602 output_count) \ | 658 output_count) \ |
| 603 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } | 659 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } |
| 604 PURE_OP_LIST(PURE) | 660 PURE_OP_LIST(PURE) |
| 605 #undef PURE | 661 #undef PURE |
| 606 | 662 |
| 607 #define PURE(Name, properties, value_input_count, control_input_count, \ | 663 #define PURE(Name, properties, value_input_count, control_input_count, \ |
| 608 output_count) \ | 664 output_count) \ |
| 609 const OptionalOperator MachineOperatorBuilder::Name() { \ | 665 const OptionalOperator MachineOperatorBuilder::Name() { \ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 } | 775 } |
| 720 ATOMIC_REPRESENTATION_LIST(STORE) | 776 ATOMIC_REPRESENTATION_LIST(STORE) |
| 721 #undef STORE | 777 #undef STORE |
| 722 UNREACHABLE(); | 778 UNREACHABLE(); |
| 723 return nullptr; | 779 return nullptr; |
| 724 } | 780 } |
| 725 | 781 |
| 726 } // namespace compiler | 782 } // namespace compiler |
| 727 } // namespace internal | 783 } // namespace internal |
| 728 } // namespace v8 | 784 } // namespace v8 |
| OLD | NEW |