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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10968060: Add a value range analysis phase to remove bounds checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/codegen.dart
===================================================================
--- lib/compiler/implementation/ssa/codegen.dart (revision 12781)
+++ lib/compiler/implementation/ssa/codegen.dart (working copy)
@@ -1915,6 +1915,12 @@
}
}
+ visitRangeConversion(HRangeConversion node) {
+ // Range conversion instructions are removed by the value range
+ // analyzer.
+ assert(false);
+ }
+
visitBoundsCheck(HBoundsCheck node) {
// TODO(ngeoffray): Separate the two checks of the bounds check, so,
// e.g., the zero checks can be shared if possible.
@@ -1923,18 +1929,24 @@
// completely.
assert(node.staticChecks != HBoundsCheck.ALWAYS_TRUE);
if (node.staticChecks != HBoundsCheck.ALWAYS_FALSE) {
- js.Binary under;
+ js.Expression under;
+ js.Expression over;
if (node.staticChecks != HBoundsCheck.ALWAYS_ABOVE_ZERO) {
- assert(node.staticChecks == HBoundsCheck.FULL_CHECK);
use(node.index);
under = new js.Binary("<", pop(), new js.LiteralNumber("0"));
}
- use(node.index);
- js.Expression index = pop();
- use(node.length);
- js.Binary over = new js.Binary(">=", index, pop());
- js.Binary underOver =
- under == null ? over : new js.Binary("||", under, over);
+ if (node.staticChecks != HBoundsCheck.ALWAYS_BELOW_LENGTH) {
+ var index = node.index;
+ use(index);
+ js.Expression jsIndex = pop();
+ use(node.length);
+ over = new js.Binary(">=", jsIndex, pop());
+ }
Søren Gjesse 2012/09/26 14:00:15 Maybe assert that not both under and over are null
ngeoffray 2012/09/27 13:22:02 Done.
+ js.Expression underOver = under == null
+ ? over
+ : over == null
+ ? under
+ : new js.Binary("||", under, over);
js.Statement thenBody = new js.Block.empty();
js.Block oldContainer = currentContainer;
currentContainer = thenBody;

Powered by Google App Engine
This is Rietveld 408576698