Chez Phase 3 inc6a: zero-Janet spine (analyzer + emitter on Chez), macro-free
Cross-compile jolt.ir + jolt.analyzer + jolt.backend-scheme to Scheme def-var! forms via the existing Janet emit pipeline (driver/emit-compiler-image) and run them ON CHEZ over a Scheme jolt.host impl. A macro-free Clojure expression now compiles and runs with no Janet in the loop: read (reader.ss) -> analyze (jolt.analyzer on Chez) -> IR -> emit (jolt.backend-scheme on Chez) -> eval. host/chez/host-contract.ss is the jolt.host contract on Chez (the portable seam the cross-compiled analyzer/emitter call): form-* over the Chez reader's forms, resolve-global/compile-ns/host-intern!/late-bind? over the var-cell registry. ctx is an opaque record carrying the compile ns. Native-op names are declare-var!'d into clojure.core so +, *, <, ... classify as :var and the emitter's native-op path lowers them. form-macro? is a #f stub and macro expansion / syntax-quote / record hints are stubs for inc6b (runtime macros, jolt-r8ku). host/chez/compile-eval.ss is the spine entry (read-string -> analyze -> emit -> eval). driver gains emit-compiler-image / ensure-compiler-image (image caching) and program-zero-janet / eval-zero-janet. Two bugs fixed in the keeper, not reproduced: - the Chez reader stores an unqualified symbol's ns as #f, but the analyzer tests (nil? ns); hc-sym-ns normalizes #f/'() -> jolt-nil. Without it every handled special (if/do/fn*) misanalyzed as a plain invoke. - char (int->char) was missing from clojure.core on Chez; the emitter's chez-str-lit needs it for keyword/string consts. Added jolt-char to converters.ss. Gate: test/chez/spine-test.janet 15/15 (Chez-hosted analyzer value == Janet-hosted oracle through the same emitter/RT; only the analysis host differs). Full Janet gate green (150 files). driver.janet is in the prelude fingerprint so the cache key moved; prelude content is unchanged. jolt-chez fingerprint/ensure-prelude made public for the test harness.
This commit is contained in:
parent
c47ae7fd22
commit
c2d977cadf
6 changed files with 398 additions and 2 deletions
|
|
@ -11,7 +11,7 @@
|
|||
(import ../../src/jolt/api :as api)
|
||||
(import ./driver :as d)
|
||||
|
||||
(defn- fingerprint []
|
||||
(defn fingerprint []
|
||||
# Hash the inputs that shape the prelude: the core tiers + the emitter + the
|
||||
# Chez RT shims. Any change invalidates the cached prelude.
|
||||
(def parts @[])
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
(array/push parts (slurp f)))
|
||||
(string/slice (string (hash (string/join parts))) 0))
|
||||
|
||||
(defn- ensure-prelude [ctx]
|
||||
(defn ensure-prelude [ctx]
|
||||
(def dir (or (os/getenv "JOLT_IMAGE_CACHE_DIR") (os/getenv "TMPDIR") "/tmp"))
|
||||
(def path (string dir "/jolt-chez-prelude-" (fingerprint) ".ss"))
|
||||
(unless (os/stat path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue