Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/loop-variable-optimizer.cc

Issue 2274053002: [turbofan] Change map to vector in loop variable analysis. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/loop-variable-optimizer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/loop-variable-optimizer.h" 5 #include "src/compiler/loop-variable-optimizer.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
9 #include "src/compiler/node-marker.h" 9 #include "src/compiler/node-marker.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 10 matching lines...) Expand all
21 do { \ 21 do { \
22 if (FLAG_trace_turbo_loop) PrintF(__VA_ARGS__); \ 22 if (FLAG_trace_turbo_loop) PrintF(__VA_ARGS__); \
23 } while (false) 23 } while (false)
24 24
25 LoopVariableOptimizer::LoopVariableOptimizer(Graph* graph, 25 LoopVariableOptimizer::LoopVariableOptimizer(Graph* graph,
26 CommonOperatorBuilder* common, 26 CommonOperatorBuilder* common,
27 Zone* zone) 27 Zone* zone)
28 : graph_(graph), 28 : graph_(graph),
29 common_(common), 29 common_(common),
30 zone_(zone), 30 zone_(zone),
31 limits_(zone), 31 limits_(graph->NodeCount(), zone),
32 induction_vars_(zone) {} 32 induction_vars_(zone) {}
33 33
34 void LoopVariableOptimizer::Run() { 34 void LoopVariableOptimizer::Run() {
35 ZoneQueue<Node*> queue(zone()); 35 ZoneQueue<Node*> queue(zone());
36 queue.push(graph()->start()); 36 queue.push(graph()->start());
37 NodeMarker<bool> queued(graph(), 2); 37 NodeMarker<bool> queued(graph(), 2);
38 while (!queue.empty()) { 38 while (!queue.empty()) {
39 Node* node = queue.front(); 39 Node* node = queue.front();
40 queue.pop(); 40 queue.pop();
41 queued.Set(node, false); 41 queued.Set(node, false);
42 42
43 DCHECK(limits_.find(node->id()) == limits_.end()); 43 DCHECK_NULL(limits_[node->id()]);
44 bool all_inputs_visited = true; 44 bool all_inputs_visited = true;
45 int inputs_end = (node->opcode() == IrOpcode::kLoop) 45 int inputs_end = (node->opcode() == IrOpcode::kLoop)
46 ? kFirstBackedge 46 ? kFirstBackedge
47 : node->op()->ControlInputCount(); 47 : node->op()->ControlInputCount();
48 for (int i = 0; i < inputs_end; i++) { 48 for (int i = 0; i < inputs_end; i++) {
49 auto input = limits_.find(NodeProperties::GetControlInput(node, i)->id()); 49 if (limits_[NodeProperties::GetControlInput(node, i)->id()] == nullptr) {
50 if (input == limits_.end()) {
51 all_inputs_visited = false; 50 all_inputs_visited = false;
52 break; 51 break;
53 } 52 }
54 } 53 }
55 if (!all_inputs_visited) continue; 54 if (!all_inputs_visited) continue;
56 55
57 VisitNode(node); 56 VisitNode(node);
58 DCHECK(limits_.find(node->id()) != limits_.end()); 57 DCHECK_NOT_NULL(limits_[node->id()]);
59 58
60 // Queue control outputs. 59 // Queue control outputs.
61 for (Edge edge : node->use_edges()) { 60 for (Edge edge : node->use_edges()) {
62 if (NodeProperties::IsControlEdge(edge) && 61 if (NodeProperties::IsControlEdge(edge) &&
63 edge.from()->op()->ControlOutputCount() > 0) { 62 edge.from()->op()->ControlOutputCount() > 0) {
64 Node* use = edge.from(); 63 Node* use = edge.from();
65 if (use->opcode() == IrOpcode::kLoop && 64 if (use->opcode() == IrOpcode::kLoop &&
66 edge.index() != kAssumedLoopEntryIndex) { 65 edge.index() != kAssumedLoopEntryIndex) {
67 VisitBackedge(node, use); 66 VisitBackedge(node, use);
68 } else if (!queued.Get(use)) { 67 } else if (!queued.Get(use)) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 backedge_value, backedge_control); 396 backedge_value, backedge_control);
398 induction_var->phi()->ReplaceInput(1, rename); 397 induction_var->phi()->ReplaceInput(1, rename);
399 } 398 }
400 } 399 }
401 } 400 }
402 } 401 }
403 402
404 } // namespace compiler 403 } // namespace compiler
405 } // namespace internal 404 } // namespace internal
406 } // namespace v8 405 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/loop-variable-optimizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698