Chez Phase 1 (increment 3j): assemble the clojure.core prelude, -e-capable jolt-chez
Emit every non-macro clojure.core form through the live analyzer -> Chez emit pipeline as a def-var! prelude (prelude mode, tier dependency order), load it before a user expression, and you get an -e-capable jolt-chez: analysis on Janet, execution on Chez. driver/emit-core-prelude assembles it (each form behind a silent load guard so the Phase-2 multimethod forms don't break the rest); bin/jolt-chez is the -e CLI, caching the prelude on disk keyed by source hash. run-corpus-prelude.janet is the full parity gate this opens, the prelude-backed sibling of run-corpus-chez. First baseline: 1220/2497 evaluated cases pass, 0 new divergences (10 allowlisted: dynamic vars, class names, eval-order — deferred Phase 2). The rest is the punch-list: ~360 emit-fail (real host interop, out of the analyzer subset) and ~900 runtime crashes, mostly core fns calling host-coupled seed natives with no Chez shim yet (str/format/vec, transients). Follow-ups jolt-t6cr/kl2l/q3w8/9ls5. Two shims landed to get the prelude to load and run. atoms.ss: atom/deref/swap!/ reset! (+ the compare/vals kernel) — needed at load time for global-hierarchy = (atom (make-hierarchy)). predicates.ss: the type predicates + name/namespace/boolean the overlay assumes are seed natives, matching the seed's strict semantics. post-prelude.ss re-asserts char?/atom? after the prelude: the overlay implements those by reading :jolt/type, which is false for Chez-native chars/atoms, so its def-var! would clobber the correct native versions. Per-case Scheme files are PID-unique so a foreground -e never reads a half-written file while the gate runs.
This commit is contained in:
parent
37c433bd4a
commit
0c9c7931fe
10 changed files with 512 additions and 0 deletions
|
|
@ -353,6 +353,51 @@
|
|||
(string/find "frequencies" (scm 1)))
|
||||
(string/format "%p" scm)))
|
||||
|
||||
# 3n) atoms (jolt-9ziu): atom/deref/swap!/reset! are host-coupled (stay in the
|
||||
# Janet seed, no overlay def-var!), so the Chez host needs an RT shim
|
||||
# (host/chez/atoms.ss). They lower to var-deref in prelude mode. The hierarchy
|
||||
# machinery (global-hierarchy = (atom (make-hierarchy))) needs `atom` at the
|
||||
# prelude's LOAD time, so this is a load blocker, not just a lazy gap. swap!
|
||||
# invokes its fn through jolt-invoke; compare-and-set!/swap-vals!/reset-vals!
|
||||
# are overlay fns that compose the native kernel.
|
||||
(each src ["(deref (atom 42))"
|
||||
"@(atom 99)"
|
||||
"(let [a (atom 0)] (reset! a 7) (deref a))"
|
||||
"(let [a (atom 0)] (swap! a inc) (swap! a inc) (deref a))"
|
||||
"(let [a (atom 10)] (swap! a + 5) (deref a))"
|
||||
"(let [a (atom 1)] (reset! a 2) [(deref a) @a])"
|
||||
"(let [a (atom 0)] (compare-and-set! a 0 5) (deref a))"
|
||||
"(let [a (atom 0)] (compare-and-set! a 9 5) (deref a))"]
|
||||
(let [[code out err] (run-prelude src) want (cli-oracle src)]
|
||||
(ok (string "atom: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " janet=" want " | " err))))
|
||||
|
||||
# 3o) type predicates + name/namespace (jolt-9ziu): seed natives the overlay
|
||||
# assumes; the Chez host shims them (host/chez/predicates.ss) and def-var!s them
|
||||
# into clojure.core, so they resolve in prelude mode. Semantics match the seed
|
||||
# (core_types.janet): map?/vector?/set? strict over the persistent records,
|
||||
# seq? only for real sequences, coll? the union. Parity vs the CLI oracle.
|
||||
(each src ["(nil? nil)" "(nil? 0)"
|
||||
"(number? 3)" "(number? :a)" "(string? \"x\")" "(string? 1)"
|
||||
"(integer? 3)" "(integer? 3.5)"
|
||||
"(symbol? 'x)" "(keyword? :x)" "(keyword? 'x)"
|
||||
"(map? {:a 1})" "(map? [1 2])"
|
||||
"(vector? [1 2])" "(vector? '(1 2))"
|
||||
"(set? #{1 2})" "(set? [1])"
|
||||
# NB: (seq? (seq [1 2])) is true on Chez (Clojure-correct — a seq IS a
|
||||
# seq) but the seed oracle returns false (non-canonical), so it's not a
|
||||
# like-for-like cli-oracle comparison; the corpus encodes the canonical
|
||||
# value, where Chez agrees. Test seq? on the unambiguous cases here.
|
||||
"(seq? [1 2])" "(seq? '(1 2))"
|
||||
"(coll? [1])" "(coll? {:a 1})" "(coll? 3)"
|
||||
"(fn? inc)" "(fn? 3)"
|
||||
"(boolean nil)" "(boolean 5)"
|
||||
"(name :foo)" "(name 'bar)" "(name \"baz\")"
|
||||
"(namespace :a/b)" "(namespace :x)"]
|
||||
(let [[code out err] (run-prelude src) want (cli-oracle src)]
|
||||
(ok (string "pred: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " janet=" want " | " err))))
|
||||
|
||||
# 4) perf signal: emitted fib(30) in-Scheme timing (excludes Chez startup), to
|
||||
# track against the spike ceiling (hand-Scheme fib ~5ms). Informational — the
|
||||
# jolt-truthy? wrapper (~3x) and flonum modeling are known Phase-4 levers.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue