OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Test megamorphic, but single target field load. | 4 // Test megamorphic, but single target field load. |
5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation | 5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 class Base { | 9 class Base { |
10 var f; | 10 var f; |
11 } | 11 } |
12 | 12 |
13 class A extends Base { | 13 class A extends Base { |
14 A() { this.f = 0; } | 14 A() { |
| 15 this.f = 0; |
| 16 } |
15 } | 17 } |
16 | 18 |
17 class B extends Base { | 19 class B extends Base { |
18 B() { this.f = 1; } | 20 B() { |
| 21 this.f = 1; |
| 22 } |
19 } | 23 } |
20 | 24 |
21 class C extends Base { | 25 class C extends Base { |
22 C() { this.f = 2; } | 26 C() { |
| 27 this.f = 2; |
| 28 } |
23 } | 29 } |
24 | 30 |
25 class D extends Base { | 31 class D extends Base { |
26 D() { this.f = 3; } | 32 D() { |
| 33 this.f = 3; |
| 34 } |
27 } | 35 } |
28 | 36 |
29 class E extends Base { | 37 class E extends Base { |
30 E() { this.f = 4; } | 38 E() { |
| 39 this.f = 4; |
| 40 } |
31 } | 41 } |
32 | 42 |
33 class F extends Base { | 43 class F extends Base { |
34 F() { this.f = 5; } | 44 F() { |
| 45 this.f = 5; |
| 46 } |
35 } | 47 } |
36 | 48 |
37 class G extends Base { | 49 class G extends Base { |
38 G() { this.f = 6; } | 50 G() { |
| 51 this.f = 6; |
| 52 } |
39 } | 53 } |
40 | 54 |
41 class H extends Base { | 55 class H extends Base { |
42 H() { this.f = 7; } | 56 H() { |
| 57 this.f = 7; |
| 58 } |
43 } | 59 } |
44 | 60 |
45 class I extends Base { | 61 class I extends Base { |
46 I() { this.f = 8; } | 62 I() { |
| 63 this.f = 8; |
| 64 } |
47 } | 65 } |
48 | 66 |
49 class J extends Base { | 67 class J extends Base { |
50 J() { this.f = 9; } | 68 J() { |
| 69 this.f = 9; |
| 70 } |
51 } | 71 } |
52 | 72 |
53 class K extends Base { | 73 class K extends Base { |
54 K() { this.f = 10; } | 74 K() { |
| 75 this.f = 10; |
| 76 } |
55 } | 77 } |
56 | 78 |
57 class L extends Base { | 79 class L extends Base { |
58 L() { this.f = 11; } | 80 L() { |
| 81 this.f = 11; |
| 82 } |
59 } | 83 } |
60 | 84 |
61 class M extends Base { | 85 class M extends Base { |
62 M() { this.f = 12; } | 86 M() { |
| 87 this.f = 12; |
| 88 } |
63 } | 89 } |
64 | 90 |
65 class N extends Base { | 91 class N extends Base { |
66 N() { this.f = 13; } | 92 N() { |
| 93 this.f = 13; |
| 94 } |
67 } | 95 } |
68 | 96 |
69 class O extends Base { | 97 class O extends Base { |
70 O() { this.f = 14; } | 98 O() { |
| 99 this.f = 14; |
| 100 } |
71 } | 101 } |
72 | 102 |
73 class P extends Base { | 103 class P extends Base { |
74 P() { this.f = 15; } | 104 P() { |
| 105 this.f = 15; |
| 106 } |
75 } | 107 } |
76 | 108 |
77 class Q extends Base { | 109 class Q extends Base { |
78 Q() { this.f = 16; } | 110 Q() { |
| 111 this.f = 16; |
| 112 } |
79 } | 113 } |
80 | 114 |
81 class R extends Base { | 115 class R extends Base { |
82 R() { this.f = 17; } | 116 R() { |
| 117 this.f = 17; |
| 118 } |
83 } | 119 } |
84 | 120 |
85 class S extends Base { | 121 class S extends Base { |
86 S() { this.f = 18; } | 122 S() { |
| 123 this.f = 18; |
| 124 } |
87 } | 125 } |
88 | 126 |
89 class T extends Base { | 127 class T extends Base { |
90 T() { this.f = 19; } | 128 T() { |
| 129 this.f = 19; |
| 130 } |
91 } | 131 } |
92 | 132 |
93 class U extends Base { | 133 class U extends Base { |
94 U() { this.f = 20; } | 134 U() { |
| 135 this.f = 20; |
| 136 } |
95 } | 137 } |
96 | 138 |
97 class V extends Base { | 139 class V extends Base { |
98 V() { this.f = 21; } | 140 V() { |
| 141 this.f = 21; |
| 142 } |
99 } | 143 } |
100 | 144 |
101 class W extends Base { | 145 class W extends Base { |
102 V() { this.f = 22; } | 146 V() { |
| 147 this.f = 22; |
| 148 } |
103 } | 149 } |
104 | 150 |
105 class X extends Base { | 151 class X extends Base { |
106 V() { this.f = 21; } | 152 V() { |
| 153 this.f = 21; |
| 154 } |
107 } | 155 } |
108 | 156 |
109 class Y extends Base { | 157 class Y extends Base { |
110 V() { this.f = 24; } | 158 V() { |
| 159 this.f = 24; |
| 160 } |
111 } | 161 } |
112 | 162 |
113 class Z extends Base { | 163 class Z extends Base { |
114 V() { this.f = 21; } | 164 V() { |
| 165 this.f = 21; |
| 166 } |
115 } | 167 } |
116 | 168 |
117 allocateObjects() { | 169 allocateObjects() { |
118 var list = new List(); | 170 var list = new List(); |
119 list.add(new A()); | 171 list.add(new A()); |
120 list.add(new B()); | 172 list.add(new B()); |
121 list.add(new C()); | 173 list.add(new C()); |
122 list.add(new D()); | 174 list.add(new D()); |
123 list.add(new E()); | 175 list.add(new E()); |
124 list.add(new F()); | 176 list.add(new F()); |
(...skipping 22 matching lines...) Expand all Loading... |
147 } | 199 } |
148 } | 200 } |
149 | 201 |
150 main() { | 202 main() { |
151 var list = allocateObjects(); | 203 var list = allocateObjects(); |
152 // Make sure the optimizer triggers the compilation of callThemAll. | 204 // Make sure the optimizer triggers the compilation of callThemAll. |
153 for (var i = 0; i < 20; i++) { | 205 for (var i = 0; i < 20; i++) { |
154 callThemAll(list); | 206 callThemAll(list); |
155 } | 207 } |
156 } | 208 } |
OLD | NEW |