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

Side by Side Diff: src/compiler/escape-analysis-reducer.cc

Issue 1577273002: [turbofan] Fix double reduce in escape analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@hash-maps
Patch Set: Created 4 years, 11 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/escape-analysis-reducer.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 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/escape-analysis-reducer.h" 5 #include "src/compiler/escape-analysis-reducer.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/counters.h" 8 #include "src/counters.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace compiler { 12 namespace compiler {
13 13
14 EscapeAnalysisReducer::EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph, 14 EscapeAnalysisReducer::EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph,
15 EscapeAnalysis* escape_analysis, 15 EscapeAnalysis* escape_analysis,
16 Zone* zone) 16 Zone* zone)
17 : AdvancedReducer(editor), 17 : AdvancedReducer(editor),
18 jsgraph_(jsgraph), 18 jsgraph_(jsgraph),
19 escape_analysis_(escape_analysis), 19 escape_analysis_(escape_analysis),
20 zone_(zone) {} 20 zone_(zone),
21 visited_(static_cast<int>(jsgraph->graph()->NodeCount()), zone) {}
21 22
22 23
23 Reduction EscapeAnalysisReducer::Reduce(Node* node) { 24 Reduction EscapeAnalysisReducer::Reduce(Node* node) {
24 switch (node->opcode()) { 25 switch (node->opcode()) {
25 case IrOpcode::kLoadField: 26 case IrOpcode::kLoadField:
26 case IrOpcode::kLoadElement: 27 case IrOpcode::kLoadElement:
27 return ReduceLoad(node); 28 return ReduceLoad(node);
28 case IrOpcode::kStoreField: 29 case IrOpcode::kStoreField:
29 case IrOpcode::kStoreElement: 30 case IrOpcode::kStoreElement:
30 return ReduceStore(node); 31 return ReduceStore(node);
(...skipping 14 matching lines...) Expand all
45 } 46 }
46 break; 47 break;
47 } 48 }
48 return NoChange(); 49 return NoChange();
49 } 50 }
50 51
51 52
52 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) { 53 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
53 DCHECK(node->opcode() == IrOpcode::kLoadField || 54 DCHECK(node->opcode() == IrOpcode::kLoadField ||
54 node->opcode() == IrOpcode::kLoadElement); 55 node->opcode() == IrOpcode::kLoadElement);
56 if (visited_.Contains(node->id())) return NoChange();
57 visited_.Add(node->id());
55 if (Node* rep = escape_analysis()->GetReplacement(node)) { 58 if (Node* rep = escape_analysis()->GetReplacement(node)) {
59 visited_.Add(node->id());
Michael Starzinger 2016/01/12 12:25:00 nit: Why add the node twice?
56 counters()->turbo_escape_loads_replaced()->Increment(); 60 counters()->turbo_escape_loads_replaced()->Increment();
57 if (FLAG_trace_turbo_escape) { 61 if (FLAG_trace_turbo_escape) {
58 PrintF("Replaced #%d (%s) with #%d (%s)\n", node->id(), 62 PrintF("Replaced #%d (%s) with #%d (%s)\n", node->id(),
59 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); 63 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
60 } 64 }
61 ReplaceWithValue(node, rep); 65 ReplaceWithValue(node, rep);
62 return Changed(rep); 66 return Changed(rep);
63 } 67 }
64 return NoChange(); 68 return NoChange();
65 } 69 }
66 70
67 71
68 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { 72 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) {
69 DCHECK(node->opcode() == IrOpcode::kStoreField || 73 DCHECK(node->opcode() == IrOpcode::kStoreField ||
70 node->opcode() == IrOpcode::kStoreElement); 74 node->opcode() == IrOpcode::kStoreElement);
75 if (visited_.Contains(node->id())) return NoChange();
76 visited_.Add(node->id());
71 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) { 77 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) {
72 if (FLAG_trace_turbo_escape) { 78 if (FLAG_trace_turbo_escape) {
73 PrintF("Removed #%d (%s) from effect chain\n", node->id(), 79 PrintF("Removed #%d (%s) from effect chain\n", node->id(),
74 node->op()->mnemonic()); 80 node->op()->mnemonic());
75 } 81 }
76 RelaxEffectsAndControls(node); 82 RelaxEffectsAndControls(node);
77 return Changed(node); 83 return Changed(node);
78 } 84 }
79 return NoChange(); 85 return NoChange();
80 } 86 }
81 87
82 88
83 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) { 89 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) {
84 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); 90 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate);
91 if (visited_.Contains(node->id())) return NoChange();
92 visited_.Add(node->id());
85 if (escape_analysis()->IsVirtual(node)) { 93 if (escape_analysis()->IsVirtual(node)) {
86 RelaxEffectsAndControls(node); 94 RelaxEffectsAndControls(node);
87 counters()->turbo_escape_allocs_replaced()->Increment(); 95 counters()->turbo_escape_allocs_replaced()->Increment();
88 if (FLAG_trace_turbo_escape) { 96 if (FLAG_trace_turbo_escape) {
89 PrintF("Removed allocate #%d from effect chain\n", node->id()); 97 PrintF("Removed allocate #%d from effect chain\n", node->id());
90 } 98 }
91 return Changed(node); 99 return Changed(node);
92 } 100 }
93 return NoChange(); 101 return NoChange();
94 } 102 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (FLAG_trace_turbo_escape) { 160 if (FLAG_trace_turbo_escape) {
153 PrintF("Replaced ObjectIsSmi #%d with false\n", node->id()); 161 PrintF("Replaced ObjectIsSmi #%d with false\n", node->id());
154 } 162 }
155 return Replace(node); 163 return Replace(node);
156 } 164 }
157 return NoChange(); 165 return NoChange();
158 } 166 }
159 167
160 168
161 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) { 169 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) {
170 if (visited_.Contains(node->id())) return NoChange();
171 visited_.Add(node->id());
162 DCHECK_GE(node->op()->EffectInputCount(), 1); 172 DCHECK_GE(node->op()->EffectInputCount(), 1);
163 bool changed = false; 173 bool changed = false;
164 for (int i = 0; i < node->InputCount(); ++i) { 174 for (int i = 0; i < node->InputCount(); ++i) {
165 Node* input = node->InputAt(i); 175 Node* input = node->InputAt(i);
166 if (input->opcode() == IrOpcode::kFrameState) { 176 if (input->opcode() == IrOpcode::kFrameState) {
167 if (Node* ret = ReduceFrameState(input, node, false)) { 177 if (Node* ret = ReduceFrameState(input, node, false)) {
168 node->ReplaceInput(i, ret); 178 node->ReplaceInput(i, ret);
169 changed = true; 179 changed = true;
170 } 180 }
171 } 181 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 297 }
288 298
289 299
290 Counters* EscapeAnalysisReducer::counters() const { 300 Counters* EscapeAnalysisReducer::counters() const {
291 return jsgraph_->isolate()->counters(); 301 return jsgraph_->isolate()->counters();
292 } 302 }
293 303
294 } // namespace compiler 304 } // namespace compiler
295 } // namespace internal 305 } // namespace internal
296 } // namespace v8 306 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/escape-analysis-reducer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698