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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart

Issue 91103003: Use the integer type to get rid of above 0 checks in bounds checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/value_range2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart (revision 30699)
+++ sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart (working copy)
@@ -24,8 +24,8 @@
return new InstructionValue(instruction, this);
}
- Value newLengthValue(HInstruction instruction) {
- return new LengthValue(instruction, this);
+ Value newPositiveValue(HInstruction instruction) {
+ return new PositiveValue(instruction, this);
}
Value newAddValue(Value left, Value right) {
@@ -291,14 +291,11 @@
}
/**
- * Special value for instructions that represent the length of an
- * array. The difference with an [InstructionValue] is that we know
- * the value is positive.
+ * Special value for instructions whose type is a positive integer.
*/
-class LengthValue extends InstructionValue {
- LengthValue(HInstruction instruction, info) : super(instruction, info);
+class PositiveValue extends InstructionValue {
sra1 2013/11/27 20:29:36 Zero is possible, but is not positive. Perhaps lea
+ PositiveValue(HInstruction instruction, info) : super(instruction, info);
bool get isPositive => true;
- String toString() => 'Length: $instruction';
}
/**
@@ -637,15 +634,17 @@
}
Range visitInstruction(HInstruction instruction) {
- return info.newUnboundRange();
+ if (instruction.isUInt32(compiler)) {
+ return info.newNormalizedRange(
+ info.intZero, info.newPositiveValue(instruction));
+ } else if (instruction.isInteger(compiler)) {
+ InstructionValue value = info.newInstructionValue(instruction);
+ return info.newNormalizedRange(value, value);
+ } else {
+ return info.newUnboundRange();
+ }
}
- Range visitParameterValue(HParameterValue parameter) {
- if (!parameter.isInteger(compiler)) return info.newUnboundRange();
- Value value = info.newInstructionValue(parameter);
- return info.newNormalizedRange(value, value);
- }
-
Range visitPhi(HPhi phi) {
if (!phi.isInteger(compiler)) return info.newUnboundRange();
// Some phases may replace instructions that change the inputs of
@@ -682,7 +681,7 @@
}
JavaScriptBackend backend = compiler.backend;
assert(fieldGet.element == backend.jsIndexableLength);
- LengthValue value = info.newLengthValue(fieldGet);
+ PositiveValue value = info.newPositiveValue(fieldGet);
// We know this range is above zero. To simplify the analysis, we
// put the zero value as the lower bound of this range. This
// allows to easily remove the second bound check in the following
« no previous file with comments | « no previous file | tests/compiler/dart2js/value_range2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698