Tune mjsunit/compiler/expression-trees.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/43703002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17404 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ee87c867
...@@ -55,46 +55,43 @@ function makeTrees(op, leaves) { ...@@ -55,46 +55,43 @@ function makeTrees(op, leaves) {
} }
} }
// All 429 possible bitwise OR trees with eight leaves. // All possible bitwise OR trees with six leaves, i.e. CatalanNumber[5] = 42,
var identifiers = ['a','b','c','d','e','f','g','h']; // see http://mathworld.wolfram.com/CatalanNumber.html.
var identifiers = ['a','b','c','d','e','f'];
var or_trees = makeTrees("|", identifiers); var or_trees = makeTrees("|", identifiers);
var and_trees = makeTrees("&", identifiers); var and_trees = makeTrees("&", identifiers);
// Set up leaf masks to set 8 least-significant bits. // Set up leaf masks to set 6 least-significant bits.
var a = 1 << 0; var a = 1 << 0;
var b = 1 << 1; var b = 1 << 1;
var c = 1 << 2; var c = 1 << 2;
var d = 1 << 3; var d = 1 << 3;
var e = 1 << 4; var e = 1 << 4;
var f = 1 << 5; var f = 1 << 5;
var g = 1 << 6;
var h = 1 << 7;
for (var i = 0; i < or_trees.length; ++i) { for (var i = 0; i < or_trees.length; ++i) {
for (var j = 0; j < 8; ++j) { for (var j = 0; j < 6; ++j) {
var or_fun = new Function("return " + or_trees[i]); var or_fun = new Function("return " + or_trees[i]);
if (j == 0) assertEquals(255, or_fun()); if (j == 0) assertEquals(63, or_fun());
// Set the j'th variable to a string to force a bailout. // Set the j'th variable to a string to force a bailout.
eval(identifiers[j] + "+= ''"); eval(identifiers[j] + "+= ''");
assertEquals(255, or_fun()); assertEquals(63, or_fun());
// Set it back to a number for the next iteration. // Set it back to a number for the next iteration.
eval(identifiers[j] + "= +" + identifiers[j]); eval(identifiers[j] + "= +" + identifiers[j]);
} }
} }
// Set up leaf masks to clear 8 least-significant bits. // Set up leaf masks to clear 6 least-significant bits.
a ^= 255; a ^= 63;
b ^= 255; b ^= 63;
c ^= 255; c ^= 63;
d ^= 255; d ^= 63;
e ^= 255; e ^= 63;
f ^= 255; f ^= 63;
g ^= 255;
h ^= 255;
for (i = 0; i < and_trees.length; ++i) { for (i = 0; i < and_trees.length; ++i) {
for (var j = 0; j < 8; ++j) { for (var j = 0; j < 6; ++j) {
var and_fun = new Function("return " + and_trees[i]); var and_fun = new Function("return " + and_trees[i]);
if (j == 0) assertEquals(0, and_fun()); if (j == 0) assertEquals(0, and_fun());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment