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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 | 278 |
279 testIndexedAliasedStore4(b) { | 279 testIndexedAliasedStore4(b) { |
280 var a = new List(2); | 280 var a = new List(2); |
281 a[0] = 1; | 281 a[0] = 1; |
282 b[0] = 3; | 282 b[0] = 3; |
283 return a[0]; | 283 return a[0]; |
284 } | 284 } |
285 | 285 |
286 | 286 |
| 287 testIndexedAliasedStore5(b) { |
| 288 var a = new List(2), |
| 289 c = new List(2); |
| 290 a[0] = 1; |
| 291 b[0] = 3; |
| 292 c[0] = 4; |
| 293 b[0] = 5; |
| 294 return a[0] << 8 | c[0]; |
| 295 } |
| 296 |
| 297 |
| 298 testIndexedAliasedStore6(x, b) { |
| 299 var a = new List(2), |
| 300 c = new List(2); |
| 301 b = x ? b : c; |
| 302 a[0] = 1; |
| 303 b[0] = 3; |
| 304 c[0] = 4; |
| 305 b[0] = 5; |
| 306 return a[0] << 8 | c[0]; |
| 307 } |
| 308 |
| 309 testIndexedAliasedStore7(x, b, i) { |
| 310 var a = new List(2), |
| 311 c = new List(2); |
| 312 b = x ? b : c; |
| 313 a[0] = 1; |
| 314 b[0] = 3; |
| 315 c[0] = 4; |
| 316 b[i] = 5; |
| 317 return a[0] << 8 | c[0]; |
| 318 } |
| 319 |
| 320 |
| 321 testIndexedAliasedStore8(x, b, i) { |
| 322 var a = new List(2), |
| 323 c = new List(2); |
| 324 b = x ? b : c; |
| 325 a[i] = 1; |
| 326 b[0] = 3; |
| 327 c[i] = 4; |
| 328 b[0] = 5; |
| 329 return a[i] << 8 | c[i]; |
| 330 } |
| 331 |
| 332 |
| 333 testIndexedAliasedStore9(b, i) { |
| 334 var a = new List(2), |
| 335 c = new List(2); |
| 336 a[i] = 1; |
| 337 b[0] = 3; |
| 338 c[i] = 4; |
| 339 b[0] = 5; |
| 340 return a[i] << 8 | c[i]; |
| 341 } |
| 342 |
| 343 |
287 var indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 344 var indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
288 | 345 |
289 class Z { | 346 class Z { |
290 var x = 42; | 347 var x = 42; |
291 } | 348 } |
292 | 349 |
293 var global_array = new List<Z>(1); | 350 var global_array = new List<Z>(1); |
294 | 351 |
295 side_effect() { | 352 side_effect() { |
296 global_array[0].x++; | 353 global_array[0].x++; |
(...skipping 12 matching lines...) Expand all Loading... |
309 testImmutableVMFields(fixed, true); | 366 testImmutableVMFields(fixed, true); |
310 testImmutableVMFields(growable, false); | 367 testImmutableVMFields(growable, false); |
311 testImmutableVMFields(growable, false); | 368 testImmutableVMFields(growable, false); |
312 | 369 |
313 final f64List = new Float64List(2); | 370 final f64List = new Float64List(2); |
314 testPhiRepresentation(true, f64List); | 371 testPhiRepresentation(true, f64List); |
315 testPhiRepresentation(false, f64List); | 372 testPhiRepresentation(false, f64List); |
316 | 373 |
317 final obj = new X(new X(new X(null))); | 374 final obj = new X(new X(new X(null))); |
318 | 375 |
319 final cs = new C(0, new C(1, new C(2, null))); | 376 final cs = new C(0, new C(1, new C(2, null))); |
320 | 377 |
321 for (var i = 0; i < 20; i++) { | 378 for (var i = 0; i < 20; i++) { |
322 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); | 379 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); |
323 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); | 380 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); |
324 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); | 381 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); |
325 testImmutableVMFields(fixed, true); | 382 testImmutableVMFields(fixed, true); |
326 testPhiRepresentation(true, f64List); | 383 testPhiRepresentation(true, f64List); |
327 testPhiForwarding(obj); | 384 testPhiForwarding(obj); |
328 testPhiForwarding2(obj); | 385 testPhiForwarding2(obj); |
329 testPhiForwarding3(); | 386 testPhiForwarding3(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 Expect.equals(3, testIndexedAliasedStore3(indices[0])); | 428 Expect.equals(3, testIndexedAliasedStore3(indices[0])); |
372 } | 429 } |
373 for (var i = 0; i < 20; i++) { | 430 for (var i = 0; i < 20; i++) { |
374 Expect.equals(1, testIndexedAliasedStore3(indices[1])); | 431 Expect.equals(1, testIndexedAliasedStore3(indices[1])); |
375 } | 432 } |
376 | 433 |
377 for (var i = 0; i < 20; i++) { | 434 for (var i = 0; i < 20; i++) { |
378 Expect.equals(1, testIndexedAliasedStore4(array)); | 435 Expect.equals(1, testIndexedAliasedStore4(array)); |
379 } | 436 } |
380 | 437 |
| 438 for (var i = 0; i < 20; i++) { |
| 439 Expect.equals(1 << 8 | 4, testIndexedAliasedStore5(array)); |
| 440 } |
| 441 |
| 442 for (var i = 0; i < 20; i++) { |
| 443 Expect.equals(1 << 8 | 4, testIndexedAliasedStore6(true, array)); |
| 444 Expect.equals(1 << 8 | 5, testIndexedAliasedStore6(false, array)); |
| 445 } |
| 446 |
| 447 for (var i = 0; i < 20; i++) { |
| 448 Expect.equals(1 << 8 | 4, testIndexedAliasedStore7(true, array, 0)); |
| 449 Expect.equals(1 << 8 | 4, testIndexedAliasedStore7(true, array, 1)); |
| 450 Expect.equals(1 << 8 | 5, testIndexedAliasedStore7(false, array, 0)); |
| 451 Expect.equals(1 << 8 | 4, testIndexedAliasedStore7(false, array, 1)); |
| 452 } |
| 453 |
| 454 for (var i = 0; i < 20; i++) { |
| 455 Expect.equals(1 << 8 | 4, testIndexedAliasedStore8(true, array, 0)); |
| 456 Expect.equals(1 << 8 | 4, testIndexedAliasedStore8(true, array, 1)); |
| 457 Expect.equals(1 << 8 | 5, testIndexedAliasedStore8(false, array, 0)); |
| 458 Expect.equals(1 << 8 | 4, testIndexedAliasedStore8(false, array, 1)); |
| 459 } |
| 460 |
| 461 for (var i = 0; i < 20; i++) { |
| 462 Expect.equals(1 << 8 | 4, testIndexedAliasedStore9(array, 0)); |
| 463 Expect.equals(1 << 8 | 4, testIndexedAliasedStore9(array, 1)); |
| 464 } |
| 465 |
381 var test_array = new List(1); | 466 var test_array = new List(1); |
382 for (var i = 0; i < 20; i++) { | 467 for (var i = 0; i < 20; i++) { |
383 Expect.equals(43, testAliasingStoreIndexed(global_array)); | 468 Expect.equals(43, testAliasingStoreIndexed(global_array)); |
384 } | 469 } |
385 } | 470 } |
OLD | NEW |