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

Side by Side Diff: src/compiler/machine-operator.cc

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

Powered by Google App Engine
This is Rietveld 408576698