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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 assertKind(elements_kind.fast_double, obj); | 143 assertKind(elements_kind.fast_double, obj); |
144 obj = fastliteralcase([3, 6, 2], 1.5); | 144 obj = fastliteralcase([3, 6, 2], 1.5); |
145 assertKind(elements_kind.fast_double, obj); | 145 assertKind(elements_kind.fast_double, obj); |
146 obj = fastliteralcase([2, 6, 3], 2); | 146 obj = fastliteralcase([2, 6, 3], 2); |
147 assertKind(elements_kind.fast_smi_only, obj); | 147 assertKind(elements_kind.fast_smi_only, obj); |
148 } | 148 } |
149 | 149 |
150 // Verify that we will not pretransition the double->fast path. | 150 // Verify that we will not pretransition the double->fast path. |
151 obj = fastliteralcase(get_standard_literal(), "elliot"); | 151 obj = fastliteralcase(get_standard_literal(), "elliot"); |
152 assertKind(elements_kind.fast, obj); | 152 assertKind(elements_kind.fast, obj); |
153 // This fails until we turn off optimistic transitions to the | 153 obj = fastliteralcase(get_standard_literal(), 3); |
154 // most general elements kind seen on keyed stores. It's a goal | 154 assertKind(elements_kind.fast, obj); |
155 // to turn it off, but for now we need it. | |
156 // obj = fastliteralcase(3); | |
157 // assertKind(elements_kind.fast_double, obj); | |
158 | 155 |
159 // Make sure this works in crankshafted code too. | 156 // Make sure this works in crankshafted code too. |
160 %OptimizeFunctionOnNextCall(get_standard_literal); | 157 %OptimizeFunctionOnNextCall(get_standard_literal); |
161 get_standard_literal(); | 158 get_standard_literal(); |
162 obj = get_standard_literal(); | 159 obj = get_standard_literal(); |
163 assertKind(elements_kind.fast_double, obj); | 160 assertKind(elements_kind.fast, obj); |
164 | 161 |
165 function fastliteralcase_smifast(value) { | 162 function fastliteralcase_smifast(value) { |
166 var literal = [1, 2, 3, 4]; | 163 var literal = [1, 2, 3, 4]; |
167 literal[0] = value; | 164 literal[0] = value; |
168 return literal; | 165 return literal; |
169 } | 166 } |
170 | 167 |
171 obj = fastliteralcase_smifast(1); | 168 obj = fastliteralcase_smifast(1); |
172 assertKind(elements_kind.fast_smi_only, obj); | 169 assertKind(elements_kind.fast_smi_only, obj); |
173 obj = fastliteralcase_smifast("carter"); | 170 obj = fastliteralcase_smifast("carter"); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 221 } |
225 | 222 |
226 // Case: new Array(length) as allocation site | 223 // Case: new Array(length) as allocation site |
227 obj = newarraycase_length_smidouble(1); | 224 obj = newarraycase_length_smidouble(1); |
228 assertKind(elements_kind.fast_smi_only, obj); | 225 assertKind(elements_kind.fast_smi_only, obj); |
229 obj = newarraycase_length_smidouble(1.5); | 226 obj = newarraycase_length_smidouble(1.5); |
230 assertKind(elements_kind.fast_double, obj); | 227 assertKind(elements_kind.fast_double, obj); |
231 obj = newarraycase_length_smidouble(2); | 228 obj = newarraycase_length_smidouble(2); |
232 assertKind(elements_kind.fast_double, obj); | 229 assertKind(elements_kind.fast_double, obj); |
233 | 230 |
234 // Try to continue the transition to fast object, but | 231 // Try to continue the transition to fast object. This won't work for |
235 // we will not pretransition from double->fast, because | 232 // constructed arrays because constructor dispatch is done on the |
236 // it may hurt performance ("poisoning"). | 233 // elements kind, and a DOUBLE array constructor won't create an allocation |
| 234 // memento. |
237 obj = newarraycase_length_smidouble("coates"); | 235 obj = newarraycase_length_smidouble("coates"); |
238 assertKind(elements_kind.fast, obj); | 236 assertKind(elements_kind.fast, obj); |
239 obj = newarraycase_length_smidouble(2.5); | 237 obj = newarraycase_length_smidouble(2); |
240 // However, because of optimistic transitions, we will | 238 assertKind(elements_kind.fast_double, obj); |
241 // transition to the most general kind of elements kind found, | |
242 // therefore I can't count on this assert yet. | |
243 // assertKind(elements_kind.fast_double, obj); | |
244 | 239 |
245 function newarraycase_length_smiobj(value) { | 240 function newarraycase_length_smiobj(value) { |
246 var a = new Array(3); | 241 var a = new Array(3); |
247 a[0] = value; | 242 a[0] = value; |
248 return a; | 243 return a; |
249 } | 244 } |
250 | 245 |
251 // Case: new Array(<length>) as allocation site, smi->fast | 246 // Case: new Array(<length>) as allocation site, smi->fast |
252 obj = newarraycase_length_smiobj(1); | 247 obj = newarraycase_length_smiobj(1); |
253 assertKind(elements_kind.fast_smi_only, obj); | 248 assertKind(elements_kind.fast_smi_only, obj); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 %ClearFunctionTypeFeedback(instanceof_check); | 368 %ClearFunctionTypeFeedback(instanceof_check); |
374 instanceof_check(Array); | 369 instanceof_check(Array); |
375 instanceof_check(Array); | 370 instanceof_check(Array); |
376 %OptimizeFunctionOnNextCall(instanceof_check); | 371 %OptimizeFunctionOnNextCall(instanceof_check); |
377 instanceof_check(Array); | 372 instanceof_check(Array); |
378 assertOptimized(instanceof_check); | 373 assertOptimized(instanceof_check); |
379 | 374 |
380 instanceof_check(realmBArray); | 375 instanceof_check(realmBArray); |
381 assertUnoptimized(instanceof_check); | 376 assertUnoptimized(instanceof_check); |
382 } | 377 } |
OLD | NEW |