Chromium Code Reviews| 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 } | |
| 15 Expect.equals(2000, a.f); | |
| 16 Expect.equals(2000, aa.f); | |
| 17 a.f = 1.0; | |
| 18 // Deoptimize ++ part of instance increment. | |
| 19 a.Incr(); | |
| 20 Expect.equals(2.0, a.f); | |
| 21 var b = new B(); | |
| 22 // Deoptimize getfield part of instance increment. | |
| 23 myIncr(b); | |
| 24 Expect.equals(1.0, b.f); | |
|
regis
2011/11/02 02:06:37
Do you use a double for a particular reason? b.f h
srdjan
2011/11/02 15:10:55
Good catch, this would fail in type checked mode.
| |
| 25 } | |
| 26 | |
| 27 myIncr(var a) { | |
| 28 a.f++; | |
| 29 } | |
| 30 | |
| 31 class A { | |
| 32 A() : f = 0; | |
| 33 Incr() { | |
| 34 f++; | |
| 35 } | |
| 36 int f; | |
| 37 } | |
| 38 | |
| 39 class B { | |
| 40 B() : f = 0; | |
| 41 int f; | |
| 42 } | |
| 43 | |
| OLD | NEW |