Skip to content

bugc: add runtime call stack for recursion support#201

Merged
gnidan merged 1 commit intocall-returnfrom
compiler-recursion-support
Apr 2, 2026
Merged

bugc: add runtime call stack for recursion support#201
gnidan merged 1 commit intocall-returnfrom
compiler-recursion-support

Conversation

@gnidan
Copy link
Copy Markdown
Member

@gnidan gnidan commented Apr 2, 2026

Summary

  • Implement FMP-based call frames so user-defined functions can recurse. Each call allocates a frame from the free memory pointer containing saved FP, saved return PC, and locals. Returns deallocate by restoring FP and FMP.
  • Fix pre-existing SUB/DIV/MOD operand ordering bug (EVM computed right op left instead of left op right).
  • Add behavioral tests for recursion (succ/count, factorial).

Implement FMP-based call frames so functions can call themselves
recursively. Each call allocates a frame (saved FP, saved return
PC, locals) from the free memory pointer; returns deallocate by
restoring FP and FMP.

Also fixes pre-existing SUB/DIV/MOD operand ordering bug where
non-commutative operations computed right op left instead of
left op right.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-02 09:15 UTC

@gnidan gnidan merged commit c2f2236 into call-return Apr 2, 2026
4 checks passed
@gnidan gnidan deleted the compiler-recursion-support branch April 2, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant