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:
parent
e93006b4be
commit
2953320599
4 changed files with 362 additions and 97 deletions
|
|
@ -152,7 +152,7 @@
|
|||
((ce-macro-form? f)
|
||||
(let-values (((nm fn-form) (ce-defmacro->fn f)))
|
||||
(let ((scm (let ((ctx (make-analyze-ctx ns-name)))
|
||||
(jolt-ce-emit (jolt-ce-analyze ctx fn-form)))))
|
||||
(jolt-ce-emit (jolt-ce-run-passes (jolt-ce-analyze ctx fn-form) ctx)))))
|
||||
(loop (cdr forms)
|
||||
(cons (string-append
|
||||
"(def-var! " (ei-str-lit ns-name) " " (ei-str-lit nm) "\n "
|
||||
|
|
@ -161,13 +161,14 @@
|
|||
acc)))))
|
||||
(else
|
||||
(let* ((ctx (make-analyze-ctx ns-name))
|
||||
(scm (jolt-ce-emit (jolt-ce-analyze ctx f))))
|
||||
(scm (jolt-ce-emit (jolt-ce-run-passes (jolt-ce-analyze ctx f) ctx))))
|
||||
(loop (cdr forms) (cons scm acc)))))))))
|
||||
|
||||
;; --- the build --------------------------------------------------------------
|
||||
;; entry-ns: the app's main namespace (a string). out-path: the binary to write.
|
||||
;; mode: "dev" | "release" | "optimized" (recorded; optimization passes wired in a
|
||||
;; later stage). Deps + source roots are already applied by the caller.
|
||||
;; mode: "dev" | "release" | "optimized". Every form runs through jolt.passes/
|
||||
;; run-passes (const-fold always; inline + type inference when optimized turns on
|
||||
;; direct-linking). Deps + source roots are already applied by the caller.
|
||||
(define (build-binary entry-ns out-path mode)
|
||||
(bld-check-toolchain)
|
||||
;; 1. record app namespaces in dependency order as they finish loading.
|
||||
|
|
@ -181,9 +182,7 @@
|
|||
(error 'jolt-build (string-append "no source namespace loaded for " entry-ns
|
||||
" — is it on the source roots?")))
|
||||
;; 2. emit each app namespace. `optimized` turns on the inference + flatten
|
||||
;; + scalar-replace passes (closed world). release/dev stay on proven
|
||||
;; var-deref codegen until those passes are validated on Chez — they were
|
||||
;; dormant before `jolt build` (inline-enabled? was hardwired off).
|
||||
;; + scalar-replace passes (closed world); release/dev get const-fold only.
|
||||
(set-optimize! (string=? mode "optimized"))
|
||||
(let* ((app-strs (apply append
|
||||
(map (lambda (nf) (bld-emit-ns (car nf) (read-file-string (cdr nf))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue