summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/inlined-accessor-exc-bailout.js
blob: 9346ac65bbb3f056f47e53606945a130cb076c4b (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
42
43
44
45
// |jit-test| --fast-warmup

// Tests for exception bailout from inlined getter/setter.

function throwingGetter() {
    var o = {};
    var count = 0;
    Object.defineProperty(o, "getter", {get: function() {
        if (count++ === 195) {
            throw 1;
        }
    }});
    var ex = null;
    try {
        for (var i = 0; i < 200; i++) {
            o.getter;
        }
    } catch(e) {
        ex = e;
    }
    assertEq(ex, 1);
    assertEq(count, 196);
}
throwingGetter();

function throwingSetter() {
    var o = {};
    var count = 0;
    Object.defineProperty(o, "setter", {set: function(v) {
        if (count++ === 195) {
            throw 1;
        }
    }});
    var ex = null;
    try {
        for (var i = 0; i < 200; i++) {
            o.setter = i;
        }
    } catch(e) {
        ex = e;
    }
    assertEq(ex, 1);
    assertEq(count, 196);
}
throwingSetter();