Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: tests/language/vm/store_elimination_vm_test.dart

Issue 143263010: Implement simple dead store elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
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.
5
6 // VMOptions=--optimization-counter-threshold=10
7
8 import "package:expect/expect.dart";
9
10 class C {
11 var x;
12 var y;
13 final z = 123;
14 }
15
16 class D {
17 var x = 0.0;
18 }
19
20 var array = [0, 0];
21
22 s1(a) {
23 a.x = 42;
24 a.x = 43;
25 return a.x;
26 }
27
28 void foo(a) {
29 Expect.equals(42, a.x);
30 }
31
32 s1a(a) {
33 a.x = 42;
34 foo(a);
35 a.x = 43;
36 return a.x;
37 }
38
39 s2() {
40 var t = new C();
41 return t;
42 }
43
44 s3(a, b) {
45 a.x = b + 1;
46 if (b % 2 == 0) {
47 a.x = 0;
48 } else {
49 a.x = 0;
50 }
51 return a.x;
52 }
53
54 s4(a, b) {
55 a.x = b + 1.0;
56 if (b % 2 == 0) {
57 a.x = b + 2.0;
58 }
59 a.x = b + 1.0;
60 return a.x;
61 }
62
63 test_with_context() {
64 f(a) {
65 var b = a + 1;
66 return (() => b + 1)();
67 }
68 for (var i = 0; i < 100000; i++) f(42);
69 Expect.equals(44, f(42));
70 }
71
72 test_with_instance() {
73 for (var i = 0; i < 20; i++) Expect.equals(43, s1(new C()));
74 for (var i = 0; i < 20; i++) Expect.equals(43, s1a(new C()));
75 for (var i = 0; i < 20; i++) Expect.equals(123, s2().z);
76 for (var i = 0; i < 20; i++) Expect.equals(0, s3(new C(), i));
77 for (var i = 0; i < 20; i++) Expect.equals(i + 1.0, s4(new D(), i));
78 }
79
80 arr1(a) {
81 a[0] = 42;
82 a[0] = 43;
83 Expect.equals(a[0], 43);
84 return a[0];
85 }
86
87 arr2(a, b) {
88 a[0] = 42;
89 a[b % 2] = 43;
90 Expect.equals(a[b % 2], 43);
91 return a[0];
92 }
93
94 test_with_array() {
95 for (var i = 0; i < 20; i++) Expect.equals(43, arr1(array));
96 for (var i = 0; i < 20; i++) {
97 Expect.equals(i % 2 == 0 ? 43 : 42, arr2(array, i));
98 }
99 }
100
101 var st = 0;
102
103 static1(b) {
104 st = 42;
105 if (b % 2 == 0) {
106 st = 2;
107 }
108 st = b + 1;
109 Expect.equals(st, b + 1);
110 return st;
111 }
112
113 test_with_static() {
114 for (var i = 0; i < 20; i++) Expect.equals(i + 1, static1(i));
115 }
116
117 main() {
118 test_with_instance();
119 test_with_array();
120 test_with_context();
121 test_with_static();
122 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698