| 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/all-nodes.h" | 7 #include "src/compiler/all-nodes.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/counters.h" | 9 #include "src/counters.h" |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 Reduction EscapeAnalysisReducer::Reduce(Node* node) { | 100 Reduction EscapeAnalysisReducer::Reduce(Node* node) { |
| 101 Reduction reduction = ReduceNode(node); | 101 Reduction reduction = ReduceNode(node); |
| 102 if (reduction.Changed() && node != reduction.replacement()) { | 102 if (reduction.Changed() && node != reduction.replacement()) { |
| 103 escape_analysis()->SetReplacement(node, reduction.replacement()); | 103 escape_analysis()->SetReplacement(node, reduction.replacement()); |
| 104 } | 104 } |
| 105 return reduction; | 105 return reduction; |
| 106 } | 106 } |
| 107 | 107 |
| 108 namespace { | 108 namespace { |
| 109 | 109 |
| 110 Node* MaybeGuard(JSGraph* jsgraph, Node* original, Node* replacement) { | 110 Node* MaybeGuard(JSGraph* jsgraph, Zone* zone, Node* original, |
| 111 Node* replacement) { |
| 111 // We might need to guard the replacement if the type of the {replacement} | 112 // We might need to guard the replacement if the type of the {replacement} |
| 112 // node is not in a sub-type relation to the type of the the {original} node. | 113 // node is not in a sub-type relation to the type of the the {original} node. |
| 113 Type* const replacement_type = NodeProperties::GetType(replacement); | 114 Type* const replacement_type = NodeProperties::GetType(replacement); |
| 114 Type* const original_type = NodeProperties::GetType(original); | 115 Type* const original_type = NodeProperties::GetType(original); |
| 115 if (!replacement_type->Is(original_type)) { | 116 if (!replacement_type->Is(original_type)) { |
| 116 Node* const control = NodeProperties::GetControlInput(original); | 117 Node* const control = NodeProperties::GetControlInput(original); |
| 117 replacement = jsgraph->graph()->NewNode( | 118 replacement = jsgraph->graph()->NewNode( |
| 118 jsgraph->common()->TypeGuard(original_type), replacement, control); | 119 jsgraph->common()->TypeGuard(original_type), replacement, control); |
| 120 NodeProperties::SetType(replacement, original_type); |
| 119 } | 121 } |
| 120 return replacement; | 122 return replacement; |
| 121 } | 123 } |
| 122 | 124 |
| 123 } // namespace | 125 } // namespace |
| 124 | 126 |
| 125 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) { | 127 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) { |
| 126 DCHECK(node->opcode() == IrOpcode::kLoadField || | 128 DCHECK(node->opcode() == IrOpcode::kLoadField || |
| 127 node->opcode() == IrOpcode::kLoadElement); | 129 node->opcode() == IrOpcode::kLoadElement); |
| 128 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { | 130 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { |
| 129 fully_reduced_.Add(node->id()); | 131 fully_reduced_.Add(node->id()); |
| 130 } | 132 } |
| 131 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) { | 133 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) { |
| 132 if (Node* rep = escape_analysis()->GetReplacement(node)) { | 134 if (Node* rep = escape_analysis()->GetReplacement(node)) { |
| 133 isolate()->counters()->turbo_escape_loads_replaced()->Increment(); | 135 isolate()->counters()->turbo_escape_loads_replaced()->Increment(); |
| 134 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(), | 136 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(), |
| 135 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); | 137 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); |
| 136 rep = MaybeGuard(jsgraph(), node, rep); | 138 rep = MaybeGuard(jsgraph(), zone(), node, rep); |
| 137 ReplaceWithValue(node, rep); | 139 ReplaceWithValue(node, rep); |
| 138 return Replace(rep); | 140 return Replace(rep); |
| 139 } | 141 } |
| 140 } | 142 } |
| 141 return NoChange(); | 143 return NoChange(); |
| 142 } | 144 } |
| 143 | 145 |
| 144 | 146 |
| 145 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { | 147 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { |
| 146 DCHECK(node->opcode() == IrOpcode::kStoreField || | 148 DCHECK(node->opcode() == IrOpcode::kStoreField || |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 372 } |
| 371 } | 373 } |
| 372 #endif // DEBUG | 374 #endif // DEBUG |
| 373 } | 375 } |
| 374 | 376 |
| 375 Isolate* EscapeAnalysisReducer::isolate() const { return jsgraph_->isolate(); } | 377 Isolate* EscapeAnalysisReducer::isolate() const { return jsgraph_->isolate(); } |
| 376 | 378 |
| 377 } // namespace compiler | 379 } // namespace compiler |
| 378 } // namespace internal | 380 } // namespace internal |
| 379 } // namespace v8 | 381 } // namespace v8 |
| OLD | NEW |