| 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_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 5 #ifndef V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ |
| 6 #define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 6 #define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ |
| 7 | 7 |
| 8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
| 10 #include "src/compiler/machine-operator.h" | |
| 11 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
| 12 #include "test/unittests/test-utils.h" | 11 #include "test/unittests/test-utils.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 14 | 13 |
| 15 namespace v8 { | 14 namespace v8 { |
| 16 namespace internal { | 15 namespace internal { |
| 17 | 16 |
| 18 // Forward declarations. | 17 // Forward declarations. |
| 19 template <class T> | 18 template <class T> |
| 20 class Handle; | 19 class Handle; |
| 21 class HeapObject; | 20 class HeapObject; |
| 22 template <class T> | 21 template <class T> |
| 23 class Unique; | 22 class Unique; |
| 24 | 23 |
| 25 namespace compiler { | 24 namespace compiler { |
| 26 | 25 |
| 27 using ::testing::Matcher; | 26 using ::testing::Matcher; |
| 28 | 27 |
| 29 | 28 |
| 30 class GraphTest : public TestWithContext, public TestWithZone { | 29 class GraphTest : public TestWithContext, public TestWithZone { |
| 31 public: | 30 public: |
| 32 explicit GraphTest(int parameters = 1); | 31 explicit GraphTest(int num_parameters = 1); |
| 33 ~GraphTest() OVERRIDE; | 32 ~GraphTest() OVERRIDE; |
| 34 | 33 |
| 35 protected: | 34 protected: |
| 36 Node* Parameter(int32_t index); | 35 Node* Parameter(int32_t index = 0); |
| 37 Node* Float32Constant(volatile float value); | 36 Node* Float32Constant(volatile float value); |
| 38 Node* Float64Constant(volatile double value); | 37 Node* Float64Constant(volatile double value); |
| 39 Node* Int32Constant(int32_t value); | 38 Node* Int32Constant(int32_t value); |
| 40 Node* Uint32Constant(uint32_t value) { | 39 Node* Uint32Constant(uint32_t value) { |
| 41 return Int32Constant(bit_cast<int32_t>(value)); | 40 return Int32Constant(bit_cast<int32_t>(value)); |
| 42 } | 41 } |
| 43 Node* Int64Constant(int64_t value); | 42 Node* Int64Constant(int64_t value); |
| 44 Node* NumberConstant(volatile double value); | 43 Node* NumberConstant(volatile double value); |
| 45 Node* HeapConstant(const Handle<HeapObject>& value); | 44 Node* HeapConstant(const Handle<HeapObject>& value); |
| 46 Node* HeapConstant(const Unique<HeapObject>& value); | 45 Node* HeapConstant(const Unique<HeapObject>& value); |
| 47 Node* FalseConstant(); | 46 Node* FalseConstant(); |
| 48 Node* TrueConstant(); | 47 Node* TrueConstant(); |
| 49 Node* UndefinedConstant(); | 48 Node* UndefinedConstant(); |
| 50 | 49 |
| 51 Matcher<Node*> IsFalseConstant(); | 50 Matcher<Node*> IsFalseConstant(); |
| 52 Matcher<Node*> IsTrueConstant(); | 51 Matcher<Node*> IsTrueConstant(); |
| 53 | 52 |
| 54 CommonOperatorBuilder* common() { return &common_; } | 53 CommonOperatorBuilder* common() { return &common_; } |
| 55 Graph* graph() { return &graph_; } | 54 Graph* graph() { return &graph_; } |
| 56 | 55 |
| 57 private: | 56 private: |
| 58 CommonOperatorBuilder common_; | 57 CommonOperatorBuilder common_; |
| 59 Graph graph_; | 58 Graph graph_; |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 | 61 |
| 63 class TypedGraphTest : public GraphTest { | 62 class TypedGraphTest : public GraphTest { |
| 64 public: | 63 public: |
| 65 explicit TypedGraphTest(int parameters = 1) | 64 explicit TypedGraphTest(int num_parameters = 1); |
| 66 : GraphTest(parameters), typer_(graph(), MaybeHandle<Context>()) {} | 65 ~TypedGraphTest() OVERRIDE; |
| 67 | 66 |
| 68 protected: | 67 protected: |
| 68 Node* Parameter(int32_t index = 0) { return GraphTest::Parameter(index); } |
| 69 Node* Parameter(Type* type, int32_t index = 0); |
| 70 |
| 69 Typer* typer() { return &typer_; } | 71 Typer* typer() { return &typer_; } |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 Typer typer_; | 74 Typer typer_; |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 } // namespace compiler | 77 } // namespace compiler |
| 76 } // namespace internal | 78 } // namespace internal |
| 77 } // namespace v8 | 79 } // namespace v8 |
| 78 | 80 |
| 79 #endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 81 #endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ |
| OLD | NEW |