| 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/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 using namespace v8::internal; | 10 using namespace v8::internal; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const InstructionOperand* y) const { | 130 const InstructionOperand* y) const { |
| 131 return (x->kind() < y->kind()) || | 131 return (x->kind() < y->kind()) || |
| 132 (x->kind() == y->kind() && x->index() < y->index()); | 132 (x->kind() == y->kind() && x->index() < y->index()); |
| 133 } | 133 } |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 InstructionOperand* CreateRandomOperand() { | 136 InstructionOperand* CreateRandomOperand() { |
| 137 int index = rng_->NextInt(6); | 137 int index = rng_->NextInt(6); |
| 138 switch (rng_->NextInt(5)) { | 138 switch (rng_->NextInt(5)) { |
| 139 case 0: | 139 case 0: |
| 140 return ConstantOperand::Create(index, main_zone()); | 140 return ConstantOperand::New(index, main_zone()); |
| 141 case 1: | 141 case 1: |
| 142 return StackSlotOperand::Create(index, main_zone()); | 142 return StackSlotOperand::New(index, main_zone()); |
| 143 case 2: | 143 case 2: |
| 144 return DoubleStackSlotOperand::Create(index, main_zone()); | 144 return DoubleStackSlotOperand::New(index, main_zone()); |
| 145 case 3: | 145 case 3: |
| 146 return RegisterOperand::Create(index, main_zone()); | 146 return RegisterOperand::New(index, main_zone()); |
| 147 case 4: | 147 case 4: |
| 148 return DoubleRegisterOperand::Create(index, main_zone()); | 148 return DoubleRegisterOperand::New(index, main_zone()); |
| 149 } | 149 } |
| 150 UNREACHABLE(); | 150 UNREACHABLE(); |
| 151 return NULL; | 151 return NULL; |
| 152 } | 152 } |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 v8::base::RandomNumberGenerator* rng_; | 155 v8::base::RandomNumberGenerator* rng_; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 | 158 |
| 159 TEST(FuzzResolver) { | 159 TEST(FuzzResolver) { |
| 160 ParallelMoveCreator pmc; | 160 ParallelMoveCreator pmc; |
| 161 for (int size = 0; size < 20; ++size) { | 161 for (int size = 0; size < 20; ++size) { |
| 162 for (int repeat = 0; repeat < 50; ++repeat) { | 162 for (int repeat = 0; repeat < 50; ++repeat) { |
| 163 ParallelMove* pm = pmc.Create(size); | 163 ParallelMove* pm = pmc.Create(size); |
| 164 | 164 |
| 165 // Note: The gap resolver modifies the ParallelMove, so interpret first. | 165 // Note: The gap resolver modifies the ParallelMove, so interpret first. |
| 166 MoveInterpreter mi1; | 166 MoveInterpreter mi1; |
| 167 mi1.AssembleParallelMove(pm); | 167 mi1.AssembleParallelMove(pm); |
| 168 | 168 |
| 169 MoveInterpreter mi2; | 169 MoveInterpreter mi2; |
| 170 GapResolver resolver(&mi2); | 170 GapResolver resolver(&mi2); |
| 171 resolver.Resolve(pm); | 171 resolver.Resolve(pm); |
| 172 | 172 |
| 173 CHECK(mi1.state() == mi2.state()); | 173 CHECK(mi1.state() == mi2.state()); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 } | 176 } |
| OLD | NEW |