| 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_GRAPH_BUILDER_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ |
| 6 #define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace compiler { | 21 namespace compiler { |
| 22 | 22 |
| 23 class GraphAndBuilders { | 23 class GraphAndBuilders { |
| 24 public: | 24 public: |
| 25 explicit GraphAndBuilders(Zone* zone) | 25 explicit GraphAndBuilders(Zone* zone) |
| 26 : main_graph_(new (zone) Graph(zone)), | 26 : main_graph_(new (zone) Graph(zone)), |
| 27 main_common_(zone), | 27 main_common_(zone), |
| 28 main_machine_(zone), | 28 main_machine_(zone), |
| 29 main_simplified_(zone) {} | 29 main_simplified_(zone) {} |
| 30 | 30 |
| 31 Graph* graph() const { return main_graph_; } |
| 32 Zone* zone() const { return graph()->zone(); } |
| 33 CommonOperatorBuilder* common() { return &main_common_; } |
| 34 MachineOperatorBuilder* machine() { return &main_machine_; } |
| 35 SimplifiedOperatorBuilder* simplified() { return &main_simplified_; } |
| 36 |
| 31 protected: | 37 protected: |
| 32 // Prefixed with main_ to avoid naming conflicts. | 38 // Prefixed with main_ to avoid naming conflicts. |
| 33 Graph* main_graph_; | 39 Graph* main_graph_; |
| 34 CommonOperatorBuilder main_common_; | 40 CommonOperatorBuilder main_common_; |
| 35 MachineOperatorBuilder main_machine_; | 41 MachineOperatorBuilder main_machine_; |
| 36 SimplifiedOperatorBuilder main_simplified_; | 42 SimplifiedOperatorBuilder main_simplified_; |
| 37 }; | 43 }; |
| 38 | 44 |
| 39 | 45 |
| 40 template <typename ReturnType> | 46 template <typename ReturnType> |
| 41 class GraphBuilderTester : public HandleAndZoneScope, | 47 class GraphBuilderTester : public HandleAndZoneScope, |
| 42 private GraphAndBuilders, | 48 public GraphAndBuilders, |
| 43 public CallHelper<ReturnType> { | 49 public CallHelper<ReturnType> { |
| 44 public: | 50 public: |
| 45 explicit GraphBuilderTester(MachineType p0 = kMachNone, | 51 explicit GraphBuilderTester(MachineType p0 = kMachNone, |
| 46 MachineType p1 = kMachNone, | 52 MachineType p1 = kMachNone, |
| 47 MachineType p2 = kMachNone, | 53 MachineType p2 = kMachNone, |
| 48 MachineType p3 = kMachNone, | 54 MachineType p3 = kMachNone, |
| 49 MachineType p4 = kMachNone) | 55 MachineType p4 = kMachNone) |
| 50 : GraphAndBuilders(main_zone()), | 56 : GraphAndBuilders(main_zone()), |
| 51 CallHelper<ReturnType>( | 57 CallHelper<ReturnType>( |
| 52 main_isolate(), | 58 main_isolate(), |
| 53 CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p0, p1, | 59 CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p0, p1, |
| 54 p2, p3, p4)), | 60 p2, p3, p4)), |
| 55 effect_(NULL), | 61 effect_(NULL), |
| 56 return_(NULL), | 62 return_(NULL), |
| 57 parameters_(main_zone()->template NewArray<Node*>(parameter_count())) { | 63 parameters_(main_zone()->template NewArray<Node*>(parameter_count())) { |
| 58 Begin(static_cast<int>(parameter_count())); | 64 Begin(static_cast<int>(parameter_count())); |
| 59 InitParameters(); | 65 InitParameters(); |
| 60 } | 66 } |
| 61 virtual ~GraphBuilderTester() {} | 67 virtual ~GraphBuilderTester() {} |
| 62 | 68 |
| 63 void GenerateCode() { Generate(); } | 69 void GenerateCode() { Generate(); } |
| 64 Node* Parameter(size_t index) { | 70 Node* Parameter(size_t index) { |
| 65 DCHECK(index < parameter_count()); | 71 DCHECK(index < parameter_count()); |
| 66 return parameters_[index]; | 72 return parameters_[index]; |
| 67 } | 73 } |
| 68 | 74 |
| 69 Isolate* isolate() { return main_isolate(); } | 75 Isolate* isolate() { return main_isolate(); } |
| 70 Graph* graph() const { return main_graph_; } | |
| 71 Zone* zone() const { return graph()->zone(); } | |
| 72 Factory* factory() { return isolate()->factory(); } | 76 Factory* factory() { return isolate()->factory(); } |
| 73 CommonOperatorBuilder* common() { return &main_common_; } | |
| 74 MachineOperatorBuilder* machine() { return &main_machine_; } | |
| 75 SimplifiedOperatorBuilder* simplified() { return &main_simplified_; } | |
| 76 | 77 |
| 77 // Initialize graph and builder. | 78 // Initialize graph and builder. |
| 78 void Begin(int num_parameters) { | 79 void Begin(int num_parameters) { |
| 79 DCHECK(graph()->start() == NULL); | 80 DCHECK(graph()->start() == NULL); |
| 80 Node* start = graph()->NewNode(common()->Start(num_parameters + 3)); | 81 Node* start = graph()->NewNode(common()->Start(num_parameters + 3)); |
| 81 graph()->SetStart(start); | 82 graph()->SetStart(start); |
| 82 effect_ = start; | 83 effect_ = start; |
| 83 } | 84 } |
| 84 | 85 |
| 85 void Return(Node* value) { | 86 void Return(Node* value) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 Node* return_; | 298 Node* return_; |
| 298 Node** parameters_; | 299 Node** parameters_; |
| 299 MaybeHandle<Code> code_; | 300 MaybeHandle<Code> code_; |
| 300 }; | 301 }; |
| 301 | 302 |
| 302 } // namespace compiler | 303 } // namespace compiler |
| 303 } // namespace internal | 304 } // namespace internal |
| 304 } // namespace v8 | 305 } // namespace v8 |
| 305 | 306 |
| 306 #endif // V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ | 307 #endif // V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ |
| OLD | NEW |