aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/trace_jit.zc
blob: e864c50f19aad88e983477259e360c760e42ee45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace;
include rt;

// a hot path: the jits have translated down() and the loop in main long before
// the last call, so the return stack pointer comes from translated code (op 56
// reads it at the gate store, cb_r on both jits)
int down(int n, int last) {
	if (n == 0) {
		if (last) rt.trace();
		return 1;
	}
	return down(n - 1, last) + 1;
}

int main() {
	int i = 0, s = 0;
	while (i < 5000) {
		s = s + down(3, i == 4999);
		i++;
	}
	rt.put_n(s);
	rt.put_c(10);
	return 0;
}