| Index: test/mjsunit/compiler/dead-string-char-code-at2.js
|
| diff --git a/test/mjsunit/compiler/dead-code6.js b/test/mjsunit/compiler/dead-string-char-code-at2.js
|
| similarity index 60%
|
| copy from test/mjsunit/compiler/dead-code6.js
|
| copy to test/mjsunit/compiler/dead-string-char-code-at2.js
|
| index ec9b8433ddd72187b3f9dab70baf2399fac0cdb2..53253c0ddd1796201f16eeb583563c01a38840e9 100644
|
| --- a/test/mjsunit/compiler/dead-code6.js
|
| +++ b/test/mjsunit/compiler/dead-string-char-code-at2.js
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2008 the V8 project authors. All rights reserved.
|
| +// Copyright 2013 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -26,48 +26,56 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| // Flags: --allow-natives-syntax
|
| -// Test some dead code elimination scenarios
|
|
|
| -function dead1(x, y) {
|
| - var a = x | 0, b = y | 0;
|
| - a * b;
|
| - a << b;
|
| - a >> b;
|
| - a >>> b;
|
| - a | b;
|
| - a & b;
|
| - a ^ b;
|
| - return x;
|
| +var S1 = "string1";
|
| +var S2 = "@@string2";
|
| +
|
| +function dead1(a, b) {
|
| + var x = %_StringCharCodeAt(a, 4);
|
| + return a; // x is dead code
|
| }
|
|
|
| -function dead2(x, y) {
|
| - var a = x | 0, b = y | 0;
|
| - (a | 0) * b;
|
| - (a | 0) << b;
|
| - (a | 0) >> b;
|
| - (a | 0) >>> b;
|
| - (a | 0) | b;
|
| - (a | 0) & b;
|
| - (a | 0) ^ b;
|
| - return x;
|
| +function dead2(a, b) {
|
| + var x = %_StringCharCodeAt(a, 3);
|
| + var y = %_StringCharCodeAt(b, 1);
|
| + return a; // x and y are both dead
|
| }
|
|
|
| function dead3(a, b) {
|
| - a == 2 ? (a * b) : (b * a); // dead
|
| - return a;
|
| + a = a ? "11" : "12";
|
| + b = b ? "13" : "14";
|
| + var x = %_StringCharCodeAt(a, 2);
|
| + var y = %_StringCharCodeAt(b, 0);
|
| + return a; // x and y are both dead
|
| }
|
|
|
| -assertTrue(dead1(33, 32) == 33);
|
| -assertTrue(dead1(33, 32) == 33);
|
| -%OptimizeFunctionOnNextCall(dead1);
|
| -assertTrue(dead1(33, 32) == 33);
|
| +function test() {
|
| + var S3 = S1 + S2;
|
|
|
| -assertTrue(dead2(34, 11) == 34);
|
| -assertTrue(dead2(34, 11) == 34);
|
| -%OptimizeFunctionOnNextCall(dead2);
|
| -assertTrue(dead2(34, 11) == 34);
|
| + assertTrue(dead1(S1, S2) == S1);
|
| + assertTrue(dead2(S1, S2) == S1);
|
| + assertTrue(dead3(S1, S2) == "11");
|
| +
|
| + assertTrue(dead1(S2, 677) == S2);
|
| + assertTrue(dead2(S2, S3) == S2);
|
| + assertTrue(dead3(S2, S3) == "11");
|
| +
|
| + assertTrue(dead1(S3, 399) == S3);
|
| + assertTrue(dead2(S3, "false") == S3);
|
| + assertTrue(dead3(0, 32) == "12");
|
|
|
| -assertTrue(dead3(35, 12) == 35);
|
| -assertTrue(dead3(35, 12) == 35);
|
| + assertTrue(dead1(S3, 0) == S3);
|
| + assertTrue(dead2(S3, S1) == S3);
|
| + assertTrue(dead3(S3, 0) == "11");
|
| +
|
| + assertTrue(dead1("true", 0) == "true");
|
| + assertTrue(dead2("true", S3) == "true");
|
| + assertTrue(dead3("true", 0) == "11");
|
| +}
|
| +
|
| +test();
|
| +test();
|
| +%OptimizeFunctionOnNextCall(dead1);
|
| +%OptimizeFunctionOnNextCall(dead2);
|
| %OptimizeFunctionOnNextCall(dead3);
|
| -assertTrue(dead3(35, 12) == 35);
|
| +test();
|
|
|