| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 ? elements_kind.fast_double | 189 ? elements_kind.fast_double |
| 190 : elements_kind.fast); | 190 : elements_kind.fast); |
| 191 } | 191 } |
| 192 */ | 192 */ |
| 193 | 193 |
| 194 /* Element transitions have not been implemented in crankshaft yet. | 194 /* Element transitions have not been implemented in crankshaft yet. |
| 195 %OptimizeFunctionOnNextCall(polymorphic); | 195 %OptimizeFunctionOnNextCall(polymorphic); |
| 196 polymorphic(smis, elements_kind.fast_smi_only); | 196 polymorphic(smis, elements_kind.fast_smi_only); |
| 197 polymorphic(strings, elements_kind.fast); | 197 polymorphic(strings, elements_kind.fast); |
| 198 polymorphic(doubles, elements_kind.fast); | 198 polymorphic(doubles, elements_kind.fast); |
| 199 | |
| 200 // Crankshaft support for smi-only elements in dynamic array literals. | |
| 201 function get(foo) { return foo; } // Used to generate dynamic values. | |
| 202 | |
| 203 function crankshaft_test() { | |
| 204 var a = [get(1), get(2), get(3)]; | |
| 205 assertKind(elements_kind.fast_smi_only, a); | |
| 206 var b = [get(1), get(2), get("three")]; | |
| 207 assertKind(elements_kind.fast, b); | |
| 208 var c = [get(1), get(2), get(3.5)]; | |
| 209 // The full code generator doesn't support conversion to fast_double | |
| 210 // yet. Crankshaft does, but only with --smi-only-arrays support. | |
| 211 if ((%GetOptimizationStatus(crankshaft_test) & 1) && | |
| 212 support_smi_only_arrays) { | |
| 213 assertKind(elements_kind.fast_double, c); | |
| 214 } else { | |
| 215 assertKind(elements_kind.fast, c); | |
| 216 } | |
| 217 } | |
| 218 for (var i = 0; i < 3; i++) { | |
| 219 crankshaft_test(); | |
| 220 } | |
| 221 %OptimizeFunctionOnNextCall(crankshaft_test); | |
| 222 crankshaft_test(); | |
| 223 */ | 199 */ |
| 224 | 200 |
| 225 // Elements_kind transitions for arrays. | 201 // Elements_kind transitions for arrays. |
| 226 | 202 |
| 227 // A map can have three different elements_kind transitions: SMI->DOUBLE, | 203 // A map can have three different elements_kind transitions: SMI->DOUBLE, |
| 228 // DOUBLE->OBJECT, and SMI->OBJECT. No matter in which order these three are | 204 // DOUBLE->OBJECT, and SMI->OBJECT. No matter in which order these three are |
| 229 // created, they must always end up with the same FAST map. | 205 // created, they must always end up with the same FAST map. |
| 230 | 206 |
| 231 // This test is meaningless without FAST_SMI_ONLY_ELEMENTS. | 207 // This test is meaningless without FAST_SMI_ONLY_ELEMENTS. |
| 232 if (support_smi_only_arrays) { | 208 if (support_smi_only_arrays) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 f[0] = 1.5; | 249 f[0] = 1.5; |
| 274 assertKind(elements_kind.fast_double, f); | 250 assertKind(elements_kind.fast_double, f); |
| 275 assertFalse(%HaveSameMap(e, f)); | 251 assertFalse(%HaveSameMap(e, f)); |
| 276 f[0] = "bar"; | 252 f[0] = "bar"; |
| 277 assertKind(elements_kind.fast, f); | 253 assertKind(elements_kind.fast, f); |
| 278 assertTrue(%HaveSameMap(e, f)); | 254 assertTrue(%HaveSameMap(e, f)); |
| 279 } | 255 } |
| 280 | 256 |
| 281 // Throw away type information in the ICs for next stress run. | 257 // Throw away type information in the ICs for next stress run. |
| 282 gc(); | 258 gc(); |
| OLD | NEW |