summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/getprop-idempotent-cache-2.js
blob: 8da24537d9ad02a88bbd26468ce8168012db2ff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function f(o) {
    var res = 0;
    for (var i=0; i<110; i++) {
        res += o.x;
    }
    return res;
}

function O(x) {
    if ([].length == 0) // Thwart definite slot analysis.
        this.x = 10;
}

var o = new O(true);
f(o);

// Add a getter, this should invalidate the script containing the idempotent cache.
var res = 0;
o.__defineGetter__("x", function() { res++; });
f(o);
assertEq(res, 110);