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

Unified Diff: tests/language/issue11793_test.dart

Issue 19347002: Fix crash https://code.google.com/p/dart/issues/detail?id=11793: only compute a range for a loop if… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/issue11793_test.dart
===================================================================
--- tests/language/issue11793_test.dart (revision 0)
+++ tests/language/issue11793_test.dart (revision 0)
@@ -0,0 +1,47 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js, whose value range analysis phase
+// assumed loop phis that were integer necessarily had integer inputs.
+
+var array = const [0, 0.5];
+var globalB = array[0];
+var otherArray = [5];
+
+main() {
+ var b = globalB;
+ var a = b + 1;
+ if (otherArray[0] == 0) {
+ // Use a non-existing selector to prevent adding a bailout check.
+ a.noSuch();
+ a = otherArray[0];
+ }
+
+ // Use [a] to make sure it does not become dead code.
+ var f = array[a];
+
+ // Add an integer check on [b].
+ var d = array[b];
+
+ // This instruction will be GVN to the same value as [a].
+ // By being GVN'ed, [e] will have its type changed from integer
+ // to number: because of the int type check on [b], we know
+ // [: b + 1 :] returns an integer.
+ // However we update this instruction with the previous [: b + 1 :]
+ // that did not have that information and therefore only knows that
+ // the instruction returns a number.
+ var e = b + 1;
+
+ // Introduce a loop phi that has [e] as header input, and [e++] as
+ // update input. By having [e] as input, dart2js will compute an
+ // integer type for the phi. However, after GVN, [e] becomes a
+ // number.
+
+ while (otherArray[0] == 0) {
+ // Use [e] as an index for an array so that the value range
+ // analysis tries to compute a range for [e].
+ otherArray[e] = d + f;
+ e++;
+ }
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698