summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/profiler/getter-setter-ic.js
blob: 15b0ee41ec591b74c65ea5034dbdf0beda5aba37 (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
// Ensure readSPSProfilingStack() doesn't crash with Ion
// getter/setter ICs on the stack.
function getObjects() {
    var objs = [];
    objs.push({x: 0, get prop() {
	readSPSProfilingStack();
	return ++this.x;
    }, set prop(v) {
	readSPSProfilingStack();
	this.x = v + 2;
    }});
    objs.push({x: 0, y: 0, get prop() {
	readSPSProfilingStack();
	return this.y;
    }, set prop(v) {
	readSPSProfilingStack();
	this.y = v;
    }});
    return objs;
}
function f() {
    var objs = getObjects();
    var res = 0;
    for (var i=0; i<100; i++) {
	var o = objs[i % objs.length];
	res += o.prop;
	o.prop = i;
    }
    assertEq(res, 4901);
}
enableSPSProfiling();
f();