Wire the optimization pass pipeline into compile + build

The fold/inline/types passes and the jolt.passes façade were baked into neither
seed half and never invoked: compile-eval and build went analyze -> emit directly,
and `jolt build --opt` flipped an optimize flag that nothing consumed.

- Compile the passes into the image (emit-image manifest): fold, inline, types,
  then the jolt.passes façade, after jolt.ir.
- compile-eval and build.ss now run jolt.passes/run-passes between analyze and
  emit. Off the direct-link path it is a pure const-fold; `jolt build --opt`
  turns on inline + flatten + scalar-replace + type inference (it sets
  hc-optimize?, which inline-enabled? reads).
- The seed minter (emit-image) stays analyze -> emit, so the seed is built
  un-optimized and the self-host fixpoint is unaffected.

build-smoke already exercised --opt; it now actually optimizes and still matches
the release binary's output. Corpus floor and the fixpoint are green.
This commit is contained in:
Yogthos 2026-06-23 01:14:14 -04:00
parent e93006b4be
commit 2953320599
4 changed files with 362 additions and 97 deletions

View file

@ -11,6 +11,10 @@
(define jolt-ce-analyze (var-deref "jolt.analyzer" "analyze"))
(define jolt-ce-emit (var-deref "jolt.backend-scheme" "emit"))
;; jolt.passes/run-passes: const-fold every analyzed form, plus inline + type
;; inference when the unit opted into direct-linking (jolt build --opt). Off that
;; path it is a pure const-fold. Loaded from the compiler image (jolt.passes).
(define jolt-ce-run-passes (var-deref "jolt.passes" "run-passes"))
(define jolt-ce-read (var-deref "clojure.core" "read-string"))
;; The spine ALWAYS runs with the full clojure.core prelude loaded, so a clojure.*
@ -59,7 +63,7 @@
(define (jolt-analyze-emit-form form ns)
(ce-scan-requires! form ns)
(let* ((ctx (make-analyze-ctx ns))
(ir (jolt-ce-analyze ctx form)))
(ir (jolt-ce-run-passes (jolt-ce-analyze ctx form) ctx)))
(jolt-ce-emit ir)))
;; --- runtime defmacro -------------------------------------------------------