| 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 correctness of side effects tracking used by load to load forwarding. | 4 // Test correctness of side effects tracking used by load to load forwarding. |
| 5 | 5 |
| 6 // VMOptions=--optimization-counter-threshold=10 | 6 // VMOptions=--optimization-counter-threshold=10 |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import "dart:typed_data"; | 9 import "dart:typed_data"; |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 a = c; | 162 a = c; |
| 163 b = xa; | 163 b = xa; |
| 164 c = xb; | 164 c = xb; |
| 165 } | 165 } |
| 166 | 166 |
| 167 Expect.listEquals([-0.1, 0.1, 0.0, | 167 Expect.listEquals([-0.1, 0.1, 0.0, |
| 168 0.0, -0.1, 0.1, | 168 0.0, -0.1, 0.1, |
| 169 0.1, 0.0, -0.1], result); | 169 0.1, 0.0, -0.1], result); |
| 170 } | 170 } |
| 171 | 171 |
| 172 |
| 173 class C { |
| 174 C(this.box, this.parent); |
| 175 final box; |
| 176 final C parent; |
| 177 } |
| 178 |
| 179 testPhiForwarding5(C c) { |
| 180 var s = 0; |
| 181 var tmp = c; |
| 182 var a = c.parent; |
| 183 if (a.box + tmp.box != 1) throw "failed"; |
| 184 do { |
| 185 s += tmp.box + a.box; |
| 186 tmp = a; |
| 187 a = a.parent; |
| 188 } while (a != null); |
| 189 return s; |
| 190 } |
| 191 |
| 192 |
| 172 class U { | 193 class U { |
| 173 var x, y; | 194 var x, y; |
| 174 U() : x = 0, y = 0; | 195 U() : x = 0, y = 0; |
| 175 } | 196 } |
| 176 | 197 |
| 177 testEqualPhisElimination() { | 198 testEqualPhisElimination() { |
| 178 var u = new U(); | 199 var u = new U(); |
| 179 var v = new U(); | 200 var v = new U(); |
| 180 var sum = 0; | 201 var sum = 0; |
| 181 for (var i = 0; i < 3; i++) { | 202 for (var i = 0; i < 3; i++) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 testImmutableVMFields(fixed, true); | 274 testImmutableVMFields(fixed, true); |
| 254 testImmutableVMFields(growable, false); | 275 testImmutableVMFields(growable, false); |
| 255 testImmutableVMFields(growable, false); | 276 testImmutableVMFields(growable, false); |
| 256 | 277 |
| 257 final f64List = new Float64List(2); | 278 final f64List = new Float64List(2); |
| 258 testPhiRepresentation(true, f64List); | 279 testPhiRepresentation(true, f64List); |
| 259 testPhiRepresentation(false, f64List); | 280 testPhiRepresentation(false, f64List); |
| 260 | 281 |
| 261 final obj = new X(new X(new X(null))); | 282 final obj = new X(new X(new X(null))); |
| 262 | 283 |
| 284 final cs = new C(0, new C(1, new C(2, null))); |
| 285 |
| 263 for (var i = 0; i < 20; i++) { | 286 for (var i = 0; i < 20; i++) { |
| 264 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); | 287 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); |
| 265 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); | 288 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); |
| 266 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); | 289 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); |
| 267 testImmutableVMFields(fixed, true); | 290 testImmutableVMFields(fixed, true); |
| 268 testPhiRepresentation(true, f64List); | 291 testPhiRepresentation(true, f64List); |
| 269 testPhiForwarding(obj); | 292 testPhiForwarding(obj); |
| 270 testPhiForwarding2(obj); | 293 testPhiForwarding2(obj); |
| 271 testPhiForwarding3(); | 294 testPhiForwarding3(); |
| 272 testPhiForwarding4(); | 295 testPhiForwarding4(); |
| 296 Expect.equals(4, testPhiForwarding5(cs)); |
| 273 testEqualPhisElimination(); | 297 testEqualPhisElimination(); |
| 274 } | 298 } |
| 275 | 299 |
| 276 Expect.equals(1, testImmutableVMFields([], false)); | 300 Expect.equals(1, testImmutableVMFields([], false)); |
| 277 Expect.equals(2, testImmutableVMFields([1], false)); | 301 Expect.equals(2, testImmutableVMFields([1], false)); |
| 278 Expect.equals(2, testImmutableVMFields([1, 2], false)); | 302 Expect.equals(2, testImmutableVMFields([1, 2], false)); |
| 279 Expect.equals(3, testImmutableVMFields([1, 2, 3], false)); | 303 Expect.equals(3, testImmutableVMFields([1, 2, 3], false)); |
| 280 | 304 |
| 281 final u32List = new Uint32List(3); | 305 final u32List = new Uint32List(3); |
| 282 u32List[0] = 0; | 306 u32List[0] = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 302 for (var i = 0; i < 20; i++) { | 326 for (var i = 0; i < 20; i++) { |
| 303 Expect.equals(3, testIndexedNoAlias(array)); | 327 Expect.equals(3, testIndexedNoAlias(array)); |
| 304 } | 328 } |
| 305 for (var i = 0; i < 20; i++) { | 329 for (var i = 0; i < 20; i++) { |
| 306 Expect.equals(5, testIndexedAliasedStore1(array, array)); | 330 Expect.equals(5, testIndexedAliasedStore1(array, array)); |
| 307 } | 331 } |
| 308 for (var i = 0; i < 20; i++) { | 332 for (var i = 0; i < 20; i++) { |
| 309 Expect.equals(4, testIndexedAliasedStore2(array, array, indices[1])); | 333 Expect.equals(4, testIndexedAliasedStore2(array, array, indices[1])); |
| 310 } | 334 } |
| 311 } | 335 } |
| OLD | NEW |