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

Unified Diff: test/mjsunit/compiler/dead-string-char-from-code.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-char-from-code.js
diff --git a/test/mjsunit/compiler/dead-code6.js b/test/mjsunit/compiler/dead-string-char-from-code.js
similarity index 62%
copy from test/mjsunit/compiler/dead-code6.js
copy to test/mjsunit/compiler/dead-string-char-from-code.js
index ec9b8433ddd72187b3f9dab70baf2399fac0cdb2..f9db59d92bbd108ec38e7a1e12cd6342142de208 100644
--- a/test/mjsunit/compiler/dead-code6.js
+++ b/test/mjsunit/compiler/dead-string-char-from-code.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 = %_StringCharFromCode(a);
+ 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 = %_StringCharFromCode(a);
+ var y = %_StringCharFromCode(b);
+ 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 = %_StringCharFromCode(a);
+ var y = %_StringCharFromCode(b);
+ 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() {
+ assertTrue(dead1(33, 32) == 33);
+ assertTrue(dead2(33, 32) == 33);
+ assertTrue(dead3(33, 32) == 11);
-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) == 11);
+
+ assertTrue(dead1(0, 30) == 0);
+ assertTrue(dead2(0, 30) == 0);
+ assertTrue(dead3(0, 32) == 12);
+
+ assertTrue(dead1(true, 0) == true);
+ assertTrue(dead2(true, 0) == true);
+ assertTrue(dead3(true, 0) == 11);
-assertTrue(dead3(35, 12) == 35);
-assertTrue(dead3(35, 12) == 35);
+ assertTrue(dead1("true", 0) == "true");
+ assertTrue(dead2("true", 0) == "true");
+ assertTrue(dead3("true", 0) == 11);
+}
+
+test();
+test();
+%OptimizeFunctionOnNextCall(dead1);
+%OptimizeFunctionOnNextCall(dead2);
%OptimizeFunctionOnNextCall(dead3);
-assertTrue(dead3(35, 12) == 35);
+test();

Powered by Google App Engine
This is Rietveld 408576698