| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); | 63 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); |
| 64 return OpParameter<CheckedLoadRepresentation>(op); | 64 return OpParameter<CheckedLoadRepresentation>(op); |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { | 68 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
| 69 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); | 69 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); |
| 70 return OpParameter<CheckedStoreRepresentation>(op); | 70 return OpParameter<CheckedStoreRepresentation>(op); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool operator==(StackSlotRepresentation lhs, StackSlotRepresentation rhs) { | 73 int StackSlotSizeOf(Operator const* op) { |
| 74 return lhs.size() == rhs.size() && lhs.alignment() == rhs.alignment(); | |
| 75 } | |
| 76 | |
| 77 bool operator!=(StackSlotRepresentation lhs, StackSlotRepresentation rhs) { | |
| 78 return !(lhs == rhs); | |
| 79 } | |
| 80 | |
| 81 size_t hash_value(StackSlotRepresentation rep) { | |
| 82 return base::hash_combine(rep.size(), rep.alignment()); | |
| 83 } | |
| 84 | |
| 85 std::ostream& operator<<(std::ostream& os, StackSlotRepresentation rep) { | |
| 86 return os << "(" << rep.size() << " : " << rep.alignment() << ")"; | |
| 87 } | |
| 88 | |
| 89 StackSlotRepresentation const& StackSlotRepresentationOf(Operator const* op) { | |
| 90 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); | 74 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); |
| 91 return OpParameter<StackSlotRepresentation>(op); | 75 return OpParameter<int>(op); |
| 92 } | 76 } |
| 93 | 77 |
| 94 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { | 78 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { |
| 95 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); | 79 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); |
| 96 return OpParameter<MachineRepresentation>(op); | 80 return OpParameter<MachineRepresentation>(op); |
| 97 } | 81 } |
| 98 | 82 |
| 99 MachineType AtomicOpRepresentationOf(Operator const* op) { | 83 MachineType AtomicOpRepresentationOf(Operator const* op) { |
| 100 return OpParameter<MachineType>(op); | 84 return OpParameter<MachineType>(op); |
| 101 } | 85 } |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 V(F32x4, 4) \ | 416 V(F32x4, 4) \ |
| 433 V(I32x4, 4) \ | 417 V(I32x4, 4) \ |
| 434 V(I16x8, 8) \ | 418 V(I16x8, 8) \ |
| 435 V(I8x16, 16) | 419 V(I8x16, 16) |
| 436 | 420 |
| 437 #define SIMD_FORMAT_LIST(V) \ | 421 #define SIMD_FORMAT_LIST(V) \ |
| 438 V(32x4, 32) \ | 422 V(32x4, 32) \ |
| 439 V(16x8, 16) \ | 423 V(16x8, 16) \ |
| 440 V(8x16, 8) | 424 V(8x16, 8) |
| 441 | 425 |
| 442 #define STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(V) \ | 426 #define STACK_SLOT_CACHED_SIZES_LIST(V) V(4) V(8) V(16) |
| 443 V(4, 0) V(8, 0) V(16, 0) V(4, 4) V(8, 8) V(16, 16) | |
| 444 | 427 |
| 445 struct StackSlotOperator : public Operator1<StackSlotRepresentation> { | 428 struct StackSlotOperator : public Operator1<int> { |
| 446 explicit StackSlotOperator(int size, int alignment) | 429 explicit StackSlotOperator(int size) |
| 447 : Operator1<StackSlotRepresentation>( | 430 : Operator1<int>(IrOpcode::kStackSlot, |
| 448 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, | 431 Operator::kNoDeopt | Operator::kNoThrow, "StackSlot", 0, |
| 449 "StackSlot", 0, 0, 0, 1, 0, 0, | 432 0, 0, 1, 0, 0, size) {} |
| 450 StackSlotRepresentation(size, alignment)) {} | |
| 451 }; | 433 }; |
| 452 | 434 |
| 453 struct MachineOperatorGlobalCache { | 435 struct MachineOperatorGlobalCache { |
| 454 #define PURE(Name, properties, value_input_count, control_input_count, \ | 436 #define PURE(Name, properties, value_input_count, control_input_count, \ |
| 455 output_count) \ | 437 output_count) \ |
| 456 struct Name##Operator final : public Operator { \ | 438 struct Name##Operator final : public Operator { \ |
| 457 Name##Operator() \ | 439 Name##Operator() \ |
| 458 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 440 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
| 459 value_input_count, 0, control_input_count, output_count, 0, \ | 441 value_input_count, 0, control_input_count, output_count, 0, \ |
| 460 0) {} \ | 442 0) {} \ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \ | 489 Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \ |
| 508 1, 1, 1, 0, MachineType::Type()) {} \ | 490 1, 1, 1, 0, MachineType::Type()) {} \ |
| 509 }; \ | 491 }; \ |
| 510 Load##Type##Operator kLoad##Type; \ | 492 Load##Type##Operator kLoad##Type; \ |
| 511 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ | 493 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ |
| 512 CheckedLoad##Type##Operator kCheckedLoad##Type; \ | 494 CheckedLoad##Type##Operator kCheckedLoad##Type; \ |
| 513 ProtectedLoad##Type##Operator kProtectedLoad##Type; | 495 ProtectedLoad##Type##Operator kProtectedLoad##Type; |
| 514 MACHINE_TYPE_LIST(LOAD) | 496 MACHINE_TYPE_LIST(LOAD) |
| 515 #undef LOAD | 497 #undef LOAD |
| 516 | 498 |
| 517 #define STACKSLOT(Size, Alignment) \ | 499 #define STACKSLOT(Size) \ |
| 518 struct StackSlotOfSize##Size##OfAlignment##Alignment##Operator final \ | 500 struct StackSlotOfSize##Size##Operator final : public StackSlotOperator { \ |
| 519 : public StackSlotOperator { \ | 501 StackSlotOfSize##Size##Operator() : StackSlotOperator(Size) {} \ |
| 520 StackSlotOfSize##Size##OfAlignment##Alignment##Operator() \ | 502 }; \ |
| 521 : StackSlotOperator(Size, Alignment) {} \ | 503 StackSlotOfSize##Size##Operator kStackSlotSize##Size; |
| 522 }; \ | 504 STACK_SLOT_CACHED_SIZES_LIST(STACKSLOT) |
| 523 StackSlotOfSize##Size##OfAlignment##Alignment##Operator \ | |
| 524 kStackSlotOfSize##Size##OfAlignment##Alignment; | |
| 525 STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(STACKSLOT) | |
| 526 #undef STACKSLOT | 505 #undef STACKSLOT |
| 527 | 506 |
| 528 #define STORE(Type) \ | 507 #define STORE(Type) \ |
| 529 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ | 508 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ |
| 530 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ | 509 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ |
| 531 : Operator1<StoreRepresentation>( \ | 510 : Operator1<StoreRepresentation>( \ |
| 532 IrOpcode::kStore, \ | 511 IrOpcode::kStore, \ |
| 533 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ | 512 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
| 534 "Store", 3, 1, 1, 0, 1, 0, \ | 513 "Store", 3, 1, 1, 0, 1, 0, \ |
| 535 StoreRepresentation(MachineRepresentation::Type, \ | 514 StoreRepresentation(MachineRepresentation::Type, \ |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 #define LOAD(Type) \ | 745 #define LOAD(Type) \ |
| 767 if (rep == MachineType::Type()) { \ | 746 if (rep == MachineType::Type()) { \ |
| 768 return &cache_.kProtectedLoad##Type; \ | 747 return &cache_.kProtectedLoad##Type; \ |
| 769 } | 748 } |
| 770 MACHINE_TYPE_LIST(LOAD) | 749 MACHINE_TYPE_LIST(LOAD) |
| 771 #undef LOAD | 750 #undef LOAD |
| 772 UNREACHABLE(); | 751 UNREACHABLE(); |
| 773 return nullptr; | 752 return nullptr; |
| 774 } | 753 } |
| 775 | 754 |
| 776 const Operator* MachineOperatorBuilder::StackSlot(int size, int alignment) { | 755 const Operator* MachineOperatorBuilder::StackSlot(int size) { |
| 777 DCHECK_LE(0, size); | 756 DCHECK_LE(0, size); |
| 778 DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || alignment == 16); | 757 #define CASE_CACHED_SIZE(Size) \ |
| 779 #define CASE_CACHED_SIZE(Size, Alignment) \ | 758 case Size: \ |
| 780 if (size == Size && alignment == Alignment) { \ | 759 return &cache_.kStackSlotSize##Size; |
| 781 return &cache_.kStackSlotOfSize##Size##OfAlignment##Alignment; \ | 760 switch (size) { |
| 761 STACK_SLOT_CACHED_SIZES_LIST(CASE_CACHED_SIZE); |
| 762 default: |
| 763 return new (zone_) StackSlotOperator(size); |
| 782 } | 764 } |
| 783 | |
| 784 STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(CASE_CACHED_SIZE) | |
| 785 | |
| 786 #undef CASE_CACHED_SIZE | 765 #undef CASE_CACHED_SIZE |
| 787 return new (zone_) StackSlotOperator(size, alignment); | |
| 788 } | 766 } |
| 789 | 767 |
| 790 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep, | 768 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep) { |
| 791 int alignment) { | 769 return StackSlot(1 << ElementSizeLog2Of(rep)); |
| 792 return StackSlot(1 << ElementSizeLog2Of(rep), alignment); | |
| 793 } | 770 } |
| 794 | 771 |
| 795 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { | 772 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { |
| 796 switch (store_rep.representation()) { | 773 switch (store_rep.representation()) { |
| 797 #define STORE(kRep) \ | 774 #define STORE(kRep) \ |
| 798 case MachineRepresentation::kRep: \ | 775 case MachineRepresentation::kRep: \ |
| 799 switch (store_rep.write_barrier_kind()) { \ | 776 switch (store_rep.write_barrier_kind()) { \ |
| 800 case kNoWriteBarrier: \ | 777 case kNoWriteBarrier: \ |
| 801 return &cache_.k##Store##kRep##NoWriteBarrier; \ | 778 return &cache_.k##Store##kRep##NoWriteBarrier; \ |
| 802 case kMapWriteBarrier: \ | 779 case kMapWriteBarrier: \ |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 uint8_t* array = zone_->NewArray<uint8_t>(16); | 1024 uint8_t* array = zone_->NewArray<uint8_t>(16); |
| 1048 memcpy(array, shuffle, 16); | 1025 memcpy(array, shuffle, 16); |
| 1049 return new (zone_) | 1026 return new (zone_) |
| 1050 Operator1<uint8_t*>(IrOpcode::kS8x16Shuffle, Operator::kPure, "Shuffle", | 1027 Operator1<uint8_t*>(IrOpcode::kS8x16Shuffle, Operator::kPure, "Shuffle", |
| 1051 2, 0, 0, 1, 0, 0, array); | 1028 2, 0, 0, 1, 0, 0, array); |
| 1052 } | 1029 } |
| 1053 | 1030 |
| 1054 } // namespace compiler | 1031 } // namespace compiler |
| 1055 } // namespace internal | 1032 } // namespace internal |
| 1056 } // namespace v8 | 1033 } // namespace v8 |
| OLD | NEW |