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

Unified Diff: test/mjsunit/compiler/dead-loops.js

Issue 98323004: Add some test cases with dead loops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/compiler/dead-loops-neg.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compiler/dead-loops.js
diff --git a/test/mjsunit/regress/regress-seqstrsetchar-ex3.js b/test/mjsunit/compiler/dead-loops.js
similarity index 59%
copy from test/mjsunit/regress/regress-seqstrsetchar-ex3.js
copy to test/mjsunit/compiler/dead-loops.js
index 43d2b083526cbf88da567896c1fd9207b587dd6d..2301b129dd7c435c17ec25b80caded4f088caa1a 100644
--- a/test/mjsunit/regress/regress-seqstrsetchar-ex3.js
+++ b/test/mjsunit/compiler/dead-loops.js
@@ -27,18 +27,61 @@
// Flags: --allow-natives-syntax
-function test() {
- var string = %NewString(10, true);
+// Presents opportunities for dead loop removal.
+
+function loop1() {
+ while (false) ; // doesn't even loop.
+}
+
+function loop2() {
+ var i = 0;
+ while (i++ < 10) ; // nothing in the body.
+}
+
+function loop3() {
+ for (var i = 0; i < 10; i++) ; // nothing in the body.
+}
+
+function loop4() {
+ var a = 0;
+ for (var i = 0; i < 10; i++) a++; // {a} is dead after the loop.
+}
+
+function loop5() {
+ var a = new Int32Array(4), sum = 0;
+ for (var i = 0; i < a.length; i++) {
+ // Involves only reads on typed arrays, and {i} doesn't overflow.
+ sum += a[i];
+ }
+}
+
+function loop6() {
+ var a = new Array(4), sum = 0;
+ for (var i = 0; i < a.length; i++) {
+ // Involves only in-bounds read on the array {a}.
+ // Have to prove that {a} doesn't have getters...?
+ sum += a[i];
+ }
+}
+
+function loop7() {
for (var i = 0; i < 10; i++) {
- %_OneByteSeqStringSetChar(string, i, 65);
- %_OneByteSeqStringSetChar(string, i, 66);
+ new Object(); // Have to prove the allocation doesn't escape.
}
+}
+
+function loop8() {
for (var i = 0; i < 10; i++) {
- assertEquals("B", string[i]);
+ var x = {}; // Have to prove the allocation doesn't escape.
}
}
-test();
-test();
-%OptimizeFunctionOnNextCall(test);
-test();
+var loops = [loop1, loop2, loop3, loop4, loop5, loop6, loop7, loop8];
+
+for (var i = 0; i < loops.length; i++) {
+ var f = loops[i];
+ f();
+ f();
+ %OptimizeFunctionOnNextCall(f);
+ f();
+}
« no previous file with comments | « no previous file | test/mjsunit/compiler/dead-loops-neg.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698