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/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 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 DCHECK(node->opcode() == IrOpcode::kLoadField || | 102 DCHECK(node->opcode() == IrOpcode::kLoadField || |
103 node->opcode() == IrOpcode::kLoadElement); | 103 node->opcode() == IrOpcode::kLoadElement); |
104 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { | 104 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { |
105 fully_reduced_.Add(node->id()); | 105 fully_reduced_.Add(node->id()); |
106 } | 106 } |
107 if (Node* rep = escape_analysis()->GetReplacement(node)) { | 107 if (Node* rep = escape_analysis()->GetReplacement(node)) { |
108 counters()->turbo_escape_loads_replaced()->Increment(); | 108 counters()->turbo_escape_loads_replaced()->Increment(); |
109 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(), | 109 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(), |
110 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); | 110 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); |
111 ReplaceWithValue(node, rep); | 111 ReplaceWithValue(node, rep); |
112 return Changed(rep); | 112 return Replace(rep); |
113 } | 113 } |
114 return NoChange(); | 114 return NoChange(); |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { | 118 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { |
119 DCHECK(node->opcode() == IrOpcode::kStoreField || | 119 DCHECK(node->opcode() == IrOpcode::kStoreField || |
120 node->opcode() == IrOpcode::kStoreElement); | 120 node->opcode() == IrOpcode::kStoreElement); |
121 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { | 121 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { |
122 fully_reduced_.Add(node->id()); | 122 fully_reduced_.Add(node->id()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 Reduction EscapeAnalysisReducer::ReduceReferenceEqual(Node* node) { | 172 Reduction EscapeAnalysisReducer::ReduceReferenceEqual(Node* node) { |
173 DCHECK_EQ(node->opcode(), IrOpcode::kReferenceEqual); | 173 DCHECK_EQ(node->opcode(), IrOpcode::kReferenceEqual); |
174 Node* left = NodeProperties::GetValueInput(node, 0); | 174 Node* left = NodeProperties::GetValueInput(node, 0); |
175 Node* right = NodeProperties::GetValueInput(node, 1); | 175 Node* right = NodeProperties::GetValueInput(node, 1); |
176 if (escape_analysis()->IsVirtual(left)) { | 176 if (escape_analysis()->IsVirtual(left)) { |
177 if (escape_analysis()->IsVirtual(right) && | 177 if (escape_analysis()->IsVirtual(right) && |
178 escape_analysis()->CompareVirtualObjects(left, right)) { | 178 escape_analysis()->CompareVirtualObjects(left, right)) { |
179 ReplaceWithValue(node, jsgraph()->TrueConstant()); | 179 ReplaceWithValue(node, jsgraph()->TrueConstant()); |
180 TRACE("Replaced ref eq #%d with true\n", node->id()); | 180 TRACE("Replaced ref eq #%d with true\n", node->id()); |
| 181 Replace(jsgraph()->TrueConstant()); |
181 } | 182 } |
182 // Right-hand side is not a virtual object, or a different one. | 183 // Right-hand side is not a virtual object, or a different one. |
183 ReplaceWithValue(node, jsgraph()->FalseConstant()); | 184 ReplaceWithValue(node, jsgraph()->FalseConstant()); |
184 TRACE("Replaced ref eq #%d with false\n", node->id()); | 185 TRACE("Replaced ref eq #%d with false\n", node->id()); |
185 return Replace(node); | 186 return Replace(jsgraph()->FalseConstant()); |
186 } else if (escape_analysis()->IsVirtual(right)) { | 187 } else if (escape_analysis()->IsVirtual(right)) { |
187 // Left-hand side is not a virtual object. | 188 // Left-hand side is not a virtual object. |
188 ReplaceWithValue(node, jsgraph()->FalseConstant()); | 189 ReplaceWithValue(node, jsgraph()->FalseConstant()); |
189 TRACE("Replaced ref eq #%d with false\n", node->id()); | 190 TRACE("Replaced ref eq #%d with false\n", node->id()); |
190 return Replace(node); | 191 return Replace(jsgraph()->FalseConstant()); |
191 } | 192 } |
192 return NoChange(); | 193 return NoChange(); |
193 } | 194 } |
194 | 195 |
195 | 196 |
196 Reduction EscapeAnalysisReducer::ReduceObjectIsSmi(Node* node) { | 197 Reduction EscapeAnalysisReducer::ReduceObjectIsSmi(Node* node) { |
197 DCHECK_EQ(node->opcode(), IrOpcode::kObjectIsSmi); | 198 DCHECK_EQ(node->opcode(), IrOpcode::kObjectIsSmi); |
198 Node* input = NodeProperties::GetValueInput(node, 0); | 199 Node* input = NodeProperties::GetValueInput(node, 0); |
199 if (escape_analysis()->IsVirtual(input)) { | 200 if (escape_analysis()->IsVirtual(input)) { |
200 ReplaceWithValue(node, jsgraph()->FalseConstant()); | 201 ReplaceWithValue(node, jsgraph()->FalseConstant()); |
201 TRACE("Replaced ObjectIsSmi #%d with false\n", node->id()); | 202 TRACE("Replaced ObjectIsSmi #%d with false\n", node->id()); |
202 return Replace(node); | 203 return Replace(jsgraph()->FalseConstant()); |
203 } | 204 } |
204 return NoChange(); | 205 return NoChange(); |
205 } | 206 } |
206 | 207 |
207 | 208 |
208 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) { | 209 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) { |
209 DCHECK_GE(node->op()->EffectInputCount(), 1); | 210 DCHECK_GE(node->op()->EffectInputCount(), 1); |
210 bool changed = false; | 211 bool changed = false; |
211 for (int i = 0; i < node->InputCount(); ++i) { | 212 for (int i = 0; i < node->InputCount(); ++i) { |
212 Node* input = node->InputAt(i); | 213 Node* input = node->InputAt(i); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 GraphReducer graph_reducer(zone(), jsgraph()->graph()); | 350 GraphReducer graph_reducer(zone(), jsgraph()->graph()); |
350 EscapeAnalysisVerifier verifier(&graph_reducer, escape_analysis()); | 351 EscapeAnalysisVerifier verifier(&graph_reducer, escape_analysis()); |
351 graph_reducer.AddReducer(&verifier); | 352 graph_reducer.AddReducer(&verifier); |
352 graph_reducer.ReduceGraph(); | 353 graph_reducer.ReduceGraph(); |
353 #endif // DEBUG | 354 #endif // DEBUG |
354 } | 355 } |
355 | 356 |
356 } // namespace compiler | 357 } // namespace compiler |
357 } // namespace internal | 358 } // namespace internal |
358 } // namespace v8 | 359 } // namespace v8 |
OLD | NEW |