Index: test/mjsunit/compiler/dead-string-add-warm.js |
diff --git a/test/mjsunit/compiler/dead-code6.js b/test/mjsunit/compiler/dead-string-add-warm.js |
similarity index 63% |
copy from test/mjsunit/compiler/dead-code6.js |
copy to test/mjsunit/compiler/dead-string-add-warm.js |
index ec9b8433ddd72187b3f9dab70baf2399fac0cdb2..982f2b9fbdb3a4385d2cd4b2e22028bb1bc43e0b 100644 |
--- a/test/mjsunit/compiler/dead-code6.js |
+++ b/test/mjsunit/compiler/dead-string-add-warm.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,51 @@ |
// 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; |
+function dead1(a, b) { |
+ var x = "a" + "b"; |
+ return a; // x, "a", and "b" are 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 = "0" + a; |
+ var y = "0" + b; |
+ return a; // x and y are both dead |
} |
function dead3(a, b) { |
- a == 2 ? (a * b) : (b * a); // dead |
- return a; |
+ a = a ? "1" : "0"; |
+ b = b ? "1" : "0"; |
+ var x = a + "0"; |
+ var y = 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 run() { |
+ assertTrue(dead1(33, 32) == 33); |
Sven Panne
2013/07/29 11:48:08
assertEquals(33, dead1(33, 32);
Likewise below an
|
+ assertTrue(dead2(33, 32) == 33); |
+ assertTrue(dead3(33, 32) == "1"); |
-assertTrue(dead2(34, 11) == 34); |
-assertTrue(dead2(34, 11) == 34); |
-%OptimizeFunctionOnNextCall(dead2); |
-assertTrue(dead2(34, 11) == 34); |
+ assertTrue(dead1(31, 30) == 31); |
+ assertTrue(dead2(31, 30) == 31); |
+ assertTrue(dead3(31, 32) == "1"); |
+ |
+ assertTrue(dead1(0, 30) == 0); |
+ assertTrue(dead2(0, 30) == 0); |
+ assertTrue(dead3(0, 32) == "0"); |
+ |
+ assertTrue(dead1(true, 0) == true); |
+ assertTrue(dead2(true, 0) == true); |
+ assertTrue(dead3(true, 0) == "1"); |
-assertTrue(dead3(35, 12) == 35); |
-assertTrue(dead3(35, 12) == 35); |
+ assertTrue(dead1("true", 0) == "true"); |
+ assertTrue(dead2("true", 0) == "true"); |
+ assertTrue(dead3("true", 0) == "1"); |
+} |
+ |
+run(); |
+run(); |
+%OptimizeFunctionOnNextCall(dead1); |
+%OptimizeFunctionOnNextCall(dead2); |
%OptimizeFunctionOnNextCall(dead3); |
-assertTrue(dead3(35, 12) == 35); |
+run(); |