| 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 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { | 94 public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { |
| 95 public: | 95 public: |
| 96 RawMachineAssemblerTester(MachineRepresentation p0 = kMachineLast, | 96 RawMachineAssemblerTester(MachineRepresentation p0 = kMachineLast, |
| 97 MachineRepresentation p1 = kMachineLast, | 97 MachineRepresentation p1 = kMachineLast, |
| 98 MachineRepresentation p2 = kMachineLast, | 98 MachineRepresentation p2 = kMachineLast, |
| 99 MachineRepresentation p3 = kMachineLast, | 99 MachineRepresentation p3 = kMachineLast, |
| 100 MachineRepresentation p4 = kMachineLast) | 100 MachineRepresentation p4 = kMachineLast) |
| 101 : MachineAssemblerTester<RawMachineAssembler>( | 101 : MachineAssemblerTester<RawMachineAssembler>( |
| 102 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, | 102 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, |
| 103 p4) {} | 103 p4) {} |
| 104 |
| 105 template <typename Ci, typename Fn> |
| 106 void Run(const Ci& ci, const Fn& fn) { |
| 107 typename Ci::const_iterator i; |
| 108 for (i = ci.begin(); i != ci.end(); ++i) { |
| 109 CHECK_EQ(fn(*i), this->Call(*i)); |
| 110 } |
| 111 } |
| 112 |
| 113 template <typename Ci, typename Cj, typename Fn> |
| 114 void Run(const Ci& ci, const Cj& cj, const Fn& fn) { |
| 115 typename Ci::const_iterator i; |
| 116 typename Cj::const_iterator j; |
| 117 for (i = ci.begin(); i != ci.end(); ++i) { |
| 118 for (j = cj.begin(); j != cj.end(); ++j) { |
| 119 CHECK_EQ(fn(*i, *j), this->Call(*i, *j)); |
| 120 } |
| 121 } |
| 122 } |
| 104 }; | 123 }; |
| 105 | 124 |
| 106 | 125 |
| 107 template <typename ReturnType> | 126 template <typename ReturnType> |
| 108 class StructuredMachineAssemblerTester | 127 class StructuredMachineAssemblerTester |
| 109 : public MachineAssemblerTester<StructuredMachineAssembler>, | 128 : public MachineAssemblerTester<StructuredMachineAssembler>, |
| 110 public CallHelper2<ReturnType, | 129 public CallHelper2<ReturnType, |
| 111 StructuredMachineAssemblerTester<ReturnType> > { | 130 StructuredMachineAssemblerTester<ReturnType> > { |
| 112 public: | 131 public: |
| 113 StructuredMachineAssemblerTester(MachineRepresentation p0 = kMachineLast, | 132 StructuredMachineAssemblerTester(MachineRepresentation p0 = kMachineLast, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 175 |
| 157 void AddReturn(Node* val) { | 176 void AddReturn(Node* val) { |
| 158 if (use_result_buffer) { | 177 if (use_result_buffer) { |
| 159 T->Store(rep, T->PointerConstant(&result), T->Int32Constant(0), val); | 178 T->Store(rep, T->PointerConstant(&result), T->Int32Constant(0), val); |
| 160 T->Return(T->Int32Constant(CHECK_VALUE)); | 179 T->Return(T->Int32Constant(CHECK_VALUE)); |
| 161 } else { | 180 } else { |
| 162 T->Return(val); | 181 T->Return(val); |
| 163 } | 182 } |
| 164 } | 183 } |
| 165 | 184 |
| 185 template <typename Ci, typename Cj, typename Fn> |
| 186 void Run(const Ci& ci, const Cj& cj, const Fn& fn) { |
| 187 typename Ci::const_iterator i; |
| 188 typename Cj::const_iterator j; |
| 189 for (i = ci.begin(); i != ci.end(); ++i) { |
| 190 for (j = cj.begin(); j != cj.end(); ++j) { |
| 191 CHECK_EQ(fn(*i, *j), this->call(*i, *j)); |
| 192 } |
| 193 } |
| 194 } |
| 195 |
| 166 protected: | 196 protected: |
| 167 CType p0; | 197 CType p0; |
| 168 CType p1; | 198 CType p1; |
| 169 CType result; | 199 CType result; |
| 170 }; | 200 }; |
| 171 | 201 |
| 172 | 202 |
| 173 // A helper class for testing code sequences that take two int parameters and | 203 // A helper class for testing code sequences that take two int parameters and |
| 174 // return an int value. | 204 // return an int value. |
| 175 class Int32BinopTester | 205 class Int32BinopTester |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 346 |
| 317 void Run(RawMachineAssemblerTester<int32_t>* m); | 347 void Run(RawMachineAssemblerTester<int32_t>* m); |
| 318 void RunLeft(RawMachineAssemblerTester<int32_t>* m); | 348 void RunLeft(RawMachineAssemblerTester<int32_t>* m); |
| 319 void RunRight(RawMachineAssemblerTester<int32_t>* m); | 349 void RunRight(RawMachineAssemblerTester<int32_t>* m); |
| 320 }; | 350 }; |
| 321 } // namespace compiler | 351 } // namespace compiler |
| 322 } // namespace internal | 352 } // namespace internal |
| 323 } // namespace v8 | 353 } // namespace v8 |
| 324 | 354 |
| 325 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 355 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| OLD | NEW |