| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 | 486 |
| 487 @override | 487 @override |
| 488 void visitGetLength(GetLength node) { | 488 void visitGetLength(GetLength node) { |
| 489 valueOf[node] = getLength(node.object.definition, currentEffectNumber); | 489 valueOf[node] = getLength(node.object.definition, currentEffectNumber); |
| 490 } | 490 } |
| 491 | 491 |
| 492 @override | 492 @override |
| 493 void visitBoundsCheck(BoundsCheck node) { | 493 void visitBoundsCheck(BoundsCheck node) { |
| 494 if (node.checks == BoundsCheck.NONE) return; | 494 if (node.checks == BoundsCheck.NONE) return; |
| 495 assert(node.index != null); // Because there is at least one check. | 495 assert(node.index != null); // Because there is at least one check. |
| 496 Primitive object = node.object.definition; | |
| 497 SignedVariable length = node.length == null | 496 SignedVariable length = node.length == null |
| 498 ? null | 497 ? null |
| 499 : getValue(node.length.definition); | 498 : getValue(node.length.definition); |
| 500 SignedVariable index = getValue(node.index.definition); | 499 SignedVariable index = getValue(node.index.definition); |
| 501 if (node.hasUpperBoundCheck) { | 500 if (node.hasUpperBoundCheck) { |
| 502 if (isDefinitelyLessThan(index, length)) { | 501 if (isDefinitelyLessThan(index, length)) { |
| 503 node.checks &= ~BoundsCheck.UPPER_BOUND; | 502 node.checks &= ~BoundsCheck.UPPER_BOUND; |
| 504 } else { | 503 } else { |
| 505 makeLessThan(index, length); | 504 makeLessThan(index, length); |
| 506 } | 505 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 731 } |
| 733 return node.body; | 732 return node.body; |
| 734 } | 733 } |
| 735 } | 734 } |
| 736 | 735 |
| 737 /// Lattice representing the known (weak) monotonicity of a loop variable. | 736 /// Lattice representing the known (weak) monotonicity of a loop variable. |
| 738 /// | 737 /// |
| 739 /// The lattice bottom is represented by `null` and represents the case where | 738 /// The lattice bottom is represented by `null` and represents the case where |
| 740 /// the loop variable never changes value during the loop. | 739 /// the loop variable never changes value during the loop. |
| 741 enum Monotonicity { NotMonotone, Increasing, Decreasing, } | 740 enum Monotonicity { NotMonotone, Increasing, Decreasing, } |
| OLD | NEW |