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
|
|
@ -43,3 +43,10 @@
|
|||
(defn mapv [f & colls] (vec (apply map f colls)))
|
||||
|
||||
(defn update [m k f & args] (assoc m k (apply f (get m k) args)))
|
||||
|
||||
;; set: realize a seqable and dedup through the set constructor; nil -> #{}. The
|
||||
;; compiler uses it off the emit path (backend bare-native-names, type inference),
|
||||
;; so unlike boolean it can live here — compiling this tier never calls set, and by
|
||||
;; the time those callers run the tier is bound. Pure composition of hash-set/seq/
|
||||
;; apply, so it lowers to the same code the native shim did.
|
||||
(defn set [coll] (if (nil? coll) #{} (apply hash-set (seq coll))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue