OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 // VMOptions=--optimization-counter-threshold=1000 --max-polymorphic-checks=1 |
| 5 |
| 6 // Test correct loop invariant code motion and type propagation from is-checks |
| 7 // and null-comparisons. |
| 8 |
| 9 class B { |
| 10 var b; |
| 11 B(this.b); |
| 12 } |
| 13 |
| 14 class C { |
| 15 final f0; |
| 16 |
| 17 final a; |
| 18 C() : a = new B(0); |
| 19 } |
| 20 |
| 21 foo(x) { |
| 22 for (var i = 0; i < 10; i++) { |
| 23 i + i; |
| 24 i + i; |
| 25 if (x is C) { |
| 26 x.a.b < 0; |
| 27 } |
| 28 } |
| 29 } |
| 30 |
| 31 class Y { var f = null; } |
| 32 |
| 33 bar(y) { |
| 34 var x = y.f; |
| 35 for (var i = 0; i < 10; i++) { |
| 36 if (x != null) { |
| 37 x.a.b < 0; |
| 38 } |
| 39 } |
| 40 } |
| 41 |
| 42 |
| 43 main () { |
| 44 var o = new Y(); |
| 45 o.f = new C(); |
| 46 bar(o); |
| 47 o.f = null; |
| 48 bar(o); |
| 49 |
| 50 for (var i = 0; i < 1000; i++) bar(o); |
| 51 |
| 52 foo(new C()); |
| 53 foo(0); |
| 54 |
| 55 for (var i = 0; i < 1000; i++) foo(0); |
| 56 } |
OLD | NEW |