aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/trace_jit.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/trace_jit.zc')
-rw-r--r--tests/programs/trace_jit.zc24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/programs/trace_jit.zc b/tests/programs/trace_jit.zc
new file mode 100644
index 0000000..e864c50
--- /dev/null
+++ b/tests/programs/trace_jit.zc
@@ -0,0 +1,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;
+}