Chez Phase 1 (increment 3n): seq-native shims + reduced
The dominant prelude-parity crash bucket was 'apply non-procedure jolt-nil': core fns calling seed-native seq fns (core_coll.janet) that have no Chez RT shim, so var-deref returns jolt-nil. A static scan of the assembled prelude turned up 52 referenced-but-undefined clojure.core names. host/chez/natives-seq.ss shims the safe seq fns over the existing seq layer: mapcat, take-while, drop-while, partition (collection arities only — the 1-arg transducer forms are jolt-kxsr), and sort (compare default; a comparator may return a 3-way number or a boolean less-than). reduced/reduced? is a jolt-reduced record in seq.ss that reduce short-circuits on and deref unwraps, so unreduced works. identical? = jolt= (the seed's definition). Deferred list?: a Chez lazy seq and a list are both cseq, so it can't be told apart without a distinct list type — a real divergence risk. Parity 1407 -> 1467/2497, 0 new divergences. emit-test 263/263.
This commit is contained in:
parent
c28b5406ca
commit
739b219d0e
7 changed files with 183 additions and 11 deletions
|
|
@ -124,12 +124,27 @@ class names, eval-order, with-open — all deferred Phase-2 / dynamic-var gaps).
|
|||
`inf`/`-inf`/`nan` and `str` renders `Infinity`/`-Infinity`/`NaN` (Clojure). Plus
|
||||
variadic `assoc!`. (`str` of inf *inside a collection* still wants the long form —
|
||||
the Phase-2 recursive str renderer — so `[inf inside coll]` is allowlisted.)
|
||||
- inc 3n `host/chez/natives-seq.ss` (jolt-y6mv): the dominant prelude-parity crash
|
||||
bucket was `apply non-procedure jolt-nil` — core fns calling seed-native seq fns
|
||||
(`src/jolt/core_coll.janet`) that have no Chez shim, so `var-deref` yields
|
||||
jolt-nil. A static scan of the assembled prelude found 52 referenced-but-undefined
|
||||
`clojure.core` names; this increment shims the safe, high-value seq fns: `mapcat`/
|
||||
`take-while`/`drop-while`/`partition` (collection arities — the 1-arg transducer
|
||||
forms are jolt-kxsr), `sort` (compare default; a comparator may return a 3-way
|
||||
number or a boolean less-than), and `reduced`/`reduced?` — a `jolt-reduced` record
|
||||
in `seq.ss` that `reduce` short-circuits on and `deref` unwraps (so `unreduced`
|
||||
works). `identical?` = `jolt=` (the seed's definition). `list?` was deferred: a
|
||||
Chez lazy seq and a list are both `cseq`, so it can't be told apart without a
|
||||
distinct list type (a real divergence risk).
|
||||
|
||||
The remaining buckets are the punch-list the next increments chase: ~360 emit-fail
|
||||
(genuine host interop — qualified Java/Janet refs, runtime `defmacro`/`eval`, out of
|
||||
the analyzer's subset) and ~715 runtime crashes — more host-coupled natives without a
|
||||
shim, transducer arities (jolt-kxsr), `cdr`-on-`()` and `\p{}` regex classes
|
||||
(jolt-y1zq), and multimethod dispatch (Phase 2 jolt-9ls5).
|
||||
The remaining buckets are the punch-list the next increments chase (at 1467/2497):
|
||||
~361 emit-fail (genuine host interop — qualified Java/Janet refs, runtime
|
||||
`defmacro`/`eval`, out of the analyzer's subset) and ~655 runtime crashes — still
|
||||
~590 `apply jolt-nil` (more host-coupled natives without a shim: `meta`/`with-meta`,
|
||||
`format`, the `clojure.string` natives, bit ops, `var`/`volatile`/`future`/
|
||||
thread-binding ops), the transducer arities (jolt-kxsr — 1-arg `filter`/`map`/`take`/
|
||||
`take-while` + 3-arg `into`), `cdr`-on-`()` and `\p{}` regex classes (jolt-y1zq), and
|
||||
multimethod dispatch (Phase 2 jolt-9ls5).
|
||||
|
||||
Two host shims landed with the prelude. `host/chez/atoms.ss`: atom/deref/swap!/
|
||||
reset! (+ compare-and-set!/swap-vals!/reset-vals!) — host-coupled mutable cells the
|
||||
|
|
|
|||
|
|
@ -488,6 +488,44 @@
|
|||
(ok (string "numedge: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " janet=" want " | " err))))
|
||||
|
||||
# 3s) seq-native shims + reduced (jolt-y6mv): the dominant prelude-parity crash
|
||||
# bucket was 'apply jolt-nil' — core fns calling seed-native seq fns with no Chez
|
||||
# shim. host/chez/natives-seq.ss shims the safe, high-value ones (mapcat/
|
||||
# take-while/drop-while/partition collection arities, sort) over the seq layer,
|
||||
# plus reduced/reduced? (reduce short-circuits on a reduced; deref unwraps it)
|
||||
# and identical?. They lower to var-deref in prelude mode. Asserted as
|
||||
# (= expected (expr)) -> "true" so seq-vs-vector equality (not print form) is the
|
||||
# contract, exactly like the corpus gate.
|
||||
(each src [# reduced
|
||||
"(reduced? (reduced 1))" "(reduced? 1)" "(deref (reduced 9))"
|
||||
"(reduce (fn [a x] (if (> a 2) (reduced a) (+ a x))) 0 [1 2 3 4 5])"
|
||||
"(= [1 1 2 2] (mapcat (fn [x] [x x]) [1 2]))"
|
||||
"(= [1 3 2 4] (mapcat vector [1 2] [3 4]))"
|
||||
"(= [1 2 3] (mapcat identity [[1 2] [3]]))"
|
||||
"(= () (mapcat vector [] [1 2]))"
|
||||
"(= [1 2] (take-while (fn [x] (< x 3)) [1 2 3 1]))"
|
||||
"(= [3 1] (drop-while (fn [x] (< x 3)) [1 2 3 1]))"
|
||||
"(= () (take-while pos? []))"
|
||||
"(= [[1 2] [3 4]] (partition 2 [1 2 3 4 5]))"
|
||||
"(= [[1 2] [4 5]] (partition 2 3 [1 2 3 4 5 6]))"
|
||||
"(= [[1 2] [3 :p]] (partition 2 2 [:p] [1 2 3]))"
|
||||
"(= [1 2 3] (sort [3 1 2]))"
|
||||
"(= [3 2 1] (sort > [1 3 2]))"
|
||||
"(= [nil 1 3] (sort compare [3 nil 1]))"
|
||||
"(= () (sort []))"
|
||||
"(identical? :a :a)" "(identical? :a :b)"]
|
||||
(let [[code out err] (run-prelude src) want (cli-oracle src)]
|
||||
(ok (string "seq-native: " src) (and (= code 0) (= out want))
|
||||
(string "chez=" out " janet=" want " | " err))))
|
||||
# reduce-kv honors reduced is an OVERLAY fn over the native reduce — exercise it
|
||||
# end-to-end through the assembled -e binary.
|
||||
(when (os/stat "bin/jolt-chez")
|
||||
(each src ["(= [:a] (reduce-kv (fn [a i v] (if (= i 1) (reduced a) (conj a v))) [] [:a :b :c]))"
|
||||
"(= 9 (unreduced (reduced 9)))" "(= 9 (unreduced 9))"]
|
||||
(let [[code out err] (run-jolt-chez src) want (cli-oracle src)]
|
||||
(ok (string "seq-native -e: " 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.
|
||||
|
|
|
|||
|
|
@ -135,8 +135,9 @@
|
|||
# reach-floor and the suite baseline. The gate fails if parity drops below it, or
|
||||
# on any NEW (un-allowlisted) divergence — a real Chez correctness regression.
|
||||
# Full-corpus baseline: inc 3j 1220/2497; 3k (converters) 1326; 3l (transients)
|
||||
# 1382; 3m (numeric-edge emit + variadic assoc!) 1407. Strided runs scale down.
|
||||
(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_PRELUDE_FLOOR") "1407")))
|
||||
# 1382; 3m (numeric-edge emit + variadic assoc!) 1407; 3n (seq-native shims +
|
||||
# reduced) 1467. Strided runs scale down.
|
||||
(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_PRELUDE_FLOOR") "1467")))
|
||||
(def floor (if (os/getenv "JOLT_CORPUS_LIMIT") 0 base-floor))
|
||||
(when (or (> (length diverged) 0) (< pass floor))
|
||||
(printf "REGRESSION: pass %d < floor %d or %d new divergence(s)" pass floor (length diverged)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue