Make elements_kind map transition test conditional on smi element support

TEST=mjsunit/element-kind passes even without --smi-only-arrays

Review URL: http://codereview.chromium.org/8230008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9578 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
jkummerow@chromium.org 2011-10-11 10:02:42 +00:00
parent 184fdcf28b
commit ddacdf847b

View File

@ -209,49 +209,53 @@ crankshaft_test();
// A map can have three different elements_kind transitions: SMI->DOUBLE,
// DOUBLE->OBJECT, and SMI->OBJECT. No matter in which order these three are
// created, they must always end up with the same FAST map.
// Preparation: create one pair of identical objects for each case.
var a = [1, 2, 3];
var b = [1, 2, 3];
assertTrue(%HaveSameMap(a, b));
assertKind(element_kind.fast_smi_only_elements, a);
var c = [1, 2, 3];
c["case2"] = true;
var d = [1, 2, 3];
d["case2"] = true;
assertTrue(%HaveSameMap(c, d));
assertFalse(%HaveSameMap(a, c));
assertKind(element_kind.fast_smi_only_elements, c);
var e = [1, 2, 3];
e["case3"] = true;
var f = [1, 2, 3];
f["case3"] = true;
assertTrue(%HaveSameMap(e, f));
assertFalse(%HaveSameMap(a, e));
assertFalse(%HaveSameMap(c, e));
assertKind(element_kind.fast_smi_only_elements, e);
// Case 1: SMI->DOUBLE, DOUBLE->OBJECT, SMI->OBJECT.
a[0] = 1.5;
assertKind(element_kind.fast_double_elements, a);
a[0] = "foo";
assertKind(element_kind.fast_elements, a);
b[0] = "bar";
assertTrue(%HaveSameMap(a, b));
// Case 2: SMI->DOUBLE, SMI->OBJECT, DOUBLE->OBJECT.
c[0] = 1.5;
assertKind(element_kind.fast_double_elements, c);
assertFalse(%HaveSameMap(c, d));
d[0] = "foo";
assertKind(element_kind.fast_elements, d);
assertFalse(%HaveSameMap(c, d));
c[0] = "bar";
assertTrue(%HaveSameMap(c, d));
// Case 3: SMI->OBJECT, SMI->DOUBLE, DOUBLE->OBJECT.
e[0] = "foo";
assertKind(element_kind.fast_elements, e);
assertFalse(%HaveSameMap(e, f));
f[0] = 1.5;
assertKind(element_kind.fast_double_elements, f);
assertFalse(%HaveSameMap(e, f));
f[0] = "bar";
assertKind(element_kind.fast_elements, f);
assertTrue(%HaveSameMap(e, f));
// This test is meaningless without FAST_SMI_ONLY_ELEMENTS.
if (support_smi_only_arrays) {
// Preparation: create one pair of identical objects for each case.
var a = [1, 2, 3];
var b = [1, 2, 3];
assertTrue(%HaveSameMap(a, b));
assertKind(element_kind.fast_smi_only_elements, a);
var c = [1, 2, 3];
c["case2"] = true;
var d = [1, 2, 3];
d["case2"] = true;
assertTrue(%HaveSameMap(c, d));
assertFalse(%HaveSameMap(a, c));
assertKind(element_kind.fast_smi_only_elements, c);
var e = [1, 2, 3];
e["case3"] = true;
var f = [1, 2, 3];
f["case3"] = true;
assertTrue(%HaveSameMap(e, f));
assertFalse(%HaveSameMap(a, e));
assertFalse(%HaveSameMap(c, e));
assertKind(element_kind.fast_smi_only_elements, e);
// Case 1: SMI->DOUBLE, DOUBLE->OBJECT, SMI->OBJECT.
a[0] = 1.5;
assertKind(element_kind.fast_double_elements, a);
a[0] = "foo";
assertKind(element_kind.fast_elements, a);
b[0] = "bar";
assertTrue(%HaveSameMap(a, b));
// Case 2: SMI->DOUBLE, SMI->OBJECT, DOUBLE->OBJECT.
c[0] = 1.5;
assertKind(element_kind.fast_double_elements, c);
assertFalse(%HaveSameMap(c, d));
d[0] = "foo";
assertKind(element_kind.fast_elements, d);
assertFalse(%HaveSameMap(c, d));
c[0] = "bar";
assertTrue(%HaveSameMap(c, d));
// Case 3: SMI->OBJECT, SMI->DOUBLE, DOUBLE->OBJECT.
e[0] = "foo";
assertKind(element_kind.fast_elements, e);
assertFalse(%HaveSameMap(e, f));
f[0] = 1.5;
assertKind(element_kind.fast_double_elements, f);
assertFalse(%HaveSameMap(e, f));
f[0] = "bar";
assertKind(element_kind.fast_elements, f);
assertTrue(%HaveSameMap(e, f));
}