Migrate clojure.core/set from a native shim to the kernel overlay tier
set was a native shim (apply jolt-hash-set (seq->list coll)). It is a pure composition, so the Clojure version (apply hash-set (seq coll)) lowers to the same code. The compiler uses set, but only off the emit path (the backend's bare-native-names def and type inference), so it can live in the kernel tier: compiling that tier never calls set, and by the time those callers run the tier is already bound. This is distinct from boolean, which the backend calls for every :if node on the emit path. Moving boolean even to the kernel tier deadlocks (compiling the tier that defines boolean needs boolean), so boolean stays native. Added a comment in predicates.ss recording that. Re-mint converges in 3 passes and the benchmark suite is unchanged within noise (collections 43.3 vs 43.1, binary-trees 367 vs 367, the rest flat).
This commit is contained in:
parent
3d0cbed3c5
commit
d77b4e6420
5 changed files with 310 additions and 298 deletions
|
|
@ -33,7 +33,11 @@
|
|||
(define (jolt-fn? x) (procedure? x))
|
||||
(define (jolt-boolean-pred? x) (boolean? x))
|
||||
|
||||
;; (boolean x) coerces truthiness (nil/false -> false, else true).
|
||||
;; (boolean x) coerces truthiness (nil/false -> false, else true). MUST stay native:
|
||||
;; the backend's emit path calls clojure.core/boolean for every :if node
|
||||
;; (backend_scheme.clj bool tracking), so it has to exist before ANY compilation,
|
||||
;; including the kernel overlay tier (whose own fns contain `if`). Migrating it even
|
||||
;; to the kernel tier deadlocks: compiling the tier that defines boolean needs boolean.
|
||||
(define (jolt-boolean x) (if (jolt-truthy? x) #t #f))
|
||||
|
||||
;; (name x): keyword/symbol -> name string; string -> itself.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue