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

Side by Side Diff: tests/language/range_analysis_test.dart

Issue 18563006: More tests updated to optimize code (Part 2). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
OLDNEW
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 // Dart test program for constructors and initializers. 4 // Dart test program for constructors and initializers.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
5 6
6 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
7 8
8 // Check that range analysis does not enter infinite loop trying to propagate 9 // Check that range analysis does not enter infinite loop trying to propagate
9 // ranges through dependant phis. 10 // ranges through dependant phis.
10 bar() { 11 bar() {
11 var sum = 0; 12 var sum = 0;
12 for (var i = 0; i < 10; i++) { 13 for (var i = 0; i < 10; i++) {
13 for (var j = i - 1; j >= 0; j--) { 14 for (var j = i - 1; j >= 0; j--) {
14 for (var k = j; k < i; k++) { 15 for (var k = j; k < i; k++) {
15 sum += (i + j + k); 16 sum += (i + j + k);
16 } 17 }
17 } 18 }
18 } 19 }
19 return sum; 20 return sum;
20 } 21 }
21 22
22 test1() { 23 test1() {
23 for (var i = 0; i < 1000; i++) bar(); 24 for (var i = 0; i < 20; i++) bar();
24 } 25 }
25 26
26 // Check that range analysis does not erroneously remove overflow check. 27 // Check that range analysis does not erroneously remove overflow check.
27 test2() { 28 test2() {
28 var width = 1073741823; 29 var width = 1073741823;
29 Expect.equals(width - 1, foo(width - 5000, width - 1)); 30 Expect.equals(width - 1, foo(width - 5000, width - 1));
30 Expect.equals(width, foo(width - 5000, width)); 31 Expect.equals(width, foo(width - 5000, width));
31 } 32 }
32 33
33 foo(n, w) { 34 foo(n, w) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (i < 0) throw "unreachable"; 78 if (i < 0) throw "unreachable";
78 } 79 }
79 return i; 80 return i;
80 } 81 }
81 82
82 h(n) { 83 h(n) {
83 var i; 84 var i;
84 for (i = 0; i < n; i++) { 85 for (i = 0; i < n; i++) {
85 if (i < 0) throw "unreachable"; 86 if (i < 0) throw "unreachable";
86 var j = i - 1; 87 var j = i - 1;
87 if (j >= n - 1) throw "unreachable"; 88 if (j >= n - 1) throw "unreachable";
88 } 89 }
89 return i; 90 return i;
90 } 91 }
91 92
92 93
93 test3() { 94 test3() {
94 test_fun(fun) { 95 test_fun(fun) {
95 Expect.equals(2, fun(0, 1)); 96 Expect.equals(2, fun(0, 1));
96 Expect.equals(3, fun(0, 0)); 97 Expect.equals(3, fun(0, 0));
97 for (var i = 0; i < 2000; i++) fun(0, 1); 98 for (var i = 0; i < 20; i++) fun(0, 1);
98 Expect.equals(2, fun(0, 1)); 99 Expect.equals(2, fun(0, 1));
99 Expect.equals(3, fun(0, 0)); 100 Expect.equals(3, fun(0, 0));
100 } 101 }
101 102
102 test_fun(f); 103 test_fun(f);
103 test_fun(f1); 104 test_fun(f1);
104 test_fun(f2); 105 test_fun(f2);
105 106
106 Expect.equals(10, g()); 107 Expect.equals(10, g());
107 for (var i = 0; i < 2000; i++) g(); 108 for (var i = 0; i < 20; i++) g();
108 Expect.equals(10, g()); 109 Expect.equals(10, g());
109 110
110 111
111 Expect.equals(10, h(10)); 112 Expect.equals(10, h(10));
112 for (var i = 0; i < 2000; i++) h(10); 113 for (var i = 0; i < 20; i++) h(10);
113 Expect.equals(10, h(10)); 114 Expect.equals(10, h(10));
114 } 115 }
115 116
116 117
117 main() { 118 main() {
118 test1(); 119 test1();
119 test2(); 120 test2();
120 test3(); 121 test3();
121 } 122 }
OLDNEW
« no previous file with comments | « tests/language/optimized_string_charcodeat_test.dart ('k') | tests/language/strict_equal_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698