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

Unified Diff: test/mjsunit/bitwise-operations-bools.js

Issue 26824002: Truncate booleans to 0/1 in truncating t-to-i. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add a testcase Created 7 years, 2 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
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/bitwise-operations-bools.js
diff --git a/test/mjsunit/compiler/load-elimination.js b/test/mjsunit/bitwise-operations-bools.js
similarity index 53%
copy from test/mjsunit/compiler/load-elimination.js
copy to test/mjsunit/bitwise-operations-bools.js
index e019508c65ebdc9eb08e03979f81b70633f55319..6c7da110b05da32d62ec73b7ac9d80337d8678be 100644
--- a/test/mjsunit/compiler/load-elimination.js
+++ b/test/mjsunit/bitwise-operations-bools.js
@@ -25,82 +25,70 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax --load-elimination
+// Test bitwise operations with booleans.
-// Test local load elimination of redundant loads and stores.
+var t = 1;
-function B(x, y) {
- this.x = x;
- this.y = y;
- return this;
+function testFalseLeftHandSide() {
+ var b;
+ if (t) b = false;
+ assertEquals(b | 1, 1);
+ assertEquals(b & 1, 0);
+ assertEquals(b ^ 1, 1);
+ assertEquals(b << 1, 0);
+ assertEquals(b >> 1, 0);
+ assertEquals(b >>> 1, 0);
}
-function test_load() {
- var a = new B(1, 2);
- return a.x + a.x + a.x + a.x;
+function testFalseRightHandSide() {
+ if (t) b = false;
+ assertEquals(1 | b, 1);
+ assertEquals(1 & b, 0);
+ assertEquals(1 ^ b, 1);
+ assertEquals(1 << b, 1);
+ assertEquals(1 >> b, 1);
+ assertEquals(1 >>> b, 1);
}
-function test_store_load() {
- var a = new B(1, 2);
- a.x = 4;
- var f = a.x;
- a.x = 5;
- var g = a.x;
- a.x = 6;
- var h = a.x;
- a.x = 7;
- return f + g + h + a.x;
+function testTrueLeftHandSide() {
+ if (t) b = true;
+ assertEquals(b | 1, 1);
+ assertEquals(b & 1, 1);
+ assertEquals(b ^ 1, 0);
+ assertEquals(b << 1, 2);
+ assertEquals(b >> 1, 0);
+ assertEquals(b >>> 1, 0);
}
-function test_nonaliasing_store1() {
- var a = new B(2, 3), b = new B(3, 4);
- b.x = 4;
- var f = a.x;
- b.x = 5;
- var g = a.x;
- b.x = 6;
- var h = a.x;
- b.x = 7;
- return f + g + h + a.x;
+function testTrueRightHandSide() {
+ if (t) b = true;
+ assertEquals(1 | b, 1);
+ assertEquals(1 & b, 1);
+ assertEquals(1 ^ b, 0);
+ assertEquals(1 << b, 2);
+ assertEquals(1 >> b, 0);
+ assertEquals(1 >>> b, 0);
}
-function killall() {
- try { } catch(e) { }
+function testBothSides() {
+ if (t) a = true;
+ if (t) b = false;
+ assertEquals(a | b, 1);
+ assertEquals(a & b, 0);
+ assertEquals(a ^ b, 1);
+ assertEquals(a << b, 1);
+ assertEquals(a >> b, 1);
+ assertEquals(a >>> b, 1);
}
-%NeverOptimizeFunction(killall);
-function test_store_load_kill() {
- var a = new B(1, 2);
- a.x = 4;
- var f = a.x;
- a.x = 5;
- var g = a.x;
- killall();
- a.x = 6;
- var h = a.x;
- a.x = 7;
- return f + g + h + a.x;
-}
-
-function test_store_store() {
- var a = new B(6, 7);
- a.x = 7;
- a.x = 7;
- a.x = 7;
- a.x = 7;
- return a.x;
-}
-
-function test(x, f) {
- assertEquals(x, f());
- assertEquals(x, f());
- %OptimizeFunctionOnNextCall(f);
- assertEquals(x, f());
-}
-
-test(4, test_load);
-test(22, test_store_load);
-test(8, test_nonaliasing_store1);
-test(22, test_store_load_kill);
-test(7, test_store_store);
+testFalseLeftHandSide();
+testFalseRightHandSide();
+testTrueLeftHandSide();
+testTrueRightHandSide();
+testFalseLeftHandSide();
+testFalseRightHandSide();
+testTrueLeftHandSide();
+testTrueRightHandSide();
+testBothSides();
+testBothSides();
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698