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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 break; | 614 break; |
615 } | 615 } |
616 } | 616 } |
617 return new HFieldGet(field, node.inputs[0]); | 617 return new HFieldGet(field, node.inputs[0]); |
618 } | 618 } |
619 | 619 |
620 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 620 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
621 Element field = | 621 Element field = |
622 findConcreteFieldForDynamicAccess(node.receiver, node.selector); | 622 findConcreteFieldForDynamicAccess(node.receiver, node.selector); |
623 if (field === null) return node; | 623 if (field === null) return node; |
624 return new HFieldSet(field, node.inputs[0], node.inputs[1]); | 624 HInstruction value = node.inputs[1]; |
| 625 if (compiler.enableTypeAssertions) { |
| 626 HInstruction other = value.convertType( |
| 627 compiler, field, HTypeConversion.CHECKED_MODE_CHECK); |
| 628 if (other != value) { |
| 629 node.block.addBefore(node, other); |
| 630 value = other; |
| 631 } |
| 632 } |
| 633 return new HFieldSet(field, node.inputs[0], value); |
625 } | 634 } |
626 | 635 |
627 HInstruction visitStringConcat(HStringConcat node) { | 636 HInstruction visitStringConcat(HStringConcat node) { |
628 DartString folded = const LiteralDartString(""); | 637 DartString folded = const LiteralDartString(""); |
629 for (int i = 0; i < node.inputs.length; i++) { | 638 for (int i = 0; i < node.inputs.length; i++) { |
630 HInstruction part = node.inputs[i]; | 639 HInstruction part = node.inputs[i]; |
631 if (!part.isConstant()) return node; | 640 if (!part.isConstant()) return node; |
632 HConstant constant = part; | 641 HConstant constant = part; |
633 if (!constant.constant.isPrimitive()) return node; | 642 if (!constant.constant.isPrimitive()) return node; |
634 PrimitiveConstant primitive = constant.constant; | 643 PrimitiveConstant primitive = constant.constant; |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 // this type for the field is still a strong signal | 1339 // this type for the field is still a strong signal |
1331 // indicating the expected type of the field. | 1340 // indicating the expected type of the field. |
1332 types[field] = type; | 1341 types[field] = type; |
1333 } else { | 1342 } else { |
1334 // If there are no invoked setters we know the type of | 1343 // If there are no invoked setters we know the type of |
1335 // this field for sure. | 1344 // this field for sure. |
1336 field.guaranteedType = type; | 1345 field.guaranteedType = type; |
1337 } | 1346 } |
1338 } | 1347 } |
1339 } | 1348 } |
OLD | NEW |