| 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();
|
| +}
|
|
|