OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 function assertKind(expected, obj, name_opt) { | 103 function assertKind(expected, obj, name_opt) { |
104 if (!support_smi_only_arrays && | 104 if (!support_smi_only_arrays && |
105 expected == elements_kind.fast_smi_only) { | 105 expected == elements_kind.fast_smi_only) { |
106 expected = elements_kind.fast; | 106 expected = elements_kind.fast; |
107 } | 107 } |
108 assertEquals(expected, getKind(obj), name_opt); | 108 assertEquals(expected, getKind(obj), name_opt); |
109 } | 109 } |
110 | 110 |
| 111 %NeverOptimizeFunction(construct_smis); |
111 function construct_smis() { | 112 function construct_smis() { |
112 %NeverOptimize(); | |
113 var a = [0, 0, 0]; | 113 var a = [0, 0, 0]; |
114 a[0] = 0; // Send the COW array map to the steak house. | 114 a[0] = 0; // Send the COW array map to the steak house. |
115 assertKind(elements_kind.fast_smi_only, a); | 115 assertKind(elements_kind.fast_smi_only, a); |
116 return a; | 116 return a; |
117 } | 117 } |
118 | 118 |
| 119 %NeverOptimizeFunction(construct_doubles); |
119 function construct_doubles() { | 120 function construct_doubles() { |
120 %NeverOptimize(); | |
121 var a = construct_smis(); | 121 var a = construct_smis(); |
122 a[0] = 1.5; | 122 a[0] = 1.5; |
123 assertKind(elements_kind.fast_double, a); | 123 assertKind(elements_kind.fast_double, a); |
124 return a; | 124 return a; |
125 } | 125 } |
126 | 126 |
| 127 %NeverOptimizeFunction(convert_mixed); |
127 function convert_mixed(array, value, kind) { | 128 function convert_mixed(array, value, kind) { |
128 %NeverOptimize(); | |
129 array[1] = value; | 129 array[1] = value; |
130 assertKind(kind, array); | 130 assertKind(kind, array); |
131 assertEquals(value, array[1]); | 131 assertEquals(value, array[1]); |
132 } | 132 } |
133 | 133 |
134 function test1() { | 134 function test1() { |
135 if (!support_smi_only_arrays) return; | 135 if (!support_smi_only_arrays) return; |
136 | 136 |
137 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will | 137 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will |
138 // transition to FAST directly). | 138 // transition to FAST directly). |
(...skipping 13 matching lines...) Expand all Loading... |
152 assertTrue(%HaveSameMap(smis, doubles)); | 152 assertTrue(%HaveSameMap(smis, doubles)); |
153 } | 153 } |
154 | 154 |
155 test1(); | 155 test1(); |
156 gc(); // clear IC state | 156 gc(); // clear IC state |
157 test1(); | 157 test1(); |
158 gc(); // clear IC state | 158 gc(); // clear IC state |
159 %OptimizeFunctionOnNextCall(test1); | 159 %OptimizeFunctionOnNextCall(test1); |
160 test1(); | 160 test1(); |
161 gc(); // clear IC state | 161 gc(); // clear IC state |
OLD | NEW |