OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax |
| 6 // Flags: --nostress-opt |
| 7 |
| 8 // --nostress-opt is specified because the test corrupts the "pristine" |
| 9 // array prototype chain by storing an element, and this is tracked |
| 10 // per-isolate. A subsequent stress run would send the load generic, |
| 11 // and no more deoptimizations of foo would occur. |
| 12 |
| 13 function foo(a, i) { return a[i]; } |
| 14 |
| 15 var a = ['one', , 'three']; |
| 16 foo(a, 0); |
| 17 foo(a, 0); |
| 18 foo(a, 0); |
| 19 %OptimizeFunctionOnNextCall(foo); |
| 20 assertEquals(undefined, foo(a, 1)); |
| 21 assertOptimized(foo); |
| 22 |
| 23 // Whereas if we disrupt the prototype chain... |
| 24 Array.prototype[1] = 'cow'; |
| 25 assertEquals('cow', foo(a, 1)); |
| 26 assertUnoptimized(foo); |
OLD | NEW |