| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/control-equivalence.h" | 5 #include "src/compiler/control-equivalence.h" |
| 6 #include "src/compiler/node-properties.h" | 6 #include "src/compiler/node-properties.h" |
| 7 | 7 |
| 8 #define TRACE(...) \ | 8 #define TRACE(...) \ |
| 9 do { \ | 9 do { \ |
| 10 if (FLAG_trace_turbo_ceq) PrintF(__VA_ARGS__); \ | 10 if (FLAG_trace_turbo_ceq) PrintF(__VA_ARGS__); \ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 void ControlEquivalence::VisitPost(Node* node, Node* parent_node, | 65 void ControlEquivalence::VisitPost(Node* node, Node* parent_node, |
| 66 DFSDirection direction) { | 66 DFSDirection direction) { |
| 67 TRACE("CEQ: Post-visit of #%d:%s\n", node->id(), node->op()->mnemonic()); | 67 TRACE("CEQ: Post-visit of #%d:%s\n", node->id(), node->op()->mnemonic()); |
| 68 BracketList& blist = GetBracketList(node); | 68 BracketList& blist = GetBracketList(node); |
| 69 | 69 |
| 70 // Remove brackets pointing to this node [line:19]. | 70 // Remove brackets pointing to this node [line:19]. |
| 71 BracketListDelete(blist, node, direction); | 71 BracketListDelete(blist, node, direction); |
| 72 | 72 |
| 73 // Propagate bracket list up the DFS tree [line:13]. | 73 // Propagate bracket list up the DFS tree [line:13]. |
| 74 if (parent_node != NULL) { | 74 if (parent_node != nullptr) { |
| 75 BracketList& parent_blist = GetBracketList(parent_node); | 75 BracketList& parent_blist = GetBracketList(parent_node); |
| 76 parent_blist.splice(parent_blist.end(), blist); | 76 parent_blist.splice(parent_blist.end(), blist); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 void ControlEquivalence::VisitBackedge(Node* from, Node* to, | 81 void ControlEquivalence::VisitBackedge(Node* from, Node* to, |
| 82 DFSDirection direction) { | 82 DFSDirection direction) { |
| 83 TRACE("CEQ: Backedge from #%d:%s to #%d:%s\n", from->id(), | 83 TRACE("CEQ: Backedge from #%d:%s to #%d:%s\n", from->id(), |
| 84 from->op()->mnemonic(), to->id(), to->op()->mnemonic()); | 84 from->op()->mnemonic(), to->id(), to->op()->mnemonic()); |
| 85 | 85 |
| 86 // Push backedge onto the bracket list [line:25]. | 86 // Push backedge onto the bracket list [line:25]. |
| 87 Bracket bracket = {direction, kInvalidClass, 0, from, to}; | 87 Bracket bracket = {direction, kInvalidClass, 0, from, to}; |
| 88 GetBracketList(from).push_back(bracket); | 88 GetBracketList(from).push_back(bracket); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 void ControlEquivalence::RunUndirectedDFS(Node* exit) { | 92 void ControlEquivalence::RunUndirectedDFS(Node* exit) { |
| 93 ZoneStack<DFSStackEntry> stack(zone_); | 93 ZoneStack<DFSStackEntry> stack(zone_); |
| 94 DFSPush(stack, exit, NULL, kInputDirection); | 94 DFSPush(stack, exit, nullptr, kInputDirection); |
| 95 VisitPre(exit); | 95 VisitPre(exit); |
| 96 | 96 |
| 97 while (!stack.empty()) { // Undirected depth-first backwards traversal. | 97 while (!stack.empty()) { // Undirected depth-first backwards traversal. |
| 98 DFSStackEntry& entry = stack.top(); | 98 DFSStackEntry& entry = stack.top(); |
| 99 Node* node = entry.node; | 99 Node* node = entry.node; |
| 100 | 100 |
| 101 if (entry.direction == kInputDirection) { | 101 if (entry.direction == kInputDirection) { |
| 102 if (entry.input != node->input_edges().end()) { | 102 if (entry.input != node->input_edges().end()) { |
| 103 Edge edge = *entry.input; | 103 Edge edge = *entry.input; |
| 104 Node* input = edge.to(); | 104 Node* input = edge.to(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 for (Bracket bracket : blist) { | 228 for (Bracket bracket : blist) { |
| 229 TRACE("{%d->%d} ", bracket.from->id(), bracket.to->id()); | 229 TRACE("{%d->%d} ", bracket.from->id(), bracket.to->id()); |
| 230 } | 230 } |
| 231 TRACE("\n"); | 231 TRACE("\n"); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace compiler | 235 } // namespace compiler |
| 236 } // namespace internal | 236 } // namespace internal |
| 237 } // namespace v8 | 237 } // namespace v8 |
| OLD | NEW |