The trio the author decided on 2026-09-20 is now all built: def is CL's defparameter — its initialiser runs on every daemon re-run, unguarded, so an edited initialiser repaints the same storage on C-c C-c plus re-run — defonce (Clojure's name for CL's defvar, per the author) initialises once behind the .init~once. flag, and defconst stays the image. One parse arm reads both forms; the difference is Ast.reinit, carried to Tast.global's grerun. Emit.startup_plan gives a def no guard flag, and Check.check_global lifts every def initialiser — zero and literal included — into global/<n>, so the host's startup reaches it through the function cell and a re-evaluated def swaps it (Session's def_inits; Emit.redefinition declares the cell for a non-sibling target). The old defvar spelling is refused with the rename and both compiling spellings, and every program, test, doc and editor list is swept — except sand.flan, the author's live WIP, whose seven defvar lines are flagged in FIX.org and keep its three dependent tests red on this branch.
21 lines
717 B
Plaintext
21 lines
717 B
Plaintext
;;;; A hot loop that does nothing but index a bounds-checked array.
|
|
;;;;
|
|
;;;; The suspected cost is three frame temporaries per check. This one has an
|
|
;;;; A/B that the others do not: --no-bounds-checks builds the same program
|
|
;;;; with the check gone, on both sides, so the difference between the two
|
|
;;;; x86 numbers is the check and nothing else, and the same difference on
|
|
;;;; the LLVM side says what the check costs when a compiler is allowed to
|
|
;;;; hoist it out of the loop.
|
|
|
|
(defonce xs [1024 i32])
|
|
|
|
(defn main [] i32
|
|
(dotimes [i 1024]
|
|
(set (at xs i) i))
|
|
(let [acc (i64 0)]
|
|
(dotimes [r 20000]
|
|
(dotimes [i 1024]
|
|
(set acc (+ acc (i64 (at xs i))))))
|
|
(print acc) (println ""))
|
|
0)
|