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 return ReduceLoad(node); | 27 return ReduceLoad(node); |
28 case IrOpcode::kStoreField: | 28 case IrOpcode::kStoreField: |
29 case IrOpcode::kStoreElement: | 29 case IrOpcode::kStoreElement: |
30 return ReduceStore(node); | 30 return ReduceStore(node); |
31 case IrOpcode::kAllocate: | 31 case IrOpcode::kAllocate: |
32 return ReduceAllocate(node); | 32 return ReduceAllocate(node); |
33 case IrOpcode::kFinishRegion: | 33 case IrOpcode::kFinishRegion: |
34 return ReduceFinishRegion(node); | 34 return ReduceFinishRegion(node); |
35 case IrOpcode::kReferenceEqual: | 35 case IrOpcode::kReferenceEqual: |
36 return ReduceReferenceEqual(node); | 36 return ReduceReferenceEqual(node); |
37 case IrOpcode::kObjectIsSmi: | |
38 return ReduceObjectIsSmi(node); | |
37 case IrOpcode::kStateValues: | 39 case IrOpcode::kStateValues: |
38 case IrOpcode::kFrameState: | 40 case IrOpcode::kFrameState: |
39 return ReplaceWithDeoptDummy(node); | 41 return ReplaceWithDeoptDummy(node); |
40 default: | 42 default: |
41 break; | 43 break; |
42 } | 44 } |
43 return NoChange(); | 45 return NoChange(); |
44 } | 46 } |
45 | 47 |
46 | 48 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 // Left-hand side is not a virtual object. | 141 // Left-hand side is not a virtual object. |
140 ReplaceWithValue(node, jsgraph()->FalseConstant()); | 142 ReplaceWithValue(node, jsgraph()->FalseConstant()); |
141 if (FLAG_trace_turbo_escape) { | 143 if (FLAG_trace_turbo_escape) { |
142 PrintF("Replaced ref eq #%d with false\n", node->id()); | 144 PrintF("Replaced ref eq #%d with false\n", node->id()); |
143 } | 145 } |
144 } | 146 } |
145 return NoChange(); | 147 return NoChange(); |
146 } | 148 } |
147 | 149 |
148 | 150 |
151 Reduction EscapeAnalysisReducer::ReduceObjectIsSmi(Node* node) { | |
152 DCHECK_EQ(node->opcode(), IrOpcode::kObjectIsSmi); | |
153 Node* input = NodeProperties::GetValueInput(node, 0); | |
154 if (escape_analysis()->IsAllocation(input)) { | |
Michael Starzinger
2015/12/14 10:41:49
IIUC, for the escape analysis it would suffice to
sigurds
2015/12/14 11:58:09
Done.
| |
155 ReplaceWithValue(node, jsgraph()->FalseConstant()); | |
156 if (FLAG_trace_turbo_escape) { | |
157 PrintF("Replaced ObjectIsSmi #%d with false\n", node->id()); | |
158 } | |
159 return Replace(node); | |
160 } | |
161 return NoChange(); | |
162 } | |
163 | |
164 | |
149 // TODO(sigurds): This is a temporary solution until escape analysis | 165 // TODO(sigurds): This is a temporary solution until escape analysis |
150 // supports deoptimization. | 166 // supports deoptimization. |
151 Reduction EscapeAnalysisReducer::ReplaceWithDeoptDummy(Node* node) { | 167 Reduction EscapeAnalysisReducer::ReplaceWithDeoptDummy(Node* node) { |
152 DCHECK(node->opcode() == IrOpcode::kStateValues || | 168 DCHECK(node->opcode() == IrOpcode::kStateValues || |
153 node->opcode() == IrOpcode::kFrameState); | 169 node->opcode() == IrOpcode::kFrameState); |
154 Reduction r = NoChange(); | 170 Reduction r = NoChange(); |
155 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { | 171 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { |
156 Node* input = NodeProperties::GetValueInput(node, i); | 172 Node* input = NodeProperties::GetValueInput(node, i); |
157 if (input->opcode() == IrOpcode::kFinishRegion || | 173 if (input->opcode() == IrOpcode::kFinishRegion || |
158 input->opcode() == IrOpcode::kAllocate || | 174 input->opcode() == IrOpcode::kAllocate || |
159 input->opcode() == IrOpcode::kPhi) { | 175 input->opcode() == IrOpcode::kPhi) { |
160 if (escape_analysis()->IsVirtual(input)) { | 176 if (escape_analysis()->IsVirtual(input)) { |
161 NodeProperties::ReplaceValueInput(node, jsgraph()->UndefinedConstant(), | 177 NodeProperties::ReplaceValueInput(node, jsgraph()->UndefinedConstant(), |
162 i); | 178 i); |
163 if (FLAG_trace_turbo_escape) { | 179 if (FLAG_trace_turbo_escape) { |
164 PrintF("Replaced state value (#%d) input with dummy\n", node->id()); | 180 PrintF("Replaced state value (#%d) input with dummy\n", node->id()); |
165 } | 181 } |
166 r = Changed(node); | 182 r = Changed(node); |
167 } | 183 } |
168 } | 184 } |
169 } | 185 } |
170 return r; | 186 return r; |
171 } | 187 } |
172 | 188 |
173 | 189 |
174 } // namespace compiler | 190 } // namespace compiler |
175 } // namespace internal | 191 } // namespace internal |
176 } // namespace v8 | 192 } // namespace v8 |
OLD | NEW |