Chromium Code Reviews| Index: tests/language/vm/store_elimination_vm_test.dart |
| =================================================================== |
| --- tests/language/vm/store_elimination_vm_test.dart (revision 0) |
| +++ tests/language/vm/store_elimination_vm_test.dart (revision 0) |
| @@ -0,0 +1,54 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| +// Test correctness of side effects tracking used by load to load forwarding. |
| + |
| +// VMOptions=--optimization-counter-threshold=10 |
| + |
| +import "package:expect/expect.dart"; |
| + |
| +class C { |
|
Vyacheslav Egorov (Google)
2014/05/08 12:53:20
Might be good to have this test cover other types
Florian Schneider
2014/05/08 14:21:43
Done.
|
| + var x; |
| + var y; |
| + final z = 123; |
| +} |
| + |
| +s1(a) { |
| + a.x = 42; |
| + a.x = 43; |
| + return a.x; |
| +} |
| + |
| +void foo(a) { |
| + Expect.equals(42, a.x); |
| +} |
| + |
| +s1a(a) { |
| + a.x = 42; |
| + foo(a); |
| + a.x = 43; |
| + return a.x; |
| +} |
| + |
| +s2() { |
| + var t = new C(); |
| + return t; |
| +} |
| + |
| +s3(a, b) { |
|
Vyacheslav Egorov (Google)
2014/05/08 12:53:20
You should also have a test where redundant store
Florian Schneider
2014/05/08 14:21:43
Done.
|
| + a.x = b + 1; |
| + if (b % 2 == 0) { |
| + a.x = 0; |
| + } else { |
| + a.x = 0; |
| + } |
| + return a.x; |
| +} |
| + |
| + |
| +main() { |
| + for (var i = 0; i < 20; i++) Expect.equals(43, s1(new C())); |
| + for (var i = 0; i < 20; i++) Expect.equals(43, s1a(new C())); |
| + for (var i = 0; i < 20; i++) Expect.equals(123, s2().z); |
| + for (var i = 0; i < 20; i++) Expect.equals(0, s3(new C(), i)); |
| +} |