| 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 <set> |
| 6 |
| 5 #include "src/v8.h" | 7 #include "src/v8.h" |
| 6 | 8 |
| 7 #include "graph-tester.h" | 9 #include "graph-tester.h" |
| 8 #include "src/compiler/graph-reducer.h" | 10 #include "src/compiler/graph-reducer.h" |
| 11 #include "src/compiler/node.h" |
| 12 #include "src/compiler/operator.h" |
| 9 | 13 |
| 10 using namespace v8::internal; | 14 using namespace v8::internal; |
| 11 using namespace v8::internal::compiler; | 15 using namespace v8::internal::compiler; |
| 12 | 16 |
| 13 const uint8_t OPCODE_A0 = 10; | 17 const uint8_t OPCODE_A0 = 10; |
| 14 const uint8_t OPCODE_A1 = 11; | 18 const uint8_t OPCODE_A1 = 11; |
| 15 const uint8_t OPCODE_A2 = 12; | 19 const uint8_t OPCODE_A2 = 12; |
| 16 const uint8_t OPCODE_B0 = 20; | 20 const uint8_t OPCODE_B0 = 20; |
| 17 const uint8_t OPCODE_B1 = 21; | 21 const uint8_t OPCODE_B1 = 21; |
| 18 const uint8_t OPCODE_B2 = 22; | 22 const uint8_t OPCODE_B2 = 22; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 178 } |
| 175 } | 179 } |
| 176 return NoChange(); | 180 return NoChange(); |
| 177 } | 181 } |
| 178 }; | 182 }; |
| 179 | 183 |
| 180 | 184 |
| 181 // Simply records the nodes visited. | 185 // Simply records the nodes visited. |
| 182 class ReducerRecorder : public Reducer { | 186 class ReducerRecorder : public Reducer { |
| 183 public: | 187 public: |
| 188 typedef std::set<Node*, std::less<Node*>, zone_allocator<Node*>> NodeSet; |
| 184 explicit ReducerRecorder(Zone* zone) | 189 explicit ReducerRecorder(Zone* zone) |
| 185 : set(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {} | 190 : set(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {} |
| 186 virtual Reduction Reduce(Node* node) { | 191 virtual Reduction Reduce(Node* node) { |
| 187 set.insert(node); | 192 set.insert(node); |
| 188 return NoChange(); | 193 return NoChange(); |
| 189 } | 194 } |
| 190 void CheckContains(Node* node) { | 195 void CheckContains(Node* node) { |
| 191 CHECK_EQ(1, static_cast<int>(set.count(node))); | 196 CHECK_EQ(1, static_cast<int>(set.count(node))); |
| 192 } | 197 } |
| 193 NodeSet set; | 198 NodeSet set; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 for (int i = 0; i < 3; i++) { | 618 for (int i = 0; i < 3; i++) { |
| 614 int before = graph.NodeCount(); | 619 int before = graph.NodeCount(); |
| 615 reducer.ReduceGraph(); | 620 reducer.ReduceGraph(); |
| 616 CHECK_EQ(before, graph.NodeCount()); | 621 CHECK_EQ(before, graph.NodeCount()); |
| 617 CHECK_EQ(&OPC0, n1->op()); | 622 CHECK_EQ(&OPC0, n1->op()); |
| 618 CHECK_EQ(&OPC1, end->op()); | 623 CHECK_EQ(&OPC1, end->op()); |
| 619 CHECK_EQ(n1, end->InputAt(0)); | 624 CHECK_EQ(n1, end->InputAt(0)); |
| 620 } | 625 } |
| 621 } | 626 } |
| 622 } | 627 } |
| OLD | NEW |