Index: test/mjsunit/element-kind.js |
diff --git a/test/mjsunit/element-kind.js b/test/mjsunit/element-kind.js |
index 48a029f27e8852eb4dde4d57ec4ffa8c0680e501..1949857fd8b0214c9fc3d117725f629c59c63723 100644 |
--- a/test/mjsunit/element-kind.js |
+++ b/test/mjsunit/element-kind.js |
@@ -28,7 +28,10 @@ |
// Flags: --allow-natives-syntax |
// Test element kind of objects |
+support_smi_only_arrays = %HasFastSmiOnlyElements([]); |
+ |
var element_kind = { |
+ fast_smi_only_elements : 0, |
fast_elements : 1, |
fast_double_elements : 2, |
dictionary_elements : 3, |
@@ -45,8 +48,16 @@ var element_kind = { |
// We expect an object to only be of one element kind. |
function assertKind(expected, obj){ |
- assertEquals(expected == element_kind.fast_elements, |
- %HasFastElements(obj)); |
+ if (support_smi_only_arrays) { |
+ assertEquals(expected == element_kind.fast_smi_only_elements, |
+ %HasFastSmiOnlyElements(obj)); |
+ assertEquals(expected == element_kind.fast_elements, |
+ %HasFastElements(obj)); |
+ } else { |
+ assertEquals(expected == element_kind.fast_elements || |
+ expected == element_kind.fast_smi_only_elements, |
+ %HasFastElements(obj)); |
+ } |
assertEquals(expected == element_kind.fast_double_elements, |
%HasFastDoubleElements(obj)); |
assertEquals(expected == element_kind.dictionary_elements, |
@@ -80,9 +91,22 @@ me.dance = 0xD15C0; |
me.drink = 0xC0C0A; |
assertKind(element_kind.fast_elements, me); |
+var too = [1,2,3]; |
+assertKind(element_kind.fast_smi_only_elements, too); |
+too.dance = 0xD15C0; |
+too.drink = 0xC0C0A; |
+assertKind(element_kind.fast_smi_only_elements, too); |
+ |
+// Make sure the element kind transitions from smionly when a non-smi is stored. |
var you = new Array(); |
+assertKind(element_kind.fast_smi_only_elements, you); |
for(i = 0; i < 1337; i++) { |
- you[i] = i; |
+ var val = i; |
+ if (i == 1336) { |
+ assertKind(element_kind.fast_smi_only_elements, you); |
+ val = new Object(); |
+ } |
+ you[i] = val; |
} |
assertKind(element_kind.fast_elements, you); |