| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 global_array[0].x++; | 464 global_array[0].x++; |
| 465 } | 465 } |
| 466 | 466 |
| 467 testAliasingStoreIndexed(array) { | 467 testAliasingStoreIndexed(array) { |
| 468 var z = new Z(); | 468 var z = new Z(); |
| 469 array[0] = z; | 469 array[0] = z; |
| 470 side_effect(); | 470 side_effect(); |
| 471 return z.x; | 471 return z.x; |
| 472 } | 472 } |
| 473 | 473 |
| 474 class ZZ { |
| 475 var f; |
| 476 } |
| 477 |
| 478 var zz, f0 = 42; |
| 479 |
| 480 testAliasesRefinement() { |
| 481 zz = new ZZ(); |
| 482 var b = zz; |
| 483 if (b.f == null) { |
| 484 b.f = f0; |
| 485 } |
| 486 return b.f; |
| 487 } |
| 488 |
| 474 main() { | 489 main() { |
| 475 final fixed = new List(10); | 490 final fixed = new List(10); |
| 476 final growable = []; | 491 final growable = []; |
| 477 testImmutableVMFields(fixed, true); | 492 testImmutableVMFields(fixed, true); |
| 478 testImmutableVMFields(growable, false); | 493 testImmutableVMFields(growable, false); |
| 479 testImmutableVMFields(growable, false); | 494 testImmutableVMFields(growable, false); |
| 480 | 495 |
| 481 final f64List = new Float64List(2); | 496 final f64List = new Float64List(2); |
| 482 testPhiRepresentation(true, f64List); | 497 testPhiRepresentation(true, f64List); |
| 483 testPhiRepresentation(false, f64List); | 498 testPhiRepresentation(false, f64List); |
| 484 | 499 |
| 485 final obj = new X(new X(new X(null))); | 500 final obj = new X(new X(new X(null))); |
| 486 | 501 |
| 487 final cs = new C(0, new C(1, new C(2, null))); | 502 final cs = new C(0, new C(1, new C(2, null))); |
| 488 | 503 |
| 489 for (var i = 0; i < 20; i++) { | 504 for (var i = 0; i < 20; i++) { |
| 490 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); | 505 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); |
| 491 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); | 506 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); |
| 492 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); | 507 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); |
| 493 testImmutableVMFields(fixed, true); | 508 testImmutableVMFields(fixed, true); |
| 494 testPhiRepresentation(true, f64List); | 509 testPhiRepresentation(true, f64List); |
| 495 testPhiForwarding(obj); | 510 testPhiForwarding(obj); |
| 496 testPhiForwarding2(obj); | 511 testPhiForwarding2(obj); |
| 497 testPhiForwarding3(); | 512 testPhiForwarding3(); |
| 498 testPhiForwarding4(); | 513 testPhiForwarding4(); |
| 499 Expect.equals(4, testPhiForwarding5(cs)); | 514 Expect.equals(4, testPhiForwarding5(cs)); |
| 500 testEqualPhisElimination(); | 515 testEqualPhisElimination(); |
| 516 Expect.equals(f0, testAliasesRefinement()); |
| 501 } | 517 } |
| 502 | 518 |
| 503 Expect.equals(1, testImmutableVMFields([], false)); | 519 Expect.equals(1, testImmutableVMFields([], false)); |
| 504 Expect.equals(2, testImmutableVMFields([1], false)); | 520 Expect.equals(2, testImmutableVMFields([1], false)); |
| 505 Expect.equals(2, testImmutableVMFields([1, 2], false)); | 521 Expect.equals(2, testImmutableVMFields([1, 2], false)); |
| 506 Expect.equals(3, testImmutableVMFields([1, 2, 3], false)); | 522 Expect.equals(3, testImmutableVMFields([1, 2, 3], false)); |
| 507 | 523 |
| 508 final u32List = new Uint32List(3); | 524 final u32List = new Uint32List(3); |
| 509 u32List[0] = 0; | 525 u32List[0] = 0; |
| 510 u32List[1] = 0x3FFFFFFF; | 526 u32List[1] = 0x3FFFFFFF; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 530 Expect.equals(3, testIndexedNoAlias(array)); | 546 Expect.equals(3, testIndexedNoAlias(array)); |
| 531 } | 547 } |
| 532 | 548 |
| 533 testIndexedAliasedStores(); | 549 testIndexedAliasedStores(); |
| 534 | 550 |
| 535 var test_array = new List(1); | 551 var test_array = new List(1); |
| 536 for (var i = 0; i < 20; i++) { | 552 for (var i = 0; i < 20; i++) { |
| 537 Expect.equals(43, testAliasingStoreIndexed(global_array)); | 553 Expect.equals(43, testAliasingStoreIndexed(global_array)); |
| 538 } | 554 } |
| 539 } | 555 } |
| OLD | NEW |