Make ^Record param hints work (resolve the record tag) (#232)
jolt.host/record-ctor-key and record-type? were stubs returning nil since the rehost, so phint-of always produced nil — a ^Record param hint (^Sphere s) was silently dead. The inference only ever typed a record param when its callers passed a concrete ctor (whole-program), so a fn called with an untyped value (a vector element, a value threaded through recursion) read its fields generically. Resolve the tag against the record registry (records.ss): chez-find-ctor-key maps a ^Type tag to the ctor-key "ns/->Name" the inference seeds with, preferring the compile ns and falling back to any registered record of that simple name (cross-ns / imported). record-type? / record-ctor-key call it. Runtime .ss — no re-mint (the analyzer reaches record-ctor-key through the host var). With this, a ^Sphere/^Ray-hinted hit-sphere in the ray tracer types its params, so its 48 generic jolt-get field reads + boxed arithmetic become bare-index reads + fl-ops: ray tracer 38.4s -> 23.9s (~1.6x), make test / shakesmoke green, selfhost holds, 0 new divergences. A wrong hint stays safe — jrec-field-at falls back to jolt-get for a non-record. run-fieldnum.ss: a ^V-hinted param (no inferable caller) bare-indexes + unboxes, with no generic jolt-get left. Co-authored-by: Yogthos <yogthos@gmail.com>
This commit is contained in:
parent
4671e1b67e
commit
09345f10c2
3 changed files with 37 additions and 2 deletions
|
|
@ -361,8 +361,19 @@
|
|||
|
||||
(define (hc-syntax-quote-lower ctx inner)
|
||||
(hc-sq-lower ctx inner (make-hashtable string-hash string=?)))
|
||||
(define (hc-record-type? ctx name) #f)
|
||||
(define (hc-record-ctor-key ctx name) jolt-nil)
|
||||
;; a ^Type param hint: name is the tag (a symbol, sometimes a string). Resolve it
|
||||
;; against the record registry (records.ss) so the inference seeds the param as
|
||||
;; that record — the open-world / cross-ns path where no caller type is inferred.
|
||||
(define (hc-record-tag-name name)
|
||||
(cond ((symbol-t? name) (symbol-t-name name))
|
||||
((string? name) name)
|
||||
(else #f)))
|
||||
(define (hc-record-type? ctx name)
|
||||
(let ((nm (hc-record-tag-name name)))
|
||||
(if (and nm (chez-find-ctor-key nm (chez-current-ns))) #t #f)))
|
||||
(define (hc-record-ctor-key ctx name)
|
||||
(let ((nm (hc-record-tag-name name)))
|
||||
(or (and nm (chez-find-ctor-key nm (chez-current-ns))) jolt-nil)))
|
||||
;; record + protocol-method shapes for the inference, from the runtime registries
|
||||
;; (records.ss) populated as deftype/defprotocol forms load.
|
||||
(define (hc-record-shapes ctx) (chez-record-shapes-map))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue