Index: test/mjsunit/array-literal-feedback.js |
diff --git a/test/mjsunit/array-literal-feedback.js b/test/mjsunit/array-literal-feedback.js |
index 3378394d90a32f16e44a4682e3c8ccf4dcd4daec..d2245c62a262fc011f89b5000de310bf26e53635 100644 |
--- a/test/mjsunit/array-literal-feedback.js |
+++ b/test/mjsunit/array-literal-feedback.js |
@@ -44,6 +44,42 @@ if (support_smi_only_arrays) { |
print("Tests do NOT include smi-only arrays."); |
} |
+var elements_kind = { |
+ fast_smi_only : 'fast smi only elements', |
+ fast : 'fast elements', |
+ fast_double : 'fast double elements', |
+ dictionary : 'dictionary elements', |
+ external_byte : 'external byte elements', |
+ external_unsigned_byte : 'external unsigned byte elements', |
+ external_short : 'external short elements', |
+ external_unsigned_short : 'external unsigned short elements', |
+ external_int : 'external int elements', |
+ external_unsigned_int : 'external unsigned int elements', |
+ external_float : 'external float elements', |
+ external_double : 'external double elements', |
+ external_pixel : 'external pixel elements' |
+} |
+ |
+function getKind(obj) { |
+ if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; |
+ if (%HasFastObjectElements(obj)) return elements_kind.fast; |
+ if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; |
+ if (%HasDictionaryElements(obj)) return elements_kind.dictionary; |
+} |
+ |
+function isHoley(obj) { |
+ if (%HasFastHoleyElements(obj)) return true; |
+ return false; |
+} |
+ |
+function assertKind(expected, obj, name_opt) { |
+ if (!support_smi_only_arrays && |
+ expected == elements_kind.fast_smi_only) { |
+ expected = elements_kind.fast; |
+ } |
+ assertEquals(expected, getKind(obj), name_opt); |
+} |
+ |
if (support_smi_only_arrays) { |
function get_literal(x) { |
@@ -72,4 +108,19 @@ if (support_smi_only_arrays) { |
b = get_literal(3); |
assertTrue(%HasFastDoubleElements(b)); |
assertOptimized(get_literal); |
+ |
+ |
+ // Test: make sure allocation site information is updated through a |
+ // transition from SMI->DOUBLE->FAST |
+ (function() { |
+ function bar(a, b, c) { |
+ return [a, b, c]; |
+ } |
+ |
+ a = bar(1, 2, 3); |
+ a[0] = 3.5; |
+ a[1] = 'hi'; |
+ b = bar(1, 2, 3); |
+ assertKind(elements_kind.fast, b); |
+ })(); |
} |