| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 node->op()->mnemonic()); | 126 node->op()->mnemonic()); |
| 127 RelaxEffectsAndControls(node); | 127 RelaxEffectsAndControls(node); |
| 128 return Changed(node); | 128 return Changed(node); |
| 129 } | 129 } |
| 130 return NoChange(); | 130 return NoChange(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) { | 134 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) { |
| 135 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); | 135 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); |
| 136 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { |
| 137 fully_reduced_.Add(node->id()); |
| 138 } |
| 136 if (escape_analysis()->IsVirtual(node)) { | 139 if (escape_analysis()->IsVirtual(node)) { |
| 137 RelaxEffectsAndControls(node); | 140 RelaxEffectsAndControls(node); |
| 138 counters()->turbo_escape_allocs_replaced()->Increment(); | 141 counters()->turbo_escape_allocs_replaced()->Increment(); |
| 139 TRACE("Removed allocate #%d from effect chain\n", node->id()); | 142 TRACE("Removed allocate #%d from effect chain\n", node->id()); |
| 140 return Changed(node); | 143 return Changed(node); |
| 141 } | 144 } |
| 142 return NoChange(); | 145 return NoChange(); |
| 143 } | 146 } |
| 144 | 147 |
| 145 | 148 |
| 146 Reduction EscapeAnalysisReducer::ReduceFinishRegion(Node* node) { | 149 Reduction EscapeAnalysisReducer::ReduceFinishRegion(Node* node) { |
| 147 DCHECK_EQ(node->opcode(), IrOpcode::kFinishRegion); | 150 DCHECK_EQ(node->opcode(), IrOpcode::kFinishRegion); |
| 148 Node* effect = NodeProperties::GetEffectInput(node, 0); | 151 Node* effect = NodeProperties::GetEffectInput(node, 0); |
| 149 if (effect->opcode() == IrOpcode::kBeginRegion) { | 152 if (effect->opcode() == IrOpcode::kBeginRegion) { |
| 153 // We only add it now to remove empty Begin/Finish region pairs |
| 154 // in the process. |
| 150 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { | 155 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { |
| 151 fully_reduced_.Add(node->id()); | 156 fully_reduced_.Add(node->id()); |
| 152 } | 157 } |
| 153 RelaxEffectsAndControls(effect); | 158 RelaxEffectsAndControls(effect); |
| 154 RelaxEffectsAndControls(node); | 159 RelaxEffectsAndControls(node); |
| 155 #ifdef DEBUG | 160 #ifdef DEBUG |
| 156 if (FLAG_trace_turbo_escape) { | 161 if (FLAG_trace_turbo_escape) { |
| 157 PrintF("Removed region #%d / #%d from effect chain,", effect->id(), | 162 PrintF("Removed region #%d / #%d from effect chain,", effect->id(), |
| 158 node->id()); | 163 node->id()); |
| 159 PrintF(" %d user(s) of #%d remain(s):", node->UseCount(), node->id()); | 164 PrintF(" %d user(s) of #%d remain(s):", node->UseCount(), node->id()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 ReplaceWithValue(node, jsgraph()->FalseConstant()); | 206 ReplaceWithValue(node, jsgraph()->FalseConstant()); |
| 202 TRACE("Replaced ObjectIsSmi #%d with false\n", node->id()); | 207 TRACE("Replaced ObjectIsSmi #%d with false\n", node->id()); |
| 203 return Replace(jsgraph()->FalseConstant()); | 208 return Replace(jsgraph()->FalseConstant()); |
| 204 } | 209 } |
| 205 return NoChange(); | 210 return NoChange(); |
| 206 } | 211 } |
| 207 | 212 |
| 208 | 213 |
| 209 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) { | 214 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) { |
| 210 DCHECK_GE(node->op()->EffectInputCount(), 1); | 215 DCHECK_GE(node->op()->EffectInputCount(), 1); |
| 216 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { |
| 217 fully_reduced_.Add(node->id()); |
| 218 } |
| 211 bool changed = false; | 219 bool changed = false; |
| 212 for (int i = 0; i < node->InputCount(); ++i) { | 220 for (int i = 0; i < node->InputCount(); ++i) { |
| 213 Node* input = node->InputAt(i); | 221 Node* input = node->InputAt(i); |
| 214 if (input->opcode() == IrOpcode::kFrameState) { | 222 if (input->opcode() == IrOpcode::kFrameState) { |
| 215 if (Node* ret = ReduceDeoptState(input, node, false)) { | 223 if (Node* ret = ReduceDeoptState(input, node, false)) { |
| 216 node->ReplaceInput(i, ret); | 224 node->ReplaceInput(i, ret); |
| 217 changed = true; | 225 changed = true; |
| 218 } | 226 } |
| 219 } | 227 } |
| 220 } | 228 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 GraphReducer graph_reducer(zone(), jsgraph()->graph()); | 358 GraphReducer graph_reducer(zone(), jsgraph()->graph()); |
| 351 EscapeAnalysisVerifier verifier(&graph_reducer, escape_analysis()); | 359 EscapeAnalysisVerifier verifier(&graph_reducer, escape_analysis()); |
| 352 graph_reducer.AddReducer(&verifier); | 360 graph_reducer.AddReducer(&verifier); |
| 353 graph_reducer.ReduceGraph(); | 361 graph_reducer.ReduceGraph(); |
| 354 #endif // DEBUG | 362 #endif // DEBUG |
| 355 } | 363 } |
| 356 | 364 |
| 357 } // namespace compiler | 365 } // namespace compiler |
| 358 } // namespace internal | 366 } // namespace internal |
| 359 } // namespace v8 | 367 } // namespace v8 |
| OLD | NEW |