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: --no-stress-opt --crankshaft --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 function foo(a, i) { return a[i]; } | 13 function foo(a, i) { return a[i]; } |
14 | 14 |
15 var a = ['one', , 'three']; | 15 var a = ['one', , 'three']; |
16 foo(a, 0); | 16 foo(a, 0); |
17 foo(a, 0); | 17 foo(a, 0); |
18 foo(a, 0); | 18 foo(a, 0); |
19 %OptimizeFunctionOnNextCall(foo); | 19 %OptimizeFunctionOnNextCall(foo); |
20 assertEquals(undefined, foo(a, 1)); | 20 assertEquals(undefined, foo(a, 1)); |
21 assertOptimized(foo); | 21 assertOptimized(foo); |
22 | 22 |
23 // Whereas if we disrupt the prototype chain... | 23 // Whereas if we disrupt the prototype chain... |
24 Array.prototype[1] = 'cow'; | 24 Array.prototype[1] = 'cow'; |
25 assertEquals('cow', foo(a, 1)); | 25 assertEquals('cow', foo(a, 1)); |
26 assertUnoptimized(foo); | 26 assertUnoptimized(foo); |
OLD | NEW |