diff options
author | tomsmeding <tom.smeding@gmail.com> | 2019-12-13 13:39:35 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2019-12-13 13:39:35 +0100 |
commit | 3595d3c75503158e4eedaedbac8e81cbbe5ae54b (patch) | |
tree | d5de3449acabdf0af4d7e361d1063d3934bb0064 /tests | |
parent | 80fee1089b659a7c7ee3a96d4cf999d369c0eb48 (diff) |
Follow caller-save convention using stack, not full state restore
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stack-test.lisp | 18 | ||||
-rw-r--r-- | tests/stack-test.out | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/stack-test.lisp b/tests/stack-test.lisp new file mode 100644 index 0000000..cabbaa3 --- /dev/null +++ b/tests/stack-test.lisp @@ -0,0 +1,18 @@ +(define g (x) (+ x 1)) + +(define f (x) + (if (<= x 0) + 0 + (let ((y (g x))) + (+ y (f (/ x 2)))))) + +; f 10 +; = 11 + f 5 +; = 11 + 6 + f 2 +; = 11 + 6 + 3 + f 1 +; = 11 + 6 + 3 + 2 +; = 22 +(print (f 10)) + +; Without Stackify, the deepest y value, i.e. 2, overwrites all y values above, +; resulting in 2 + 2 + 2 + 2 = 8. diff --git a/tests/stack-test.out b/tests/stack-test.out new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/tests/stack-test.out @@ -0,0 +1 @@ +22 |