OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compiler/graph.h" | |
Michael Starzinger
2016/10/25 09:16:03
nit: Please keep the graph.h include at the top wi
Mircea Trofin
2016/10/25 15:27:19
Done.
| |
6 | |
7 #include <algorithm> | 5 #include <algorithm> |
8 | 6 |
9 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/compiler/all-nodes.h" | |
9 #include "src/compiler/graph.h" | |
10 #include "src/compiler/node-properties.h" | |
10 #include "src/compiler/node.h" | 11 #include "src/compiler/node.h" |
11 #include "src/compiler/node-properties.h" | |
12 #include "src/compiler/verifier.h" | 12 #include "src/compiler/verifier.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace compiler { | 16 namespace compiler { |
17 | 17 |
18 Graph::Graph(Zone* zone) | 18 Graph::Graph(Zone* zone) |
19 : zone_(zone), | 19 : zone_(zone), |
20 start_(nullptr), | 20 start_(nullptr), |
21 end_(nullptr), | 21 end_(nullptr), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 return clone; | 65 return clone; |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 NodeId Graph::NextNodeId() { | 69 NodeId Graph::NextNodeId() { |
70 NodeId const id = next_node_id_; | 70 NodeId const id = next_node_id_; |
71 CHECK(!base::bits::UnsignedAddOverflow32(id, 1, &next_node_id_)); | 71 CHECK(!base::bits::UnsignedAddOverflow32(id, 1, &next_node_id_)); |
72 return id; | 72 return id; |
73 } | 73 } |
74 | 74 |
75 void Graph::Print() const { | |
76 AllNodes all(zone(), this); | |
77 // Get all the nodes in a map keyed by their ID. That ensures we have them | |
78 // sorted by ID, which makes it easy to find nodes (e.g. inputs) by their | |
79 // ID, in the printout. | |
80 std::map<int, Node*> map; | |
81 for (Node* node : all.reachable) map.insert(std::make_pair(node->id(), node)); | |
82 for (auto& pair : map) pair.second->Print(); | |
Michael Starzinger
2016/10/25 09:16:03
How would you feel about using "OFStream os(stdout
Mircea Trofin
2016/10/25 15:27:19
Happy to, and done - it is unfortunate the API isn
| |
83 } | |
84 | |
75 } // namespace compiler | 85 } // namespace compiler |
76 } // namespace internal | 86 } // namespace internal |
77 } // namespace v8 | 87 } // namespace v8 |
OLD | NEW |