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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // Ensure small array literals start in specific element kind mode. | 51 // Ensure small array literals start in specific element kind mode. |
52 assertTrue(%HasFastSmiElements([])); | 52 assertTrue(%HasFastSmiElements([])); |
53 assertTrue(%HasFastSmiElements([1])); | 53 assertTrue(%HasFastSmiElements([1])); |
54 assertTrue(%HasFastSmiElements([1,2])); | 54 assertTrue(%HasFastSmiElements([1,2])); |
55 assertTrue(%HasFastDoubleElements([1.1])); | 55 assertTrue(%HasFastDoubleElements([1.1])); |
56 assertTrue(%HasFastDoubleElements([1.1,2])); | 56 assertTrue(%HasFastDoubleElements([1.1,2])); |
57 | 57 |
58 // Push | 58 // Push |
59 var a0 = [1, 2, 3]; | 59 var a0 = [1, 2, 3]; |
60 assertTrue(%HasFastSmiElements(a0)); | 60 if (%HasFastSmiElements(a0)) { |
61 a0.push(4); | 61 assertTrue(%HasFastSmiElements(a0)); |
62 assertTrue(%HasFastSmiElements(a0)); | 62 a0.push(4); |
63 a0.push(1.3); | 63 assertTrue(%HasFastSmiElements(a0)); |
64 assertTrue(%HasFastDoubleElements(a0)); | 64 a0.push(1.3); |
65 a0.push(1.5); | 65 assertTrue(%HasFastDoubleElements(a0)); |
66 assertTrue(%HasFastDoubleElements(a0)); | 66 a0.push(1.5); |
67 a0.push({}); | 67 assertTrue(%HasFastDoubleElements(a0)); |
68 assertTrue(%HasFastObjectElements(a0)); | 68 a0.push({}); |
69 a0.push({}); | 69 assertTrue(%HasFastObjectElements(a0)); |
70 assertTrue(%HasFastObjectElements(a0)); | 70 a0.push({}); |
| 71 assertTrue(%HasFastObjectElements(a0)); |
| 72 } else { |
| 73 assertTrue(%HasFastObjectElements(a0)); |
| 74 a0.push(4); |
| 75 a0.push(1.3); |
| 76 a0.push(1.5); |
| 77 a0.push({}); |
| 78 a0.push({}); |
| 79 assertTrue(%HasFastObjectElements(a0)); |
| 80 } |
71 assertEquals([1,2,3,4,1.3,1.5,{},{}], a0); | 81 assertEquals([1,2,3,4,1.3,1.5,{},{}], a0); |
72 | 82 |
73 // Concat | 83 // Concat |
74 var a1; | 84 var a1; |
75 a1 = [1,2,3].concat([]); | 85 a1 = [1,2,3].concat([]); |
76 assertTrue(%HasFastSmiElements(a1)); | 86 assertTrue(%HasFastSmiElements(a1)); |
77 assertEquals([1,2,3], a1); | 87 assertEquals([1,2,3], a1); |
78 a1 = [1,2,3].concat([4,5,6]); | 88 a1 = [1,2,3].concat([4,5,6]); |
79 assertTrue(%HasFastSmiElements(a1)); | 89 assertTrue(%HasFastSmiElements(a1)); |
80 assertEquals([1,2,3,4,5,6], a1); | 90 assertEquals([1,2,3,4,5,6], a1); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 assertEquals([1.1,{},2,3], a4); | 308 assertEquals([1.1,{},2,3], a4); |
299 } | 309 } |
300 | 310 |
301 if (support_smi_only_arrays) { | 311 if (support_smi_only_arrays) { |
302 for (var i = 0; i < 3; i++) { | 312 for (var i = 0; i < 3; i++) { |
303 array_natives_test(); | 313 array_natives_test(); |
304 } | 314 } |
305 %OptimizeFunctionOnNextCall(array_natives_test); | 315 %OptimizeFunctionOnNextCall(array_natives_test); |
306 array_natives_test(); | 316 array_natives_test(); |
307 } | 317 } |
OLD | NEW |