feat: success checker on by default in direct-link builds, free (jolt audit)
Checking inherently needs an inference pass (~2.6x compile as a standalone pass). But direct-link builds ALREADY run one inference pass for specialization (run-passes' infer-top), so checking can ride along: set a check-mode flag, turn checking? on during that existing pass, and collect the diagnostics after — ~2% overhead measured on the ray tracer, vs 2.6x for the separate pass. So the checker now defaults to `warn` in direct-link builds (where it's nearly free) and stays OFF in plain REPL/dev builds (no inference to ride, no forced cost — opt in with JOLT_TYPE_CHECK there). JOLT_TYPE_CHECK still overrides in both directions (off to disable, error to escalate). It checks the POST-optimization IR, which matches what the optimized program actually evaluates — scalar-replace only drops provably-pure code, an accepted opt-mode divergence, so no real error is hidden. The loaders enable position tracking whenever checking will run (env-selected or direct-link). type-check! (the standalone pass) stays for plain builds; both paths share report-diags!. cli-test pins: plain build silent, direct-link warns by default, JOLT_TYPE_CHECK=off disables. Gate green, suite 4718, runtime bench even.
This commit is contained in:
parent
69af83da89
commit
088232b778
6 changed files with 111 additions and 35 deletions
|
|
@ -1311,6 +1311,21 @@
|
|||
(get fnode :arities))))
|
||||
def-node)))
|
||||
|
||||
;; Piggyback checking (jolt audit). In direct-link mode infer-top already runs
|
||||
;; one inference pass for specialization; turning checking? on during it makes
|
||||
;; the success checker nearly free there (no extra traversal — just the
|
||||
;; per-call error-domain predicates). The back end sets the mode before
|
||||
;; run-passes and reads take-diags! after. It checks the POST-optimization IR,
|
||||
;; which matches what the optimized program actually evaluates (scalar-replace
|
||||
;; only drops provably-pure code, an accepted opt-mode divergence).
|
||||
(def ^:private check-mode-box (atom {:on false :strict false}))
|
||||
(defn set-check-mode!
|
||||
"Enable/disable checking during the next run-passes inference (direct-link)."
|
||||
[on strict?] (reset! check-mode-box {:on (if on true false) :strict (if strict? true false)}))
|
||||
(defn take-diags!
|
||||
"Diagnostics accumulated by the last checking run-passes; clears the buffer."
|
||||
[] (let [d (vec @diag-box)] (reset! diag-box []) d))
|
||||
|
||||
(defn run-passes
|
||||
"All passes, in order. The back end applies this to every analyzed form. When
|
||||
inlining is enabled for the unit (user code under direct-linking, jolt-87f),
|
||||
|
|
@ -1327,5 +1342,15 @@
|
|||
(if (and @dirty (< i 8))
|
||||
(recur (inc i) n2)
|
||||
n2)))]
|
||||
(infer-top opt))
|
||||
;; specialization inference, optionally also emitting success diagnostics
|
||||
(if (get @check-mode-box :on)
|
||||
(do (reset! diag-box [])
|
||||
(reset! checking-box #{})
|
||||
(reset! strict-box (get @check-mode-box :strict))
|
||||
(reset! checking? true)
|
||||
(let [r (infer-top opt)]
|
||||
(reset! checking? false)
|
||||
(reset! strict-box false)
|
||||
r))
|
||||
(infer-top opt)))
|
||||
(const-fold node)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue