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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 assertTrue(new type(1,2,3) instanceof type); | 310 assertTrue(new type(1,2,3) instanceof type); |
311 } | 311 } |
312 | 312 |
313 function instanceof_check2(type) { | 313 function instanceof_check2(type) { |
314 assertTrue(new type() instanceof type); | 314 assertTrue(new type() instanceof type); |
315 assertTrue(new type(5) instanceof type); | 315 assertTrue(new type(5) instanceof type); |
316 assertTrue(new type(1,2,3) instanceof type); | 316 assertTrue(new type(1,2,3) instanceof type); |
317 } | 317 } |
318 | 318 |
319 var realmBArray = Realm.eval(realmB, "Array"); | 319 var realmBArray = Realm.eval(realmB, "Array"); |
| 320 // Two calls with Array because ES6 instanceof desugars into a load of Array, |
| 321 // and load has a premonomorphic state. |
| 322 instanceof_check(Array); |
320 instanceof_check(Array); | 323 instanceof_check(Array); |
321 instanceof_check(realmBArray); | 324 instanceof_check(realmBArray); |
322 | 325 |
323 // instanceof_check2 is here because the call site goes through a state. | 326 // instanceof_check2 is here because the call site goes through a state. |
324 // Since instanceof_check(Array) was first called with the current context | 327 // Since instanceof_check(Array) was first called with the current context |
325 // Array function, it went from (uninit->Array) then (Array->megamorphic). | 328 // Array function, it went from (uninit->Array) then (Array->megamorphic). |
326 // We'll get a different state traversal if we start with realmBArray. | 329 // We'll get a different state traversal if we start with realmBArray. |
327 // It'll go (uninit->realmBArray) then (realmBArray->megamorphic). Recognize | 330 // It'll go (uninit->realmBArray) then (realmBArray->megamorphic). Recognize |
328 // that state "Array" implies an AllocationSite is present, and code is | 331 // that state "Array" implies an AllocationSite is present, and code is |
329 // configured to use it. | 332 // configured to use it. |
| 333 |
| 334 // Two calls with realmBArray because ES6 instanceof desugars into a load of |
| 335 // realmBArray, and load has a premonomorphic state. |
| 336 instanceof_check2(realmBArray); |
330 instanceof_check2(realmBArray); | 337 instanceof_check2(realmBArray); |
331 instanceof_check2(Array); | 338 instanceof_check2(Array); |
332 | 339 |
333 %OptimizeFunctionOnNextCall(instanceof_check); | 340 %OptimizeFunctionOnNextCall(instanceof_check); |
334 | 341 |
335 // No de-opt will occur because HCallNewArray wasn't selected, on account of | 342 // No de-opt will occur because HCallNewArray wasn't selected, on account of |
336 // the call site not being monomorphic to Array. | 343 // the call site not being monomorphic to Array. |
337 instanceof_check(Array); | 344 instanceof_check(Array); |
338 assertOptimized(instanceof_check); | 345 assertOptimized(instanceof_check); |
339 instanceof_check(realmBArray); | 346 instanceof_check(realmBArray); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 assertKind(elements_kind.fast_smi_only, obj[1][0]); | 467 assertKind(elements_kind.fast_smi_only, obj[1][0]); |
461 obj[0][0] = 3.5; | 468 obj[0][0] = 3.5; |
462 obj[1][0][0] = "goodbye"; | 469 obj[1][0][0] = "goodbye"; |
463 assertKind(elements_kind.fast_double, obj[0]); | 470 assertKind(elements_kind.fast_double, obj[0]); |
464 assertKind(elements_kind.fast, obj[1][0]); | 471 assertKind(elements_kind.fast, obj[1][0]); |
465 | 472 |
466 obj = get_deep_nested_literal(); | 473 obj = get_deep_nested_literal(); |
467 assertKind(elements_kind.fast_double, obj[0]); | 474 assertKind(elements_kind.fast_double, obj[0]); |
468 assertKind(elements_kind.fast, obj[1][0]); | 475 assertKind(elements_kind.fast, obj[1][0]); |
469 })(); | 476 })(); |
OLD | NEW |