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

Unified Diff: test/mjsunit/compiler/dead-string-add.js

Issue 20241005: Fix IsDeletable() for HStringAdd, HStringCharCodeAt, HStringCharFromCode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test cases and simplify conditions for removal of checks. 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 side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/compiler/dead-string-add.js
diff --git a/test/mjsunit/compiler/dead-code3.js b/test/mjsunit/compiler/dead-string-add.js
similarity index 66%
copy from test/mjsunit/compiler/dead-code3.js
copy to test/mjsunit/compiler/dead-string-add.js
index d05797825b9400033b148090e9cd47e8305c4ce9..4ef4adbfaf63118d0264f4f6aeca844382e1c68d 100644
--- a/test/mjsunit/compiler/dead-code3.js
+++ b/test/mjsunit/compiler/dead-string-add.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,53 +26,40 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function dead1(a, b) {
- a + b; // dead
- return a;
+ var x = "a" + "b";
+ return a; // x, "a", and "b" are dead code
}
function dead2(a, b) {
- a | 0; // dead
- b | 0; // dead
+ var x = a + "0";
+ var y = b + "0";
return a; // x and y are both dead
}
function dead3(a, b) {
- a == 2 ? a : b; // dead
- return a;
-}
-
-function dead4(a) {
- var z = 3;
- for (i = 0; i < 3; i++) {
- z + 3; // dead
- }
- return a;
-}
-
-function dead5(a) {
- var z = 3;
- for (i = 0; i < 3; i++) {
- z + 3; // dead
- z++;
- }
- var w = z + a;
- return a; // z is dead
+ 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(dead2(33, 32) == 33);
-assertTrue(dead3(33, 32) == 33);
-assertTrue(dead4(33) == 33);
-assertTrue(dead5(33) == 33);
+assertTrue(dead3(33, 32) == "1");
+
+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(34, 7) == 34);
-assertTrue(dead2(34, 7) == 34);
-assertTrue(dead3(34, 7) == 34);
-assertTrue(dead4(34) == 34);
-assertTrue(dead5(34) == 34);
+assertTrue(dead1(true, 0) == true);
+assertTrue(dead2(true, 0) == true);
+assertTrue(dead3(true, 0) == "1");
-assertTrue(dead1(3.4, 0.1) == 3.4);
-assertTrue(dead2(3.4, 0.1) == 3.4);
-assertTrue(dead3(3.4, 0.1) == 3.4);
-assertTrue(dead4(3.4) == 3.4);
-assertTrue(dead5(3.4) == 3.4);
+assertTrue(dead1("true", 0) == "true");
+assertTrue(dead2("true", 0) == "true");
+assertTrue(dead3("true", 0) == "1");

Powered by Google App Engine
This is Rietveld 408576698