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 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax --expose-gc --nostress-opt --typed-array-max-si
ze-in-heap=2048 | 28 // Flags: --allow-natives-syntax --expose-gc --nostress-opt --typed-array-max-si
ze-in-heap=2048 |
29 | 29 |
30 var elements_kind = { | 30 var elements_kind = { |
31 fast_smi_only : 'fast smi only elements', | 31 fast_smi_only : 'fast smi only elements', |
32 fast : 'fast elements', | 32 fast : 'fast elements', |
33 fast_double : 'fast double elements', | 33 fast_double : 'fast double elements', |
34 dictionary : 'dictionary elements', | 34 dictionary : 'dictionary elements', |
35 external_int32 : 'external int8 elements', | |
36 external_uint8 : 'external uint8 elements', | |
37 external_int16 : 'external int16 elements', | |
38 external_uint16 : 'external uint16 elements', | |
39 external_int32 : 'external int32 elements', | |
40 external_uint32 : 'external uint32 elements', | |
41 external_float32 : 'external float32 elements', | |
42 external_float64 : 'external float64 elements', | |
43 external_uint8_clamped : 'external uint8_clamped elements', | |
44 fixed_int32 : 'fixed int8 elements', | 35 fixed_int32 : 'fixed int8 elements', |
45 fixed_uint8 : 'fixed uint8 elements', | 36 fixed_uint8 : 'fixed uint8 elements', |
46 fixed_int16 : 'fixed int16 elements', | 37 fixed_int16 : 'fixed int16 elements', |
47 fixed_uint16 : 'fixed uint16 elements', | 38 fixed_uint16 : 'fixed uint16 elements', |
48 fixed_int32 : 'fixed int32 elements', | 39 fixed_int32 : 'fixed int32 elements', |
49 fixed_uint32 : 'fixed uint32 elements', | 40 fixed_uint32 : 'fixed uint32 elements', |
50 fixed_float32 : 'fixed float32 elements', | 41 fixed_float32 : 'fixed float32 elements', |
51 fixed_float64 : 'fixed float64 elements', | 42 fixed_float64 : 'fixed float64 elements', |
52 fixed_uint8_clamped : 'fixed uint8_clamped elements' | 43 fixed_uint8_clamped : 'fixed uint8_clamped elements' |
53 } | 44 } |
54 | 45 |
55 function getKind(obj) { | 46 function getKind(obj) { |
56 if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; | 47 if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; |
57 if (%HasFastObjectElements(obj)) return elements_kind.fast; | 48 if (%HasFastObjectElements(obj)) return elements_kind.fast; |
58 if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; | 49 if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; |
59 if (%HasDictionaryElements(obj)) return elements_kind.dictionary; | 50 if (%HasDictionaryElements(obj)) return elements_kind.dictionary; |
60 | 51 |
61 // Every external kind is also an external array. | |
62 if (%HasExternalInt8Elements(obj)) { | |
63 return elements_kind.external_int8; | |
64 } | |
65 if (%HasExternalUint8Elements(obj)) { | |
66 return elements_kind.external_uint8; | |
67 } | |
68 if (%HasExternalInt16Elements(obj)) { | |
69 return elements_kind.external_int16; | |
70 } | |
71 if (%HasExternalUint16Elements(obj)) { | |
72 return elements_kind.external_uint16; | |
73 } | |
74 if (%HasExternalInt32Elements(obj)) { | |
75 return elements_kind.external_int32; | |
76 } | |
77 if (%HasExternalUint32Elements(obj)) { | |
78 return elements_kind.external_uint32; | |
79 } | |
80 if (%HasExternalFloat32Elements(obj)) { | |
81 return elements_kind.external_float32; | |
82 } | |
83 if (%HasExternalFloat64Elements(obj)) { | |
84 return elements_kind.external_float64; | |
85 } | |
86 if (%HasExternalUint8ClampedElements(obj)) { | |
87 return elements_kind.external_uint8_clamped; | |
88 } | |
89 if (%HasFixedInt8Elements(obj)) { | 52 if (%HasFixedInt8Elements(obj)) { |
90 return elements_kind.fixed_int8; | 53 return elements_kind.fixed_int8; |
91 } | 54 } |
92 if (%HasFixedUint8Elements(obj)) { | 55 if (%HasFixedUint8Elements(obj)) { |
93 return elements_kind.fixed_uint8; | 56 return elements_kind.fixed_uint8; |
94 } | 57 } |
95 if (%HasFixedInt16Elements(obj)) { | 58 if (%HasFixedInt16Elements(obj)) { |
96 return elements_kind.fixed_int16; | 59 return elements_kind.fixed_int16; |
97 } | 60 } |
98 if (%HasFixedUint16Elements(obj)) { | 61 if (%HasFixedUint16Elements(obj)) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 assertKind(elements_kind.fixed_uint8, new Uint8Array(007)); | 120 assertKind(elements_kind.fixed_uint8, new Uint8Array(007)); |
158 assertKind(elements_kind.fixed_int16, new Int16Array(666)); | 121 assertKind(elements_kind.fixed_int16, new Int16Array(666)); |
159 assertKind(elements_kind.fixed_uint16, new Uint16Array(42)); | 122 assertKind(elements_kind.fixed_uint16, new Uint16Array(42)); |
160 assertKind(elements_kind.fixed_int32, new Int32Array(0xF)); | 123 assertKind(elements_kind.fixed_int32, new Int32Array(0xF)); |
161 assertKind(elements_kind.fixed_uint32, new Uint32Array(23)); | 124 assertKind(elements_kind.fixed_uint32, new Uint32Array(23)); |
162 assertKind(elements_kind.fixed_float32, new Float32Array(7)); | 125 assertKind(elements_kind.fixed_float32, new Float32Array(7)); |
163 assertKind(elements_kind.fixed_float64, new Float64Array(0)); | 126 assertKind(elements_kind.fixed_float64, new Float64Array(0)); |
164 assertKind(elements_kind.fixed_uint8_clamped, new Uint8ClampedArray(512)); | 127 assertKind(elements_kind.fixed_uint8_clamped, new Uint8ClampedArray(512)); |
165 | 128 |
166 var ab = new ArrayBuffer(128); | 129 var ab = new ArrayBuffer(128); |
167 assertKind(elements_kind.external_int8, new Int8Array(ab)); | 130 assertKind(elements_kind.fixed_int8, new Int8Array(ab)); |
168 assertKind(elements_kind.external_uint8, new Uint8Array(ab)); | 131 assertKind(elements_kind.fixed_uint8, new Uint8Array(ab)); |
169 assertKind(elements_kind.external_int16, new Int16Array(ab)); | 132 assertKind(elements_kind.fixed_int16, new Int16Array(ab)); |
170 assertKind(elements_kind.external_uint16, new Uint16Array(ab)); | 133 assertKind(elements_kind.fixed_uint16, new Uint16Array(ab)); |
171 assertKind(elements_kind.external_int32, new Int32Array(ab)); | 134 assertKind(elements_kind.fixed_int32, new Int32Array(ab)); |
172 assertKind(elements_kind.external_uint32, new Uint32Array(ab)); | 135 assertKind(elements_kind.fixed_uint32, new Uint32Array(ab)); |
173 assertKind(elements_kind.external_float32, new Float32Array(ab)); | 136 assertKind(elements_kind.fixed_float32, new Float32Array(ab)); |
174 assertKind(elements_kind.external_float64, new Float64Array(ab)); | 137 assertKind(elements_kind.fixed_float64, new Float64Array(ab)); |
175 assertKind(elements_kind.external_uint8_clamped, new Uint8ClampedArray(ab)); | 138 assertKind(elements_kind.fixed_uint8_clamped, new Uint8ClampedArray(ab)); |
176 | 139 |
177 // Crankshaft support for smi-only array elements. | 140 // Crankshaft support for smi-only array elements. |
178 function monomorphic(array) { | 141 function monomorphic(array) { |
179 assertKind(elements_kind.fast_smi_only, array); | 142 assertKind(elements_kind.fast_smi_only, array); |
180 for (var i = 0; i < 3; i++) { | 143 for (var i = 0; i < 3; i++) { |
181 array[i] = i + 10; | 144 array[i] = i + 10; |
182 } | 145 } |
183 assertKind(elements_kind.fast_smi_only, array); | 146 assertKind(elements_kind.fast_smi_only, array); |
184 for (var i = 0; i < 3; i++) { | 147 for (var i = 0; i < 3; i++) { |
185 var a = array[i]; | 148 var a = array[i]; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 // Test that Array.splice() and Array.slice() return correct ElementsKinds. | 340 // Test that Array.splice() and Array.slice() return correct ElementsKinds. |
378 var a = ["foo", "bar"]; | 341 var a = ["foo", "bar"]; |
379 assertKind(elements_kind.fast, a); | 342 assertKind(elements_kind.fast, a); |
380 var b = a.splice(0, 1); | 343 var b = a.splice(0, 1); |
381 assertKind(elements_kind.fast, b); | 344 assertKind(elements_kind.fast, b); |
382 var c = a.slice(0, 1); | 345 var c = a.slice(0, 1); |
383 assertKind(elements_kind.fast, c); | 346 assertKind(elements_kind.fast, c); |
384 | 347 |
385 // Throw away type information in the ICs for next stress run. | 348 // Throw away type information in the ICs for next stress run. |
386 gc(); | 349 gc(); |
OLD | NEW |