summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/bug860838-1.js
blob: 087ae9841eecf6574b1dd37a823a82068358059c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var counter = 0;
function inc() { return counter++ }
var imp = { inc:inc };

function FFI1(stdlib, foreign) {
    "use asm";

    var inc = foreign.inc;

    function g() {
      return inc()|0
    }

    return g
}

function FFI2(stdlib, foreign) {
    "use asm";

    var inc=foreign.inc;

    function g() {
      inc()
    }

    return g
}


var f = FFI2(this, imp);     // produces AOT-compiled version
f()
assertEq(counter, 1);

var f = FFI1(this, imp);     // produces AOT-compiled version

assertEq(f(), 1);
assertEq(counter, 2);
assertEq(f(), 2);
assertEq(counter, 3);