blob: d72875a2968a1ee03a8be372d7de779b71429d66 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7(function () {
8 function f(a, b, mode) {
9 if (mode) {
10 return a === b;
11 } else {
12 return a === b;
13 }
14 }
15
16 // Gather type feedback for both branches.
17 f("a", "b", 1);
18 f("c", "d", 1);
19 f("a", "b", 0);
20 f("c", "d", 0);
21
22 function g(mode) {
23 var x = 1e10 | 0;
24 f(x, x, mode);
25 }
26
27 // Gather type feedback for g, but only on one branch for f.
28 g(1);
29 g(1);
30 %OptimizeFunctionOnNextCall(g);
31 // Optimize g, which inlines f. Both branches in f will see the constant.
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})();