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 27 matching lines...) Expand all Loading... |
38 if (support_smi_only_arrays) { | 38 if (support_smi_only_arrays) { |
39 print("Tests include smi-only arrays."); | 39 print("Tests include smi-only arrays."); |
40 } else { | 40 } else { |
41 print("Tests do NOT include smi-only arrays."); | 41 print("Tests do NOT include smi-only arrays."); |
42 } | 42 } |
43 | 43 |
44 // 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. |
45 function get(foo) { return foo; } // Used to generate dynamic values. | 45 function get(foo) { return foo; } // Used to generate dynamic values. |
46 | 46 |
47 function array_literal_test() { | 47 function array_literal_test() { |
| 48 var c0 = [1, 2, get(3.5)]; |
| 49 assertTrue(%HasFastDoubleElements(c0)); |
| 50 assertEquals(3.5, c0[2]); |
| 51 assertEquals(2, c0[1]); |
| 52 assertEquals(1, c0[0]); |
| 53 |
48 var a0 = [1, 2, 3]; | 54 var a0 = [1, 2, 3]; |
49 assertTrue(%HasFastSmiOnlyElements(a0)); | 55 assertTrue(%HasFastSmiOnlyElements(a0)); |
50 var a1 = [get(1), get(2), get(3)]; | 56 var a1 = [get(1), get(2), get(3)]; |
51 assertTrue(%HasFastSmiOnlyElements(a1)); | 57 assertTrue(%HasFastSmiOnlyElements(a1)); |
52 | 58 |
53 var b0 = [1, 2, get("three")]; | 59 var b0 = [1, 2, get("three")]; |
54 assertTrue(%HasFastElements(b0)); | 60 assertTrue(%HasFastElements(b0)); |
55 var b1 = [get(1), get(2), get("three")]; | 61 var b1 = [get(1), get(2), get("three")]; |
56 assertTrue(%HasFastElements(b1)); | 62 assertTrue(%HasFastElements(b1)); |
57 | 63 |
58 var c0 = [1, 2, get(3.5)]; | |
59 assertTrue(%HasFastDoubleElements(c0)); | |
60 assertEquals(3.5, c0[2]); | |
61 assertEquals(2, c0[1]); | |
62 assertEquals(1, c0[0]); | |
63 | |
64 var c1 = [1, 2, 3.5]; | 64 var c1 = [1, 2, 3.5]; |
65 assertTrue(%HasFastDoubleElements(c1)); | 65 assertTrue(%HasFastDoubleElements(c1)); |
66 assertEquals(3.5, c1[2]); | 66 assertEquals(3.5, c1[2]); |
67 assertEquals(2, c1[1]); | 67 assertEquals(2, c1[1]); |
68 assertEquals(1, c1[0]); | 68 assertEquals(1, c1[0]); |
69 | 69 |
70 var c2 = [get(1), get(2), get(3.5)]; | 70 var c2 = [get(1), get(2), get(3.5)]; |
71 assertTrue(%HasFastDoubleElements(c2)); | 71 assertTrue(%HasFastDoubleElements(c2)); |
72 assertEquals(3.5, c2[2]); | 72 assertEquals(3.5, c2[2]); |
73 assertEquals(2, c2[1]); | 73 assertEquals(2, c2[1]); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 assertEquals(1, array[1]); | 201 assertEquals(1, array[1]); |
202 assertEquals(foo, array[2]); | 202 assertEquals(foo, array[2]); |
203 } | 203 } |
204 | 204 |
205 (function literals_after_osr() { | 205 (function literals_after_osr() { |
206 var color = [0]; | 206 var color = [0]; |
207 // Trigger OSR. | 207 // Trigger OSR. |
208 while (%GetOptimizationStatus(literals_after_osr) == 2) {} | 208 while (%GetOptimizationStatus(literals_after_osr) == 2) {} |
209 return [color[0]]; | 209 return [color[0]]; |
210 })(); | 210 })(); |
OLD | NEW |