| 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/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 case IrOpcode::kStoreField: | 27 case IrOpcode::kStoreField: |
| 28 return ReduceStoreField(node); | 28 return ReduceStoreField(node); |
| 29 case IrOpcode::kAllocate: | 29 case IrOpcode::kAllocate: |
| 30 return ReduceAllocate(node); | 30 return ReduceAllocate(node); |
| 31 case IrOpcode::kFinishRegion: | 31 case IrOpcode::kFinishRegion: |
| 32 return ReduceFinishRegion(node); | 32 return ReduceFinishRegion(node); |
| 33 case IrOpcode::kReferenceEqual: | 33 case IrOpcode::kReferenceEqual: |
| 34 return ReduceReferenceEqual(node); | 34 return ReduceReferenceEqual(node); |
| 35 case IrOpcode::kStateValues: | 35 case IrOpcode::kStateValues: |
| 36 case IrOpcode::kFrameState: | 36 case IrOpcode::kFrameState: |
| 37 return ReplaceWithDeoptDummy(node); | 37 return ReduceStateValueInputs(node); |
| 38 default: | 38 default: |
| 39 break; | 39 break; |
| 40 } | 40 } |
| 41 return NoChange(); | 41 return NoChange(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 | 44 |
| 45 Reduction EscapeAnalysisReducer::ReduceLoadField(Node* node) { | 45 Reduction EscapeAnalysisReducer::ReduceLoadField(Node* node) { |
| 46 DCHECK_EQ(node->opcode(), IrOpcode::kLoadField); | 46 DCHECK_EQ(node->opcode(), IrOpcode::kLoadField); |
| 47 if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) { | 47 if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Left-hand side is not a virtual object. | 133 // Left-hand side is not a virtual object. |
| 134 ReplaceWithValue(node, jsgraph()->FalseConstant()); | 134 ReplaceWithValue(node, jsgraph()->FalseConstant()); |
| 135 if (FLAG_trace_turbo_escape) { | 135 if (FLAG_trace_turbo_escape) { |
| 136 PrintF("Replaced ref eq #%d with false\n", node->id()); | 136 PrintF("Replaced ref eq #%d with false\n", node->id()); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 return NoChange(); | 139 return NoChange(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 // TODO(sigurds): This is a temporary solution until escape analysis | 143 Reduction EscapeAnalysisReducer::ReduceStateValueInputs(Node* node) { |
| 144 // supports deoptimization. | |
| 145 Reduction EscapeAnalysisReducer::ReplaceWithDeoptDummy(Node* node) { | |
| 146 DCHECK(node->opcode() == IrOpcode::kStateValues || | 144 DCHECK(node->opcode() == IrOpcode::kStateValues || |
| 147 node->opcode() == IrOpcode::kFrameState); | 145 node->opcode() == IrOpcode::kFrameState); |
| 146 Node* effect = escape_analysis()->GetEffect(node); |
| 147 DCHECK_NOT_NULL(effect); |
| 148 Reduction r = NoChange(); | 148 Reduction r = NoChange(); |
| 149 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { | 149 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { |
| 150 Node* input = NodeProperties::GetValueInput(node, i); | 150 Node* input = NodeProperties::GetValueInput(node, i); |
| 151 if (input->opcode() == IrOpcode::kFinishRegion || | 151 if (input->opcode() == IrOpcode::kFinishRegion || |
| 152 input->opcode() == IrOpcode::kAllocate || | 152 input->opcode() == IrOpcode::kAllocate) { |
| 153 input->opcode() == IrOpcode::kPhi) { | |
| 154 if (escape_analysis()->IsVirtual(input)) { | 153 if (escape_analysis()->IsVirtual(input)) { |
| 155 NodeProperties::ReplaceValueInput(node, jsgraph()->UndefinedConstant(), | 154 if (Node* object_state = |
| 156 i); | 155 escape_analysis()->GetOrCreateObjectState(effect, input)) { |
| 157 if (FLAG_trace_turbo_escape) { | 156 NodeProperties::ReplaceValueInput(node, object_state, i); |
| 158 PrintF("Replaced state value (#%d) input with dummy\n", node->id()); | 157 if (FLAG_trace_turbo_escape) { |
| 158 PrintF("Replaced state value (#%d) input with object state #%d\n", |
| 159 node->id(), object_state->id()); |
| 160 } |
| 161 r = Changed(node); |
| 159 } | 162 } |
| 160 r = Changed(node); | |
| 161 } | 163 } |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 return r; | 166 return r; |
| 165 } | 167 } |
| 166 | 168 |
| 167 | |
| 168 } // namespace compiler | 169 } // namespace compiler |
| 169 } // namespace internal | 170 } // namespace internal |
| 170 } // namespace v8 | 171 } // namespace v8 |
| OLD | NEW |