Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: pkg/compiler/lib/src/ssa/value_range_analyzer.dart

Issue 936483004: Make value range analysis tolerate erroneous length expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added test Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of ssa; 5 part of ssa;
6 6
7 7
8 class ValueRangeInfo { 8 class ValueRangeInfo {
9 final ConstantSystem constantSystem; 9 final ConstantSystem constantSystem;
10 10
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 704
705 Range visitBoundsCheck(HBoundsCheck check) { 705 Range visitBoundsCheck(HBoundsCheck check) {
706 // Save the next instruction, in case the check gets removed. 706 // Save the next instruction, in case the check gets removed.
707 HInstruction next = check.next; 707 HInstruction next = check.next;
708 Range indexRange = ranges[check.index]; 708 Range indexRange = ranges[check.index];
709 Range lengthRange = ranges[check.length]; 709 Range lengthRange = ranges[check.length];
710 if (indexRange == null) { 710 if (indexRange == null) {
711 indexRange = info.newUnboundRange(); 711 indexRange = info.newUnboundRange();
712 assert(!check.index.isInteger(compiler)); 712 assert(!check.index.isInteger(compiler));
713 } 713 }
714 if (lengthRange == null) {
715 // We might have lost the length range due to a type conversion that
716 // asserts a non-integer type. In such a case, the program will never
717 // get to this point anyway, so no need to try and refine ranges.
718 return indexRange;
719 }
714 assert(check.length.isInteger(compiler)); 720 assert(check.length.isInteger(compiler));
715 721
716 // Check if the index is strictly below the upper bound of the length 722 // Check if the index is strictly below the upper bound of the length
717 // range. 723 // range.
718 Value maxIndex = lengthRange.upper - info.intOne; 724 Value maxIndex = lengthRange.upper - info.intOne;
719 bool belowLength = maxIndex != const MaxIntValue() 725 bool belowLength = maxIndex != const MaxIntValue()
720 && indexRange.upper.min(maxIndex) == indexRange.upper; 726 && indexRange.upper.min(maxIndex) == indexRange.upper;
721 727
722 // Check if the index is strictly below the lower bound of the length 728 // Check if the index is strictly below the lower bound of the length
723 // range. 729 // range.
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 } 1075 }
1070 1076
1071 Range handleBinaryOperation(HBinaryArithmetic instruction) { 1077 Range handleBinaryOperation(HBinaryArithmetic instruction) {
1072 Range leftRange = visit(instruction.left); 1078 Range leftRange = visit(instruction.left);
1073 Range rightRange = visit(instruction.right); 1079 Range rightRange = visit(instruction.right);
1074 if (leftRange == null || rightRange == null) return null; 1080 if (leftRange == null || rightRange == null) return null;
1075 BinaryOperation operation = instruction.operation(info.constantSystem); 1081 BinaryOperation operation = instruction.operation(info.constantSystem);
1076 return operation.apply(leftRange, rightRange); 1082 return operation.apply(leftRange, rightRange);
1077 } 1083 }
1078 } 1084 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/21166_test.dart » ('j') | tests/compiler/dart2js_extra/21166_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698