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
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7var m = (function() {
8  "use asm";
9  function f(x) {
10    return x < 0;
11  }
12  function g(x) {
13    return 0 < x;
14  }
15  return { f: f, g: g };
16})();
17var f = m.f;
18var g = m.g;
19
20var counter = 0;
21
22function deopt(f) {
23  return {
24    toString : function() {
25      %DeoptimizeFunction(f);
26      counter++;
27      return "2";
28    }
29  };
30}
31
32assertEquals(false, f(deopt(f)));
33assertEquals(1, counter);
34
35assertEquals(true, g(deopt(g)));
36assertEquals(2, counter);
37
38%OptimizeFunctionOnNextCall(f);
39assertEquals(false, f(deopt(f)));
40assertEquals(3, counter);
41
42%OptimizeFunctionOnNextCall(g);
43assertEquals(true, g(deopt(g)));
44assertEquals(4, counter);
45