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

Side by Side Diff: test/cctest/compiler/test-gap-resolver.cc

Issue 2060273003: [tests] Don't test moves between different reps in test-gap-resolver.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | no next file » | 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/gap-resolver.h" 5 #include "src/compiler/gap-resolver.h"
6 6
7 #include "src/base/utils/random-number-generator.h" 7 #include "src/base/utils/random-number-generator.h"
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 }; 160 };
161 161
162 162
163 class ParallelMoveCreator : public HandleAndZoneScope { 163 class ParallelMoveCreator : public HandleAndZoneScope {
164 public: 164 public:
165 ParallelMoveCreator() : rng_(CcTest::random_number_generator()) {} 165 ParallelMoveCreator() : rng_(CcTest::random_number_generator()) {}
166 166
167 ParallelMove* Create(int size) { 167 ParallelMove* Create(int size) {
168 ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone()); 168 ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone());
169 std::set<InstructionOperand, CompareOperandModuloType> seen; 169 std::set<InstructionOperand, CompareOperandModuloType> seen;
170 MachineRepresentation rep = RandomRepresentation();
170 for (int i = 0; i < size; ++i) { 171 for (int i = 0; i < size; ++i) {
171 MoveOperands mo(CreateRandomOperand(true), CreateRandomOperand(false)); 172 MoveOperands mo(CreateRandomOperand(true, rep),
173 CreateRandomOperand(false, rep));
172 if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) { 174 if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) {
173 parallel_move->AddMove(mo.source(), mo.destination()); 175 parallel_move->AddMove(mo.source(), mo.destination());
174 seen.insert(mo.destination()); 176 seen.insert(mo.destination());
175 } 177 }
176 } 178 }
177 return parallel_move; 179 return parallel_move;
178 } 180 }
179 181
180 private: 182 private:
181 MachineRepresentation RandomRepresentation() { 183 MachineRepresentation RandomRepresentation() {
182 int index = rng_->NextInt(3); 184 int index = rng_->NextInt(5);
183 switch (index) { 185 switch (index) {
184 case 0: 186 case 0:
185 return MachineRepresentation::kWord32; 187 return MachineRepresentation::kWord32;
186 case 1: 188 case 1:
187 return MachineRepresentation::kWord64; 189 return MachineRepresentation::kWord64;
188 case 2: 190 case 2:
191 return MachineRepresentation::kFloat32;
192 case 3:
193 return MachineRepresentation::kFloat64;
194 case 4:
189 return MachineRepresentation::kTagged; 195 return MachineRepresentation::kTagged;
190 } 196 }
191 UNREACHABLE(); 197 UNREACHABLE();
192 return MachineRepresentation::kNone; 198 return MachineRepresentation::kNone;
193 } 199 }
194 200
195 MachineRepresentation RandomDoubleRepresentation() { 201 InstructionOperand CreateRandomOperand(bool is_source,
196 int index = rng_->NextInt(2); 202 MachineRepresentation rep) {
197 if (index == 0) return MachineRepresentation::kFloat64;
198 return MachineRepresentation::kFloat32;
199 }
200
201 InstructionOperand CreateRandomOperand(bool is_source) {
202 int index = rng_->NextInt(7); 203 int index = rng_->NextInt(7);
203 // destination can't be Constant. 204 // destination can't be Constant.
204 switch (rng_->NextInt(is_source ? 7 : 6)) { 205 switch (rng_->NextInt(is_source ? 5 : 4)) {
205 case 0: 206 case 0:
206 return AllocatedOperand(LocationOperand::STACK_SLOT, 207 return AllocatedOperand(LocationOperand::STACK_SLOT, rep, index);
207 RandomRepresentation(), index);
208 case 1: 208 case 1:
209 return AllocatedOperand(LocationOperand::STACK_SLOT, 209 return AllocatedOperand(LocationOperand::REGISTER, rep, index);
210 RandomDoubleRepresentation(), index);
211 case 2: 210 case 2:
212 return AllocatedOperand(LocationOperand::REGISTER,
213 RandomRepresentation(), index);
214 case 3:
215 return AllocatedOperand(LocationOperand::REGISTER,
216 RandomDoubleRepresentation(), index);
217 case 4:
218 return ExplicitOperand( 211 return ExplicitOperand(
219 LocationOperand::REGISTER, RandomRepresentation(), 212 LocationOperand::REGISTER, rep,
220 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 213 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
221 ->GetAllocatableGeneralCode(1)); 214 ->GetAllocatableGeneralCode(1));
222 case 5: 215 case 3:
223 return ExplicitOperand( 216 return ExplicitOperand(
224 LocationOperand::STACK_SLOT, RandomRepresentation(), 217 LocationOperand::STACK_SLOT, rep,
225 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 218 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
226 ->GetAllocatableGeneralCode(index)); 219 ->GetAllocatableGeneralCode(index));
227 case 6: 220 case 4:
228 return ConstantOperand(index); 221 return ConstantOperand(index);
229 } 222 }
230 UNREACHABLE(); 223 UNREACHABLE();
231 return InstructionOperand(); 224 return InstructionOperand();
232 } 225 }
233 226
234 private: 227 private:
235 v8::base::RandomNumberGenerator* rng_; 228 v8::base::RandomNumberGenerator* rng_;
236 }; 229 };
237 230
(...skipping 13 matching lines...) Expand all
251 resolver.Resolve(pm); 244 resolver.Resolve(pm);
252 245
253 CHECK(mi1.state() == mi2.state()); 246 CHECK(mi1.state() == mi2.state());
254 } 247 }
255 } 248 }
256 } 249 }
257 250
258 } // namespace compiler 251 } // namespace compiler
259 } // namespace internal 252 } // namespace internal
260 } // namespace v8 253 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698