OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 |
| 7 var f1 = function() { while (1) { } } |
| 8 |
| 9 function g1() { |
| 10 var s = "hey"; |
| 11 f1 = function() { return true; } |
| 12 if (f1()) { return s; } |
| 13 } |
| 14 |
| 15 %OptimizeFunctionOnNextCall(g1); |
| 16 assertEquals("hey", g1()); |
| 17 |
| 18 var f2 = function() { do { } while (1); } |
| 19 |
| 20 function g2() { |
| 21 var s = "hey"; |
| 22 f2 = function() { return true; } |
| 23 if (f2()) { return s; } |
| 24 } |
| 25 |
| 26 %OptimizeFunctionOnNextCall(g2); |
| 27 assertEquals("hey", g2()); |
| 28 |
| 29 var f3 = function() { for (;;); } |
| 30 |
| 31 function g3() { |
| 32 var s = "hey"; |
| 33 f3 = function() { return true; } |
| 34 if (f3()) { return s; } |
| 35 } |
| 36 |
| 37 %OptimizeFunctionOnNextCall(g3); |
| 38 assertEquals("hey", g3()); |
| 39 |
| 40 var f4 = function() { for (;;); } |
| 41 |
| 42 function g4() { |
| 43 var s = "hey"; |
| 44 f4 = function() { return true; } |
| 45 while (f4()) { return s; } |
| 46 } |
| 47 |
| 48 %OptimizeFunctionOnNextCall(g4); |
| 49 assertEquals("hey", g4()); |
OLD | NEW |