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 interface OptimizationPhase { | 5 interface OptimizationPhase { |
6 String get name(); | 6 String get name(); |
7 void visitGraph(HGraph graph); | 7 void visitGraph(HGraph graph); |
8 } | 8 } |
9 | 9 |
10 class SsaOptimizerTask extends CompilerTask { | 10 class SsaOptimizerTask extends CompilerTask { |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 break; | 620 break; |
621 } | 621 } |
622 } | 622 } |
623 return new HFieldGet(field, node.inputs[0], isAssignable: !isFinalOrConst); | 623 return new HFieldGet(field, node.inputs[0], isAssignable: !isFinalOrConst); |
624 } | 624 } |
625 | 625 |
626 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 626 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
627 Element field = | 627 Element field = |
628 findConcreteFieldForDynamicAccess(node.receiver, node.selector); | 628 findConcreteFieldForDynamicAccess(node.receiver, node.selector); |
629 if (field === null) return node; | 629 if (field === null) return node; |
630 return new HFieldSet(field, node.inputs[0], node.inputs[1]); | 630 HInstruction value = node.inputs[1]; |
| 631 if (compiler.enableTypeAssertions) { |
| 632 HInstruction other = value.convertType( |
| 633 compiler, field, HTypeConversion.CHECKED_MODE_CHECK); |
| 634 if (other != value) { |
| 635 node.block.addBefore(node, other); |
| 636 value = other; |
| 637 } |
| 638 } |
| 639 return new HFieldSet(field, node.inputs[0], value); |
631 } | 640 } |
632 | 641 |
633 HInstruction visitStringConcat(HStringConcat node) { | 642 HInstruction visitStringConcat(HStringConcat node) { |
634 DartString folded = const LiteralDartString(""); | 643 DartString folded = const LiteralDartString(""); |
635 for (int i = 0; i < node.inputs.length; i++) { | 644 for (int i = 0; i < node.inputs.length; i++) { |
636 HInstruction part = node.inputs[i]; | 645 HInstruction part = node.inputs[i]; |
637 if (!part.isConstant()) return node; | 646 if (!part.isConstant()) return node; |
638 HConstant constant = part; | 647 HConstant constant = part; |
639 if (!constant.constant.isPrimitive()) return node; | 648 if (!constant.constant.isPrimitive()) return node; |
640 PrimitiveConstant primitive = constant.constant; | 649 PrimitiveConstant primitive = constant.constant; |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 // this type for the field is still a strong signal | 1345 // this type for the field is still a strong signal |
1337 // indicating the expected type of the field. | 1346 // indicating the expected type of the field. |
1338 types[field] = type; | 1347 types[field] = type; |
1339 } else { | 1348 } else { |
1340 // If there are no invoked setters we know the type of | 1349 // If there are no invoked setters we know the type of |
1341 // this field for sure. | 1350 // this field for sure. |
1342 field.guaranteedType = type; | 1351 field.guaranteedType = type; |
1343 } | 1352 } |
1344 } | 1353 } |
1345 } | 1354 } |
OLD | NEW |