| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 | 6 |
| 7 function f(a, b, mode) { | 7 (function () { |
| 8 if (mode) { | 8 function f(a, b, mode) { |
| 9 return a === b; | 9 if (mode) { |
| 10 } else { | 10 return a === b; |
| 11 return a === b; | 11 } else { |
| 12 return a === b; |
| 13 } |
| 12 } | 14 } |
| 13 } | |
| 14 | 15 |
| 15 // Gather type feedback for both branches. | 16 // Gather type feedback for both branches. |
| 16 f("a", "b", 1); | 17 f("a", "b", 1); |
| 17 f("c", "d", 1); | 18 f("c", "d", 1); |
| 18 f("a", "b", 0); | 19 f("a", "b", 0); |
| 19 f("c", "d", 0); | 20 f("c", "d", 0); |
| 20 | 21 |
| 21 function g(mode) { | 22 function g(mode) { |
| 22 var x = 1e10 | 0; | 23 var x = 1e10 | 0; |
| 23 f(x, x, mode); | 24 f(x, x, mode); |
| 24 } | 25 } |
| 25 | 26 |
| 26 // Gather type feedback for g, but only on one branch for f. | 27 // Gather type feedback for g, but only on one branch for f. |
| 27 g(1); | 28 g(1); |
| 28 g(1); | 29 g(1); |
| 29 %OptimizeFunctionOnNextCall(g); | 30 %OptimizeFunctionOnNextCall(g); |
| 30 // Optimize g, which inlines f. Both branches in f will see the constant. | 31 // Optimize g, which inlines f. Both branches in f will see the constant. |
| 31 g(0); | 32 g(0); |
| 33 })(); |
| 34 |
| 35 (function () { |
| 36 function f(a, b, mode) { |
| 37 if (mode) { |
| 38 return a === b; |
| 39 } else { |
| 40 return a === b; |
| 41 } |
| 42 } |
| 43 |
| 44 // Gather type feedback for both branches. |
| 45 f({ a : 1}, {b : 1}, 1); |
| 46 f({ c : 1}, {d : 1}, 1); |
| 47 f({ a : 1}, {c : 1}, 0); |
| 48 f({ b : 1}, {d : 1}, 0); |
| 49 |
| 50 function g(mode) { |
| 51 var x = 1e10 | 0; |
| 52 f(x, x, mode); |
| 53 } |
| 54 |
| 55 // Gather type feedback for g, but only on one branch for f. |
| 56 g(1); |
| 57 g(1); |
| 58 %OptimizeFunctionOnNextCall(g); |
| 59 // Optimize g, which inlines f. Both branches in f will see the constant. |
| 60 g(0); |
| 61 })(); |
| OLD | NEW |