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/bit-vector.h" | 5 #include "src/bit-vector.h" |
6 #include "src/compiler/control-equivalence.h" | 6 #include "src/compiler/control-equivalence.h" |
7 #include "src/compiler/graph-visualizer.h" | 7 #include "src/compiler/graph-visualizer.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 #include "src/compiler/source-position.h" |
9 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
10 #include "test/unittests/compiler/graph-unittest.h" | 11 #include "test/unittests/compiler/graph-unittest.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 namespace compiler { | 15 namespace compiler { |
15 | 16 |
16 #define ASSERT_EQUIVALENCE(...) \ | 17 #define ASSERT_EQUIVALENCE(...) \ |
17 do { \ | 18 do { \ |
18 Node* __n[] = {__VA_ARGS__}; \ | 19 Node* __n[] = {__VA_ARGS__}; \ |
19 ASSERT_TRUE(IsEquivalenceClass(arraysize(__n), __n)); \ | 20 ASSERT_TRUE(IsEquivalenceClass(arraysize(__n), __n)); \ |
20 } while (false) | 21 } while (false) |
21 | 22 |
22 class ControlEquivalenceTest : public GraphTest { | 23 class ControlEquivalenceTest : public GraphTest { |
23 public: | 24 public: |
24 ControlEquivalenceTest() : all_nodes_(zone()), classes_(zone()) { | 25 ControlEquivalenceTest() : all_nodes_(zone()), classes_(zone()) { |
25 Store(graph()->start()); | 26 Store(graph()->start()); |
26 } | 27 } |
27 | 28 |
28 protected: | 29 protected: |
29 void ComputeEquivalence(Node* node) { | 30 void ComputeEquivalence(Node* node) { |
30 graph()->SetEnd(graph()->NewNode(common()->End(1), node)); | 31 graph()->SetEnd(graph()->NewNode(common()->End(1), node)); |
31 if (FLAG_trace_turbo) { | 32 if (FLAG_trace_turbo) { |
32 OFStream os(stdout); | 33 OFStream os(stdout); |
33 os << AsDOT(*graph()); | 34 SourcePositionTable table(graph()); |
| 35 os << AsJSON(*graph(), &table); |
34 } | 36 } |
35 ControlEquivalence equivalence(zone(), graph()); | 37 ControlEquivalence equivalence(zone(), graph()); |
36 equivalence.Run(node); | 38 equivalence.Run(node); |
37 classes_.resize(graph()->NodeCount()); | 39 classes_.resize(graph()->NodeCount()); |
38 for (Node* node : all_nodes_) { | 40 for (Node* node : all_nodes_) { |
39 classes_[node->id()] = equivalence.ClassOf(node); | 41 classes_[node->id()] = equivalence.ClassOf(node); |
40 } | 42 } |
41 } | 43 } |
42 | 44 |
43 bool IsEquivalenceClass(size_t length, Node** nodes) { | 45 bool IsEquivalenceClass(size_t length, Node** nodes) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ASSERT_EQUIVALENCE(t2); | 252 ASSERT_EQUIVALENCE(t2); |
251 ASSERT_EQUIVALENCE(f2); | 253 ASSERT_EQUIVALENCE(f2); |
252 ASSERT_EQUIVALENCE(f3); | 254 ASSERT_EQUIVALENCE(f3); |
253 ASSERT_EQUIVALENCE(lp); | 255 ASSERT_EQUIVALENCE(lp); |
254 } | 256 } |
255 | 257 |
256 | 258 |
257 } // namespace compiler | 259 } // namespace compiler |
258 } // namespace internal | 260 } // namespace internal |
259 } // namespace v8 | 261 } // namespace v8 |
OLD | NEW |