forth: inline primitive calls in colon-def body (skip forth-execute-word)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -34,6 +34,10 @@
|
|||||||
;; to the prior X — matching standard Forth redefinition semantics.
|
;; to the prior X — matching standard Forth redefinition semantics.
|
||||||
;; RECURSE is the one exception: it stays late-bound against the not-yet-
|
;; RECURSE is the one exception: it stays late-bound against the not-yet-
|
||||||
;; installed current definition.
|
;; installed current definition.
|
||||||
|
;; Inline primitive calls: skip the `forth-execute-word` indirection by
|
||||||
|
;; appending the word's body fn directly (forth-execute-word body
|
||||||
|
;; reduces to `((get w "body") state)`, which is exactly what the body
|
||||||
|
;; fn already is). Saves one frame per call op in every colon-def.
|
||||||
(define
|
(define
|
||||||
forth-compile-call
|
forth-compile-call
|
||||||
(fn
|
(fn
|
||||||
@@ -43,9 +47,7 @@
|
|||||||
(if
|
(if
|
||||||
(nil? w)
|
(nil? w)
|
||||||
(forth-error state (str name " ?"))
|
(forth-error state (str name " ?"))
|
||||||
(let
|
(forth-def-append! state (get w "body"))))))
|
||||||
((op (fn (s) (forth-execute-word s w))))
|
|
||||||
(forth-def-append! state op))))))
|
|
||||||
|
|
||||||
(define
|
(define
|
||||||
forth-compile-recurse
|
forth-compile-recurse
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"source": "gerryjackson/forth2012-test-suite src/core.fr",
|
"source": "gerryjackson/forth2012-test-suite src/core.fr",
|
||||||
"generated_at": "2026-04-25T03:32:23Z",
|
"generated_at": "2026-04-25T04:00:01Z",
|
||||||
"chunks_available": 638,
|
"chunks_available": 638,
|
||||||
"chunks_fed": 638,
|
"chunks_fed": 638,
|
||||||
"total": 638,
|
"total": 638,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
| percent | 96% |
|
| percent | 96% |
|
||||||
|
|
||||||
- **Source**: `gerryjackson/forth2012-test-suite` `src/core.fr`
|
- **Source**: `gerryjackson/forth2012-test-suite` `src/core.fr`
|
||||||
- **Generated**: 2026-04-25T03:32:23Z
|
- **Generated**: 2026-04-25T04:00:01Z
|
||||||
- **Note**: completed
|
- **Note**: completed
|
||||||
|
|
||||||
A "chunk" is any preprocessed segment ending at a `}T` (every Hayes test
|
A "chunk" is any preprocessed segment ending at a `}T` (every Hayes test
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ Representation:
|
|||||||
- [x] Target: 100% Hayes Core (97% achieved — remaining 5 errors all in `GI5`'s multi-`WHILE`-per-`BEGIN` non-standard pattern, plus one stuck `dict-set!` chunk and 14 numeric-edge fails)
|
- [x] Target: 100% Hayes Core (97% achieved — remaining 5 errors all in `GI5`'s multi-`WHILE`-per-`BEGIN` non-standard pattern, plus one stuck `dict-set!` chunk and 14 numeric-edge fails)
|
||||||
|
|
||||||
### Phase 6 — speed
|
### Phase 6 — speed
|
||||||
- [ ] Inline primitive calls during compile (skip dict lookup)
|
- [x] Inline primitive calls during compile (skip dict lookup)
|
||||||
- [ ] Tail-call optimise colon-def endings
|
- [ ] Tail-call optimise colon-def endings
|
||||||
- [ ] JIT cooperation: mark compiled colon-defs as VM-eligible
|
- [ ] JIT cooperation: mark compiled colon-defs as VM-eligible
|
||||||
|
|
||||||
@@ -106,6 +106,17 @@ Representation:
|
|||||||
|
|
||||||
_Newest first._
|
_Newest first._
|
||||||
|
|
||||||
|
- **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
|
||||||
|
`(fn (s) (forth-execute-word s w))`. `forth-execute-word body`
|
||||||
|
reduces to `((get w "body") state)`, so the wrapper added an
|
||||||
|
extra closure + `get` per call op for no behavioural gain. Same
|
||||||
|
early-binding semantics: the body fn is captured at compile time,
|
||||||
|
so later redefinitions of the same name don't retroactively
|
||||||
|
change existing definitions. All 306 internal tests still green;
|
||||||
|
Hayes Core stays at 618/638. Pure optimisation.
|
||||||
|
|
||||||
- **Phase 5 close — `\` no-op + POSTPONE-immediate split + `>NUMBER` +
|
- **Phase 5 close — `\` no-op + POSTPONE-immediate split + `>NUMBER` +
|
||||||
`DOES>`; Hayes 486→618 (97%).** Big closing-out iteration.
|
`DOES>`; Hayes 486→618 (97%).** Big closing-out iteration.
|
||||||
Made `\` IMMEDIATE so `POSTPONE \` (Hayes' IFFLOORED/IFSYM gate)
|
Made `\` IMMEDIATE so `POSTPONE \` (Hayes' IFFLOORED/IFSYM gate)
|
||||||
|
|||||||
Reference in New Issue
Block a user