OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import '../common/codegen.dart' show CodegenWorkItem; | 5 import '../common/codegen.dart' show CodegenWorkItem; |
6 import '../common/tasks.dart' show CompilerTask; | 6 import '../common/tasks.dart' show CompilerTask; |
7 import '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
10 import '../core_types.dart' show CoreClasses; | 10 import '../core_types.dart' show CoreClasses; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 ConstantValue value = getConstantFromType(node); | 240 ConstantValue value = getConstantFromType(node); |
241 if (value != null) { | 241 if (value != null) { |
242 HConstant constant = graph.addConstant(value, compiler); | 242 HConstant constant = graph.addConstant(value, compiler); |
243 for (HInstruction user in node.usedBy.toList()) { | 243 for (HInstruction user in node.usedBy.toList()) { |
244 user.changeUse(node, constant); | 244 user.changeUse(node, constant); |
245 } | 245 } |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 HInstruction visitParameterValue(HParameterValue node) { | 249 HInstruction visitParameterValue(HParameterValue node) { |
| 250 // [HParameterValue]s are either the value of the parameter (in fully SSA |
| 251 // converted code), or the mutable variable containing the value (in |
| 252 // incompletely SSA converted code, e.g. methods containing exceptions). |
| 253 // |
250 // If the parameter is used as a mutable variable we cannot replace the | 254 // If the parameter is used as a mutable variable we cannot replace the |
251 // variable with a value. | 255 // variable with a value. |
252 if (node.usedAsVariable()) return node; | 256 // |
| 257 // If the parameter is used as a mutable variable but never written, first |
| 258 // convert to a value parameter. |
| 259 |
| 260 if (node.usedAsVariable()) { |
| 261 if (!node.usedBy.every((user) => user is HLocalGet)) return node; |
| 262 // Trivial SSA-conversion. Replace all HLocalGet instructions with the |
| 263 // parameter. |
| 264 for (HLocalGet user in node.usedBy.toList()) { |
| 265 user.block.rewrite(user, node); |
| 266 user.block.remove(user); |
| 267 } |
| 268 } |
| 269 |
253 propagateConstantValueToUses(node); | 270 propagateConstantValueToUses(node); |
254 return node; | 271 return node; |
255 } | 272 } |
256 | 273 |
257 HInstruction visitBoolify(HBoolify node) { | 274 HInstruction visitBoolify(HBoolify node) { |
258 List<HInstruction> inputs = node.inputs; | 275 List<HInstruction> inputs = node.inputs; |
259 assert(inputs.length == 1); | 276 assert(inputs.length == 1); |
260 HInstruction input = inputs[0]; | 277 HInstruction input = inputs[0]; |
261 if (input.isBoolean(compiler)) return input; | 278 if (input.isBoolean(compiler)) return input; |
262 | 279 |
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2407 | 2424 |
2408 keyedValues.forEach((receiver, values) { | 2425 keyedValues.forEach((receiver, values) { |
2409 result.keyedValues[receiver] = | 2426 result.keyedValues[receiver] = |
2410 new Map<HInstruction, HInstruction>.from(values); | 2427 new Map<HInstruction, HInstruction>.from(values); |
2411 }); | 2428 }); |
2412 | 2429 |
2413 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2430 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
2414 return result; | 2431 return result; |
2415 } | 2432 } |
2416 } | 2433 } |
OLD | NEW |