| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.cps_ir.bounds_checker; | 5 library dart2js.cps_ir.bounds_checker; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import 'optimizers.dart' show Pass; | 8 import 'optimizers.dart' show Pass; |
| 9 import 'octagon.dart'; | 9 import 'octagon.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 effectNumberAt[cont] = NEW_EFFECT; | 607 effectNumberAt[cont] = NEW_EFFECT; |
| 608 } | 608 } |
| 609 // TODO(asgerf): Compute join for parameters to increase precision? | 609 // TODO(asgerf): Compute join for parameters to increase precision? |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 // ---------------- PRIMITIVES -------------------- | 613 // ---------------- PRIMITIVES -------------------- |
| 614 | 614 |
| 615 @override | 615 @override |
| 616 void visitInvokeMethod(InvokeMethod node) { | 616 void visitInvokeMethod(InvokeMethod node) { |
| 617 if (node.selector.isGetter && node.selector.name == 'length') { |
| 618 // If the receiver type is not known to be indexable, the length call |
| 619 // was not rewritten to GetLength. But if we can prove that the call only |
| 620 // succeeds for indexables, we can trust that it returns the length. |
| 621 TypeMask successType = |
| 622 types.receiverTypeFor(node.selector, node.dartReceiver.type); |
| 623 if (types.isDefinitelyIndexable(successType)) { |
| 624 valueOf[node] = getLength(node.dartReceiver, currentEffectNumber); |
| 625 } |
| 626 } |
| 617 // TODO(asgerf): What we really need is a "changes length" side effect flag. | 627 // TODO(asgerf): What we really need is a "changes length" side effect flag. |
| 618 if (world | 628 if (world |
| 619 .getSideEffectsOfSelector(node.selector, node.mask) | 629 .getSideEffectsOfSelector(node.selector, node.mask) |
| 620 .changesIndex()) { | 630 .changesIndex()) { |
| 621 currentEffectNumber = makeNewEffect(); | 631 currentEffectNumber = makeNewEffect(); |
| 622 } | 632 } |
| 623 } | 633 } |
| 624 | 634 |
| 625 @override | 635 @override |
| 626 void visitInvokeStatic(InvokeStatic node) { | 636 void visitInvokeStatic(InvokeStatic node) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 } | 741 } |
| 732 return node.body; | 742 return node.body; |
| 733 } | 743 } |
| 734 } | 744 } |
| 735 | 745 |
| 736 /// Lattice representing the known (weak) monotonicity of a loop variable. | 746 /// Lattice representing the known (weak) monotonicity of a loop variable. |
| 737 /// | 747 /// |
| 738 /// The lattice bottom is represented by `null` and represents the case where | 748 /// The lattice bottom is represented by `null` and represents the case where |
| 739 /// the loop variable never changes value during the loop. | 749 /// the loop variable never changes value during the loop. |
| 740 enum Monotonicity { NotMonotone, Increasing, Decreasing, } | 750 enum Monotonicity { NotMonotone, Increasing, Decreasing, } |
| OLD | NEW |