summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/unboxed-element-hole.js
blob: c3afd13dab702e277e936ca6af0888cff07a7ed1 (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
40
41
function noElement() {
    for (var i = 0; i < 1e4; i++) {
        var obj = {length: 0};
        assertEq(obj[0], undefined);
    }
}

function noElementCheckPrototype() {
    for (var i = 0; i < 1e4; i++) {
        var obj = {length: 0};
        assertEq(obj[0], i <= 1e3 ? undefined : 1);
        if (i == 1e3) {
            Object.prototype[0] = 1;
        }
    }
    delete Object.prototype[0];
}

function elementOnPrototype() {
    Object.prototype[0] = 3;
    for (var i = 0; i < 1e4; i++) {
        var obj = {length: 0};
        assertEq(obj[0], 3);
    }
    delete Object.prototype[0];
}

function checkExpando() {
    for (var i = 0; i < 1e4; i++) {
        var obj = {length: 0};
        if (i >= 1e3) {
            obj[0] = 2;
        }
        assertEq(obj[0], i < 1e3 ? undefined : 2);
    }
}

noElement();
noElementCheckPrototype();
elementOnPrototype();
checkExpando();