| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return literal; | 168 return literal; |
| 169 } | 169 } |
| 170 | 170 |
| 171 obj = fastliteralcase_smifast(1); | 171 obj = fastliteralcase_smifast(1); |
| 172 assertKind(elements_kind.fast_smi_only, obj); | 172 assertKind(elements_kind.fast_smi_only, obj); |
| 173 obj = fastliteralcase_smifast("carter"); | 173 obj = fastliteralcase_smifast("carter"); |
| 174 assertKind(elements_kind.fast, obj); | 174 assertKind(elements_kind.fast, obj); |
| 175 obj = fastliteralcase_smifast(2); | 175 obj = fastliteralcase_smifast(2); |
| 176 assertKind(elements_kind.fast, obj); | 176 assertKind(elements_kind.fast, obj); |
| 177 | 177 |
| 178 // Case: make sure transitions from packed to holey are tracked |
| 179 function fastliteralcase_smiholey(index, value) { |
| 180 var literal = [1, 2, 3, 4]; |
| 181 literal[index] = value; |
| 182 return literal; |
| 183 } |
| 184 |
| 185 obj = fastliteralcase_smiholey(5, 1); |
| 186 assertKind(elements_kind.fast_smi_only, obj); |
| 187 assertHoley(obj); |
| 188 obj = fastliteralcase_smiholey(0, 1); |
| 189 assertKind(elements_kind.fast_smi_only, obj); |
| 190 assertHoley(obj); |
| 191 |
| 178 function newarraycase_smidouble(value) { | 192 function newarraycase_smidouble(value) { |
| 179 var a = new Array(); | 193 var a = new Array(); |
| 180 a[0] = value; | 194 a[0] = value; |
| 181 return a; | 195 return a; |
| 182 } | 196 } |
| 183 | 197 |
| 184 // Case: new Array() as allocation site, smi->double | 198 // Case: new Array() as allocation site, smi->double |
| 185 obj = newarraycase_smidouble(1); | 199 obj = newarraycase_smidouble(1); |
| 186 assertKind(elements_kind.fast_smi_only, obj); | 200 assertKind(elements_kind.fast_smi_only, obj); |
| 187 obj = newarraycase_smidouble(1.5); | 201 obj = newarraycase_smidouble(1.5); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 return a; | 275 return a; |
| 262 } | 276 } |
| 263 | 277 |
| 264 obj = newarraycase_list_smiobj(1); | 278 obj = newarraycase_list_smiobj(1); |
| 265 assertKind(elements_kind.fast_smi_only, obj); | 279 assertKind(elements_kind.fast_smi_only, obj); |
| 266 obj = newarraycase_list_smiobj("coates"); | 280 obj = newarraycase_list_smiobj("coates"); |
| 267 assertKind(elements_kind.fast, obj); | 281 assertKind(elements_kind.fast, obj); |
| 268 obj = newarraycase_list_smiobj(2); | 282 obj = newarraycase_list_smiobj(2); |
| 269 assertKind(elements_kind.fast, obj); | 283 assertKind(elements_kind.fast, obj); |
| 270 | 284 |
| 285 // Case: array constructor calls with out of date feedback. |
| 286 // The boilerplate should incorporate all feedback, but the input array |
| 287 // should be minimally transitioned based on immediate need. |
| 288 (function() { |
| 289 function foo(i) { |
| 290 // We have two cases, one for literals one for constructed arrays. |
| 291 var a = (i == 0) |
| 292 ? [1, 2, 3] |
| 293 : new Array(1, 2, 3); |
| 294 return a; |
| 295 } |
| 296 |
| 297 for (i = 0; i < 2; i++) { |
| 298 a = foo(i); |
| 299 b = foo(i); |
| 300 b[5] = 1; // boilerplate goes holey |
| 301 assertHoley(foo(i)); |
| 302 a[0] = 3.5; // boilerplate goes holey double |
| 303 assertKind(elements_kind.fast_double, a); |
| 304 assertNotHoley(a); |
| 305 c = foo(i); |
| 306 assertKind(elements_kind.fast_double, c); |
| 307 assertHoley(c); |
| 308 } |
| 309 })(); |
| 310 |
| 271 function newarraycase_onearg(len, value) { | 311 function newarraycase_onearg(len, value) { |
| 272 var a = new Array(len); | 312 var a = new Array(len); |
| 273 a[0] = value; | 313 a[0] = value; |
| 274 return a; | 314 return a; |
| 275 } | 315 } |
| 276 | 316 |
| 277 obj = newarraycase_onearg(5, 3.5); | 317 obj = newarraycase_onearg(5, 3.5); |
| 278 assertKind(elements_kind.fast_double, obj); | 318 assertKind(elements_kind.fast_double, obj); |
| 279 obj = newarraycase_onearg(10, 5); | 319 obj = newarraycase_onearg(10, 5); |
| 280 assertKind(elements_kind.fast_double, obj); | 320 assertKind(elements_kind.fast_double, obj); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 %ClearFunctionTypeFeedback(instanceof_check); | 373 %ClearFunctionTypeFeedback(instanceof_check); |
| 334 instanceof_check(Array); | 374 instanceof_check(Array); |
| 335 instanceof_check(Array); | 375 instanceof_check(Array); |
| 336 %OptimizeFunctionOnNextCall(instanceof_check); | 376 %OptimizeFunctionOnNextCall(instanceof_check); |
| 337 instanceof_check(Array); | 377 instanceof_check(Array); |
| 338 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 378 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 339 | 379 |
| 340 instanceof_check(realmBArray); | 380 instanceof_check(realmBArray); |
| 341 assertTrue(1 != %GetOptimizationStatus(instanceof_check)); | 381 assertTrue(1 != %GetOptimizationStatus(instanceof_check)); |
| 342 } | 382 } |
| OLD | NEW |