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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 28 // Flags: --allow-natives-syntax |
29 | 29 |
30 // IC and Crankshaft support for smi-only elements in dynamic array literals. | 30 // IC and Crankshaft support for smi-only elements in dynamic array literals. |
31 function get(foo) { return foo; } // Used to generate dynamic values. | 31 function get(foo) { return foo; } // Used to generate dynamic values. |
32 | 32 |
| 33 var __sequence = 0; |
33 function array_natives_test() { | 34 function array_natives_test() { |
34 | 35 |
35 // Ensure small array literals start in specific element kind mode. | 36 // Ensure small array literals start in specific element kind mode. |
36 assertTrue(%HasFastSmiElements([])); | 37 assertTrue(%HasFastSmiElements([])); |
37 assertTrue(%HasFastSmiElements([1])); | 38 assertTrue(%HasFastSmiElements([1])); |
38 assertTrue(%HasFastSmiElements([1,2])); | 39 assertTrue(%HasFastSmiElements([1,2])); |
39 assertTrue(%HasFastDoubleElements([1.1])); | 40 assertTrue(%HasFastDoubleElements([1.1])); |
40 assertTrue(%HasFastDoubleElements([1.1,2])); | 41 assertTrue(%HasFastDoubleElements([1.1,2])); |
41 | 42 |
42 // This code exists to eliminate the learning influence of AllocationSites | 43 // This code exists to eliminate the learning influence of AllocationSites |
43 // on the following tests. | 44 // on the following tests. |
44 var __sequence = 0; | |
45 function make_array_string(literal) { | 45 function make_array_string(literal) { |
46 this.__sequence = this.__sequence + 1; | 46 this.__sequence = this.__sequence + 1; |
47 return "/* " + this.__sequence + " */ " + literal; | 47 return "/* " + this.__sequence + " */ " + literal; |
48 } | 48 } |
49 function make_array(literal) { | 49 function make_array(literal) { |
50 return eval(make_array_string(literal)); | 50 return eval(make_array_string(literal)); |
51 } | 51 } |
52 | 52 |
53 // Push | 53 // Push |
54 var a0 = make_array("[1, 2, 3]"); | 54 var a0 = make_array("[1, 2, 3]"); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 assertEquals(4, a4.unshift(1.1)); | 299 assertEquals(4, a4.unshift(1.1)); |
300 assertTrue(%HasFastObjectElements(a4)); | 300 assertTrue(%HasFastObjectElements(a4)); |
301 assertEquals([1.1,{},2,3], a4); | 301 assertEquals([1.1,{},2,3], a4); |
302 } | 302 } |
303 | 303 |
304 for (var i = 0; i < 3; i++) { | 304 for (var i = 0; i < 3; i++) { |
305 array_natives_test(); | 305 array_natives_test(); |
306 } | 306 } |
307 %OptimizeFunctionOnNextCall(array_natives_test); | 307 %OptimizeFunctionOnNextCall(array_natives_test); |
308 array_natives_test(); | 308 array_natives_test(); |
OLD | NEW |