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

Unified Diff: tests/language/vm/type_propagation_test.dart

Issue 1491373005: VM: Fix bug in type propagation at conditionals. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « runtime/vm/flow_graph_type_propagator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/vm/type_propagation_test.dart
diff --git a/tests/language/vm/type_propagation_test.dart b/tests/language/vm/type_propagation_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..935c0964880d8a205c78a1d58755bb408f4d4cee
--- /dev/null
+++ b/tests/language/vm/type_propagation_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2015, 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.
+// VMOptions=--optimization-counter-threshold=1000 --max-polymorphic-checks=1
+
+// Test correct loop invariant code motion and type propagation from is-checks
+// and null-comparisons.
+
+class B {
+ var b;
+ B(this.b);
+}
+
+class C {
+ final f0;
+
+ final a;
+ C() : a = new B(0);
+}
+
+foo(x) {
+ for (var i = 0; i < 10; i++) {
+ i + i;
+ i + i;
+ if (x is C) {
+ x.a.b < 0;
+ }
+ }
+}
+
+class Y { var f = null; }
+
+bar(y) {
+ var x = y.f;
+ for (var i = 0; i < 10; i++) {
+ if (x != null) {
+ x.a.b < 0;
+ }
+ }
+}
+
+
+main () {
+ var o = new Y();
+ o.f = new C();
+ bar(o);
+ o.f = null;
+ bar(o);
+
+ for (var i = 0; i < 1000; i++) bar(o);
+
+ foo(new C());
+ foo(0);
+
+ for (var i = 0; i < 1000; i++) foo(0);
+}
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698