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