| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, 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 | |
| 5 // Check correct deoptimization of instance field increment. | |
| 6 | |
| 7 | |
| 8 main() { | |
| 9 var a = new A(); | |
| 10 var aa = new A(); | |
| 11 for (int i = 0; i < 2000; i++) { | |
| 12 a.Incr(); | |
| 13 myIncr(aa); | |
| 14 conditionalIncr(false, a); | |
| 15 } | |
| 16 Expect.equals(2000, a.f); | |
| 17 Expect.equals(2000, aa.f); | |
| 18 a.f = 1.0; | |
| 19 // Deoptimize ++ part of instance increment. | |
| 20 a.Incr(); | |
| 21 Expect.equals(2.0, a.f); | |
| 22 var b = new B(); | |
| 23 // Deoptimize getfield part of instance increment. | |
| 24 myIncr(b); | |
| 25 Expect.equals(1.0, b.f); | |
| 26 // Deoptimize since no type feedback was collected. | |
| 27 var old = a.f; | |
| 28 conditionalIncr(true, a); | |
| 29 Expect.equals(old + 1, a.f); | |
| 30 } | |
| 31 | |
| 32 myIncr(var a) { | |
| 33 a.f++; | |
| 34 } | |
| 35 | |
| 36 conditionalIncr(var f, var a) { | |
| 37 if (f) { | |
| 38 a.f++; | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 class A { | |
| 43 A() : f = 0; | |
| 44 Incr() { | |
| 45 f++; | |
| 46 } | |
| 47 var f; | |
| 48 } | |
| 49 | |
| 50 class B { | |
| 51 B() : f = 0; | |
| 52 var f; | |
| 53 } | |
| 54 | |
| OLD | NEW |