OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc | 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc |
29 | 29 |
30 // Test element kind of objects. | 30 // Test element kind of objects. |
31 // Since --smi-only-arrays affects builtins, its default setting at compile | 31 // Since --smi-only-arrays affects builtins, its default setting at compile |
32 // time sticks if built with snapshot. If --smi-only-arrays is deactivated | 32 // time sticks if built with snapshot. If --smi-only-arrays is deactivated |
33 // by default, only a no-snapshot build actually has smi-only arrays enabled | 33 // by default, only a no-snapshot build actually has smi-only arrays enabled |
34 // in this test case. Depending on whether smi-only arrays are actually | 34 // in this test case. Depending on whether smi-only arrays are actually |
35 // enabled, this test takes the appropriate code path to check smi-only arrays. | 35 // enabled, this test takes the appropriate code path to check smi-only arrays. |
36 | 36 |
37 support_smi_only_arrays = %HasFastSmiOnlyElements(new Array(1,2,3,4,5,6,7,8)); | 37 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); |
38 | 38 |
39 if (support_smi_only_arrays) { | 39 if (support_smi_only_arrays) { |
40 print("Tests include smi-only arrays."); | 40 print("Tests include smi-only arrays."); |
41 } else { | 41 } else { |
42 print("Tests do NOT include smi-only arrays."); | 42 print("Tests do NOT include smi-only arrays."); |
43 } | 43 } |
44 | 44 |
45 var elements_kind = { | 45 var elements_kind = { |
46 fast_smi_only : 'fast smi only elements', | 46 fast_smi_only : 'fast smi only elements', |
47 fast : 'fast elements', | 47 fast : 'fast elements', |
48 fast_double : 'fast double elements', | 48 fast_double : 'fast double elements', |
49 dictionary : 'dictionary elements', | 49 dictionary : 'dictionary elements', |
50 external_byte : 'external byte elements', | 50 external_byte : 'external byte elements', |
51 external_unsigned_byte : 'external unsigned byte elements', | 51 external_unsigned_byte : 'external unsigned byte elements', |
52 external_short : 'external short elements', | 52 external_short : 'external short elements', |
53 external_unsigned_short : 'external unsigned short elements', | 53 external_unsigned_short : 'external unsigned short elements', |
54 external_int : 'external int elements', | 54 external_int : 'external int elements', |
55 external_unsigned_int : 'external unsigned int elements', | 55 external_unsigned_int : 'external unsigned int elements', |
56 external_float : 'external float elements', | 56 external_float : 'external float elements', |
57 external_double : 'external double elements', | 57 external_double : 'external double elements', |
58 external_pixel : 'external pixel elements' | 58 external_pixel : 'external pixel elements' |
59 } | 59 } |
60 | 60 |
61 function getKind(obj) { | 61 function getKind(obj) { |
62 if (%HasFastSmiOnlyElements(obj)) return elements_kind.fast_smi_only; | 62 if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; |
63 if (%HasFastElements(obj)) return elements_kind.fast; | 63 if (%HasFastObjectElements(obj)) return elements_kind.fast; |
64 if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; | 64 if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; |
65 if (%HasDictionaryElements(obj)) return elements_kind.dictionary; | 65 if (%HasDictionaryElements(obj)) return elements_kind.dictionary; |
66 // Every external kind is also an external array. | 66 // Every external kind is also an external array. |
67 assertTrue(%HasExternalArrayElements(obj)); | 67 assertTrue(%HasExternalArrayElements(obj)); |
68 if (%HasExternalByteElements(obj)) { | 68 if (%HasExternalByteElements(obj)) { |
69 return elements_kind.external_byte; | 69 return elements_kind.external_byte; |
70 } | 70 } |
71 if (%HasExternalUnsignedByteElements(obj)) { | 71 if (%HasExternalUnsignedByteElements(obj)) { |
72 return elements_kind.external_unsigned_byte; | 72 return elements_kind.external_unsigned_byte; |
73 } | 73 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 var a = ["foo", "bar"]; | 337 var a = ["foo", "bar"]; |
338 assertKind(elements_kind.fast, a); | 338 assertKind(elements_kind.fast, a); |
339 var b = a.splice(0, 1); | 339 var b = a.splice(0, 1); |
340 assertKind(elements_kind.fast, b); | 340 assertKind(elements_kind.fast, b); |
341 var c = a.slice(0, 1); | 341 var c = a.slice(0, 1); |
342 assertKind(elements_kind.fast, c); | 342 assertKind(elements_kind.fast, c); |
343 } | 343 } |
344 | 344 |
345 // Throw away type information in the ICs for next stress run. | 345 // Throw away type information in the ICs for next stress run. |
346 gc(); | 346 gc(); |
OLD | NEW |