| 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 15 matching lines...) Expand all Loading... |
| 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 --smi-only-arrays --expose-gc | 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc |
| 29 // Test element kind of objects. | 29 // Test element kind of objects. |
| 30 // Since --smi-only-arrays affects builtins, its default setting at compile | 30 // Since --smi-only-arrays affects builtins, its default setting at compile |
| 31 // time sticks if built with snapshot. If --smi-only-arrays is deactivated | 31 // time sticks if built with snapshot. If --smi-only-arrays is deactivated |
| 32 // by default, only a no-snapshot build actually has smi-only arrays enabled | 32 // by default, only a no-snapshot build actually has smi-only arrays enabled |
| 33 // in this test case. Depending on whether smi-only arrays are actually | 33 // in this test case. Depending on whether smi-only arrays are actually |
| 34 // enabled, this test takes the appropriate code path to check smi-only arrays. | 34 // enabled, this test takes the appropriate code path to check smi-only arrays. |
| 35 | 35 |
| 36 support_smi_only_arrays = %HasFastSmiOnlyElements(new Array()); | 36 support_smi_only_arrays = %HasFastSmiOnlyElements([1,2,3,4,5,6,7,8,9,10]); |
| 37 |
| 38 if (support_smi_only_arrays) { |
| 39 print("Tests include smi-only arrays."); |
| 40 } else { |
| 41 print("Tests do NOT include smi-only arrays."); |
| 42 } |
| 37 | 43 |
| 38 // IC and Crankshaft support for smi-only elements in dynamic array literals. | 44 // IC and Crankshaft support for smi-only elements in dynamic array literals. |
| 39 function get(foo) { return foo; } // Used to generate dynamic values. | 45 function get(foo) { return foo; } // Used to generate dynamic values. |
| 40 | 46 |
| 41 function array_literal_test() { | 47 function array_literal_test() { |
| 42 var a0 = [1, 2, 3]; | 48 var a0 = [1, 2, 3]; |
| 43 assertTrue(%HasFastSmiOnlyElements(a0)); | 49 assertTrue(%HasFastSmiOnlyElements(a0)); |
| 44 var a1 = [get(1), get(2), get(3)]; | 50 var a1 = [get(1), get(2), get(3)]; |
| 45 assertTrue(%HasFastSmiOnlyElements(a1)); | 51 assertTrue(%HasFastSmiOnlyElements(a1)); |
| 46 | 52 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 assertEquals(1, array[1]); | 194 assertEquals(1, array[1]); |
| 189 assertEquals(6, array[2]); | 195 assertEquals(6, array[2]); |
| 190 | 196 |
| 191 var foo = new Object(); | 197 var foo = new Object(); |
| 192 array = deopt_array_literal_all_doubles(foo); | 198 array = deopt_array_literal_all_doubles(foo); |
| 193 assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_doubles)); | 199 assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_doubles)); |
| 194 assertEquals(0.5, array[0]); | 200 assertEquals(0.5, array[0]); |
| 195 assertEquals(1, array[1]); | 201 assertEquals(1, array[1]); |
| 196 assertEquals(foo, array[2]); | 202 assertEquals(foo, array[2]); |
| 197 } | 203 } |
| OLD | NEW |