Chez Phase 1 (increment 3b): seq tier + dynamic IFn dispatch on the Chez RT
Brings up the seq layer on the Chez runtime. host/chez/seq.ss adds one lazy-capable node (cseq) that models Clojure's list, cons, and lazy seq - all print as (...), all sequential-= to each other and to vectors. seq coerces any seqable (vector/map/set/string/list/seq/nil) to a cseq or nil; the empty seq is a distinct value printing () (rest of a 1-elem coll is () not nil, seq of empty is nil). Leaf ops: first/rest/next/seq/cons/list, reverse/last, map/filter/remove/reduce/into, range/take/drop/concat/apply, keys/vals, plus nth/peek/pop extended over seqs. map/filter/reduce apply their fn arg through jolt-invoke, so a procedure, keyword, or collection all work as the fn. Dynamic IFn dispatch: a keyword/vector/coll held in a local (let binding or fn param) and called as a fn now routes through the jolt-invoke fallback (procedure? -> apply; keyword/coll -> lookup). The emitter only routes a :local callee that isn't a known procedure - a named fn's self-recursion name stays a direct call, so the fib hot path is untouched. Closes the 3 ex-known IFn divergences. emit.janet: seq/pred ops added to native-ops with arity gates; value-position clojure.core refs resolve to the RT procedure (native-ops names one for each), with +/-/*// routed to flonum-coercing wrappers so higher-order arithmetic ((reduce + [])) keeps the all-double model. values.ss: cross-type sequential =/hash so a vector and a list of the same elements are jolt= and hash alike. rt.ss: printer learns seqs; top-level nil prints as the empty string (jolt -e str-style). Fixed latent bug: (conj nil ...) now builds a list, not a vector. Gates: emit-test 69/69 (fib/mandelbrot/collections/seq/IFn parity vs the jolt oracle, fib(30) ~24ms unchanged). Subset probe 433/436 -> 595/595 compiled, 0 divergences (was 3 known), 2060/2655 out of subset. Full run-tests green (125 files, conformance + suites included).
This commit is contained in:
parent
5c5d2cd1fc
commit
cb3cfaf0c2
8 changed files with 383 additions and 33 deletions
|
|
@ -48,14 +48,16 @@ compile-time signal) and are counted "out of subset", not as divergences.
|
|||
|
||||
JOLT_CHEZ_CORPUS=1 janet test/chez/run-corpus-chez.janet
|
||||
|
||||
Baseline after inc 3a (persistent collections, jolt-wgbz): **433/436 compiled
|
||||
cases pass**, 3 known divergences, 0 NEW; 2219/2655 out of subset (await the seq
|
||||
tier + core on Chez). The 3 known divergences are dynamic IFn dispatch — a
|
||||
keyword/vector held in a LOCAL and called as a fn (`(let [k :a] (k m))`); the
|
||||
STATIC literal forms (`(:a m)`, `({:a 1} :a)`) are supported. They're
|
||||
allowlisted in the probe; it exits non-zero on a NEW divergence.
|
||||
Baseline after inc 3b (seq tier + dynamic IFn, jolt-5pso): **595/595 compiled
|
||||
cases pass**, 0 divergences; 2060/2655 out of subset (await clojure.core on Chez).
|
||||
The seq tier brought up a list/lazy-seq type with first/rest/next/seq/cons/list,
|
||||
map/filter/reduce/into/remove, range/take/drop/concat/apply, keys/vals, and
|
||||
nth/peek/pop over seqs; dynamic IFn dispatch (a keyword/vector/coll held in a
|
||||
local and called as a fn) now routes through the `jolt-invoke` fallback, closing
|
||||
the 3 ex-known divergences. The probe exits non-zero on any NEW divergence.
|
||||
|
||||
(Prior, inc 2 baseline: 182/182 compiled, 0 divergences, 2473 out of subset.)
|
||||
(Prior, inc 3a: 433/436 compiled, 3 known IFn divergences, 2219 out of subset.
|
||||
Inc 2: 182/182 compiled, 0 divergences, 2473 out of subset.)
|
||||
|
||||
It's a slow report (a Chez subprocess per case), so it's gated behind
|
||||
`JOLT_CHEZ_CORPUS` out of the default suite, like the benches.
|
||||
|
|
|
|||
|
|
@ -121,6 +121,70 @@
|
|||
(ok (string "coll: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " janet=" want " | " err))))
|
||||
|
||||
# 3d) dynamic IFn dispatch (inc 3b): a keyword/vector/coll held in a LOCAL (let
|
||||
# binding or fn param) and called as a fn. The 3 ex-known-divergences. The
|
||||
# callee is a :local that's NOT the fn's self-name, so emit routes it through
|
||||
# the jolt-invoke fallback (procedure? -> apply; keyword/coll -> lookup).
|
||||
(each [src want] [["(let [v [10 20 30]] (v 1))" "20"]
|
||||
["(let [k :a] (k {:a 7}))" "7"]
|
||||
["((fn [f] (f {:a 1})) :a)" "1"]]
|
||||
(let [[code out err] (d/run-on-chez ctx src)]
|
||||
(ok (string "ifn: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " want=" want " | " err))))
|
||||
|
||||
# 3e) seq tier (inc 3b): jolt list type, first/rest/next/seq/cons/list, lazy-seq
|
||||
# (range/take over an infinite seq), map/filter/reduce/into/remove, keys/vals.
|
||||
# Lists and lazy seqs print as (...) and are sequential-= to vectors. Ordered
|
||||
# shapes -> printed-form parity vs the CLI oracle.
|
||||
(each src ["(first [1 2 3])"
|
||||
"(rest [1 2 3])"
|
||||
"(rest [1])"
|
||||
"(rest [])"
|
||||
"(next [1 2 3])"
|
||||
"(next [1])"
|
||||
"(cons 0 [1 2 3])"
|
||||
"(cons 1 nil)"
|
||||
"(list 1 2 3)"
|
||||
"(list)"
|
||||
"(seq [])"
|
||||
"(conj (list 2 3) 1)"
|
||||
"(conj nil 1 2)"
|
||||
"(map inc [1 2 3])"
|
||||
"(map + [1 2 3] [10 20 30])"
|
||||
"(map :a [{:a 1} {:a 2}])"
|
||||
"(filter even? [1 2 3 4])"
|
||||
"(remove even? [1 2 3 4])"
|
||||
"(reduce + 0 [1 2 3])"
|
||||
"(reduce + [1 2 3])"
|
||||
"(reduce + (map inc (range 4)))"
|
||||
"(into [] [1 2 3])"
|
||||
"(into [1] (list 2 3))"
|
||||
"(take 3 (range))"
|
||||
"(reverse [1 2 3])"
|
||||
"(apply + [1 2 3])"
|
||||
"(count (map inc [1 2 3]))"]
|
||||
(let [[code out err] (d/run-on-chez ctx src)
|
||||
want (cli-oracle src)]
|
||||
(ok (string "seq: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " janet=" want " | " err))))
|
||||
|
||||
# 3f) seq tier — unordered / cross-type, equality-wrapped (prints true/false):
|
||||
# keys/vals order is HAMT order, into-map / into-set unordered; sequential =
|
||||
# across vector and list.
|
||||
(each src ["(= 2 (count (keys {:a 1 :b 2})))"
|
||||
"(= 3 (reduce + (vals {:a 1 :b 2})))"
|
||||
"(= {:a 1 :b 2} (into {} [[:a 1] [:b 2]]))"
|
||||
"(= #{1 2 3} (into #{} [1 2 3]))"
|
||||
"(= [1 2 3] (list 1 2 3))"
|
||||
"(= [1 2 3] (map inc [0 1 2]))"
|
||||
# jolt returns a vector for (seq vec) / bounded (range); Chez returns a
|
||||
# Clojure-canonical lazy seq. Values are sequential-=, printed forms differ.
|
||||
"(= [1 2 3] (seq [1 2 3]))"
|
||||
"(= [0 1 2 3 4] (range 5))"]
|
||||
(let [[code out err] (d/run-on-chez ctx src)]
|
||||
(ok (string "seq=: " src) (and (= code 0) (= out "true"))
|
||||
(string "chez=" out " | " 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.
|
||||
|
|
|
|||
|
|
@ -28,15 +28,13 @@
|
|||
corpus))
|
||||
|
||||
# Known subset divergences: cases that compile but need a feature beyond the
|
||||
# current increment. Dynamic IFn dispatch — a keyword/vector held in a LOCAL or
|
||||
# var then called as a fn ((let [k :a] (k m))) — is runtime dispatch on the
|
||||
# invoke mechanism, deferred to the IFn/protocol increment. The STATIC literal
|
||||
# forms ((:a m), ({:a 1} :a)) ARE supported. Allowlisted by label; the gate fails
|
||||
# only on a NEW divergence.
|
||||
# current increment. None as of inc 3b — dynamic IFn dispatch (a keyword/vector
|
||||
# held in a LOCAL then called as a fn, (let [k :a] (k m))) now routes through the
|
||||
# jolt-invoke fallback, and the seq tier closed the rest. Add a label here if a
|
||||
# future increment surfaces a case that compiles but needs deferred semantics;
|
||||
# the gate fails only on a NEW (un-allowlisted) divergence.
|
||||
(def known-divergences
|
||||
{"param holding a keyword (IFn leftover)" true
|
||||
"vector-in-local as fn" true
|
||||
"keyword-in-local as fn" true})
|
||||
{})
|
||||
|
||||
(def ctx (d/make-ctx))
|
||||
(var compiled 0) (var pass 0) (var out-of-subset 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue