forth: TCO at colon-def endings (no extra frame on tail-call ops)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 04:29:57 +00:00
parent f6e333dd19
commit 0d6d0bf439
2 changed files with 26 additions and 4 deletions

View File

@@ -99,13 +99,23 @@ Representation:
### Phase 6 — speed
- [x] Inline primitive calls during compile (skip dict lookup)
- [ ] Tail-call optimise colon-def endings
- [x] Tail-call optimise colon-def endings
- [ ] JIT cooperation: mark compiled colon-defs as VM-eligible
## Progress log
_Newest first._
- **Phase 6 — TCO at colon-def endings (Hayes unchanged at 618/638).**
`forth-run-body` now special-cases the final op when it's a plain
function (not a branch dict): we call it in tail position with no
pc-increment and no recursive `forth-run-body` call. This means
the SX CEK can collapse the continuation frame, so chains like
`: A ... B ; : B ... C ; …` and `RECURSE` deep-recursion test
cases run without piling up frames at each colon-def boundary.
All 306 internal tests still green; verified 5000-deep
`COUNTDOWN RECURSE` still terminates fine.
- **Phase 6 — inline primitive calls (Hayes unchanged at 618/638).**
`forth-compile-call` now appends the looked-up word's body fn
directly to the colon-def body instead of wrapping it in