feat: Phase 2 vector-op specialization — count/nth on inferred vectors (jolt-d6u)
The inference now tags a :local it proved to be a vector with :hint :vector, and the back end specializes (count v) -> pv-count (skipping core-count's dispatch chain) and the 3-arg (nth v i default) -> pv-nth. The 2-arg nth is deliberately NOT specialized: pv-nth returns nil out-of-bounds where Clojure nth throws. Sound, conformance 335/335 x3 and full jpm test pass; type-infer-phase2-test pins the specialization and the 2-arg exclusion.
This commit is contained in:
parent
09e5af02c9
commit
5f05a99010
3 changed files with 49 additions and 1 deletions
|
|
@ -817,7 +817,11 @@
|
|||
[(let [v (get node :val)] (if (or (nil? v) (= false v)) :any :truthy)) node]
|
||||
(= op :local)
|
||||
(let [t (get tenv (get node :name))]
|
||||
[(if t t :any) (if (struct-safe? t) (assoc node :hint :struct) node)])
|
||||
[(if t t :any)
|
||||
(cond
|
||||
(struct-safe? t) (assoc node :hint :struct)
|
||||
(vec-type? t) (assoc node :hint :vector)
|
||||
:else node)])
|
||||
(= op :map)
|
||||
(let [res (mapv (fn [pr]
|
||||
(let [kr (infer (nth pr 0) tenv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue