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

Side by Side Diff: src/compiler/register-allocator-verifier.h

Issue 1895013003: [turbofan] Fixes to validator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | src/compiler/register-allocator-verifier.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 #ifndef V8_REGISTER_ALLOCATOR_VERIFIER_H_ 5 #ifndef V8_REGISTER_ALLOCATOR_VERIFIER_H_
6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_ 6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_
7 7
8 #include "src/zone-containers.h" 8 #include "src/zone-containers.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 AssessmentKind kind() const { return kind_; } 55 AssessmentKind kind() const { return kind_; }
56 56
57 protected: 57 protected:
58 explicit Assessment(AssessmentKind kind) : kind_(kind) {} 58 explicit Assessment(AssessmentKind kind) : kind_(kind) {}
59 AssessmentKind kind_; 59 AssessmentKind kind_;
60 60
61 private: 61 private:
62 DISALLOW_COPY_AND_ASSIGN(Assessment); 62 DISALLOW_COPY_AND_ASSIGN(Assessment);
63 }; 63 };
64 64
65 // FinalAssessmens are associated to operands that we know to be a certain
66 // virtual register.
67 class FinalAssessment final : public Assessment {
68 public:
69 explicit FinalAssessment(int virtual_register)
70 : Assessment(Final), virtual_register_(virtual_register) {}
71
72 int virtual_register() const { return virtual_register_; }
73 static const FinalAssessment* cast(const Assessment* assessment) {
74 CHECK(assessment->kind() == Final);
75 return static_cast<const FinalAssessment*>(assessment);
76 }
77
78 private:
79 int virtual_register_;
80
81 DISALLOW_COPY_AND_ASSIGN(FinalAssessment);
82 };
83
84 // PendingAssessments are associated to operands coming from the multiple 65 // PendingAssessments are associated to operands coming from the multiple
85 // predecessors of a block. We only record the operand and the block, and 66 // predecessors of a block. We only record the operand and the block, and
86 // will determine if the way the operand is defined (from the predecessors) 67 // will determine if the way the operand is defined (from the predecessors)
87 // matches a particular use. This handles scenarios where multiple phis are 68 // matches a particular use. This handles scenarios where multiple phis are
88 // defined with identical operands, and the move optimizer moved down the moves 69 // defined with identical operands, and the move optimizer moved down the moves
89 // separating the 2 phis in the block defining them. 70 // separating the 2 phis in the block defining them.
90 class PendingAssessment final : public Assessment { 71 class PendingAssessment final : public Assessment {
91 public: 72 public:
92 explicit PendingAssessment(const InstructionBlock* origin, 73 explicit PendingAssessment(const InstructionBlock* origin,
93 InstructionOperand operand) 74 InstructionOperand operand)
94 : Assessment(Pending), origin_(origin), operand_(operand) {} 75 : Assessment(Pending), origin_(origin), operand_(operand) {}
95 76
96 static PendingAssessment* cast(Assessment* assessment) { 77 static PendingAssessment* cast(Assessment* assessment) {
97 CHECK(assessment->kind() == Pending); 78 CHECK(assessment->kind() == Pending);
98 return static_cast<PendingAssessment*>(assessment); 79 return static_cast<PendingAssessment*>(assessment);
99 } 80 }
100 81
101 const InstructionBlock* origin() const { return origin_; } 82 const InstructionBlock* origin() const { return origin_; }
102 InstructionOperand operand() const { return operand_; } 83 InstructionOperand operand() const { return operand_; }
103 84
104 private: 85 private:
105 const InstructionBlock* const origin_; 86 const InstructionBlock* const origin_;
106 InstructionOperand operand_; 87 InstructionOperand operand_;
107 88
108 DISALLOW_COPY_AND_ASSIGN(PendingAssessment); 89 DISALLOW_COPY_AND_ASSIGN(PendingAssessment);
109 }; 90 };
110 91
92 // FinalAssessmens are associated to operands that we know to be a certain
93 // virtual register.
94 class FinalAssessment final : public Assessment {
95 public:
96 explicit FinalAssessment(int virtual_register,
97 const PendingAssessment* original_pending = nullptr)
98 : Assessment(Final),
99 virtual_register_(virtual_register),
100 original_pending_assessment_(original_pending) {}
101
102 int virtual_register() const { return virtual_register_; }
103 static const FinalAssessment* cast(const Assessment* assessment) {
104 CHECK(assessment->kind() == Final);
105 return static_cast<const FinalAssessment*>(assessment);
106 }
107
108 const PendingAssessment* original_pending_assessment() const {
109 return original_pending_assessment_;
110 }
111
112 private:
113 int virtual_register_;
114 const PendingAssessment* original_pending_assessment_;
115
116 DISALLOW_COPY_AND_ASSIGN(FinalAssessment);
117 };
118
111 struct OperandAsKeyLess { 119 struct OperandAsKeyLess {
112 bool operator()(const InstructionOperand& a, 120 bool operator()(const InstructionOperand& a,
113 const InstructionOperand& b) const { 121 const InstructionOperand& b) const {
114 return a.CompareCanonicalized(b); 122 return a.CompareCanonicalized(b);
115 } 123 }
116 }; 124 };
117 125
118 // Assessments associated with a basic block. 126 // Assessments associated with a basic block.
119 class BlockAssessments : public ZoneObject { 127 class BlockAssessments : public ZoneObject {
120 public: 128 public:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 static void VerifyTemp(const OperandConstraint& constraint); 232 static void VerifyTemp(const OperandConstraint& constraint);
225 static void VerifyOutput(const OperandConstraint& constraint); 233 static void VerifyOutput(const OperandConstraint& constraint);
226 234
227 void BuildConstraint(const InstructionOperand* op, 235 void BuildConstraint(const InstructionOperand* op,
228 OperandConstraint* constraint); 236 OperandConstraint* constraint);
229 void CheckConstraint(const InstructionOperand* op, 237 void CheckConstraint(const InstructionOperand* op,
230 const OperandConstraint* constraint); 238 const OperandConstraint* constraint);
231 BlockAssessments* CreateForBlock(const InstructionBlock* block); 239 BlockAssessments* CreateForBlock(const InstructionBlock* block);
232 240
233 void ValidatePendingAssessment(RpoNumber block_id, InstructionOperand op, 241 void ValidatePendingAssessment(RpoNumber block_id, InstructionOperand op,
234 PendingAssessment* assessment, 242 BlockAssessments* current_assessments,
243 const PendingAssessment* assessment,
235 int virtual_register); 244 int virtual_register);
245 void ValidateFinalAssessment(RpoNumber block_id, InstructionOperand op,
246 BlockAssessments* current_assessments,
247 const FinalAssessment* assessment,
248 int virtual_register);
236 void ValidateUse(RpoNumber block_id, BlockAssessments* current_assessments, 249 void ValidateUse(RpoNumber block_id, BlockAssessments* current_assessments,
237 InstructionOperand op, int virtual_register); 250 InstructionOperand op, int virtual_register);
238 251
239 Zone* const zone_; 252 Zone* const zone_;
240 const RegisterConfiguration* config_; 253 const RegisterConfiguration* config_;
241 const InstructionSequence* const sequence_; 254 const InstructionSequence* const sequence_;
242 Constraints constraints_; 255 Constraints constraints_;
243 ZoneMap<RpoNumber, BlockAssessments*> assessments_; 256 ZoneMap<RpoNumber, BlockAssessments*> assessments_;
244 ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_; 257 ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_;
245 258
246 // Cached structures, to avoid memory churn. Needed solely in
247 // ValidatePendingAssessment.
248 ZoneQueue<std::pair<PendingAssessment*, int>> worklist_;
249 ZoneSet<RpoNumber> seen_;
250
251 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier); 259 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier);
252 }; 260 };
253 261
254 } // namespace compiler 262 } // namespace compiler
255 } // namespace internal 263 } // namespace internal
256 } // namespace v8 264 } // namespace v8
257 265
258 #endif 266 #endif
OLDNEW
« no previous file with comments | « no previous file | src/compiler/register-allocator-verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698