;;;; The aggregate case across the reload boundary, v2. ;;;; ;;;; The same four signatures with different arithmetic, so that the host's ;;;; un-rebuilt `outer' printing a different number can only mean its call ;;;; sites followed four redefined bodies that take and return structs. ;;;; ;;;; The `defstruct' blocks are byte-identical to v1's and must stay that way. ;;;; Layout is computed per module, so a field reordered here would make the ;;;; host and the module disagree about offsets — a real bug, but one wearing ;;;; this test's clothes, and it would be indistinguishable in the transcript ;;;; from the convention mismatch the fixture exists to detect. ;;;; ;;;; The four `weigh' functions are changed and the change must be dead text: a ;;;; module declares a sibling rather than defining it, so each call has to ;;;; land on the host's copy. With the bodies identical nothing at run time ;;;; would notice a module that grew its own; multiplied by ten, it is the ;;;; difference between 1611 and 12411 in the first term alone. ;;;; ;;;; Nothing here introduces a name the host was not built with. X86.redefinition ;;;; refuses those by name — that is the registry path, and it is item 1 of ;;;; docs/handoffs/HANDOFF-x86-redef.md's "what remains" rather than anything to do with ;;;; aggregates. (defstruct Pair [a i64 b i64]) (defstruct Quad [a i64 b i64 c i64 d i64]) (defstruct Duo [x f64 y f64]) (defstruct Mix [n i64 z f64]) (defvar counter i64) (defn weigh-pair [p Pair] i64 (+ (.a p) (* 30 (.b p)))) (defn weigh-quad [q Quad] i64 (+ (+ (.a q) (* 30 (.b q))) (+ (* 50 (.c q)) (* 70 (.d q))))) (defn weigh-duo [d Duo] i64 (+ (i64 (.x d)) (* 30 (i64 (.y d))))) (defn weigh-mix [m Mix] i64 (+ (.n m) (* 30 (i64 (.z m))))) (defn step-pair [p Pair] Pair (println "a2") (set counter (+ counter 10)) (Pair {.a (+ (.a p) 10) .b (+ (.b p) (* 2 (weigh-pair p)))})) (defn step-quad [q Quad] Quad (Quad {.a (+ (.a q) 10) .b (+ (.b q) 20) .c (+ (.c q) 30) .d (+ (.d q) (* 2 (weigh-quad q)))})) (defn step-duo [d Duo] Duo (Duo {.x (+ (.x d) 10.0) .y (+ (.y d) (f64 (* 2 (weigh-duo d))))})) (defn step-mix [m Mix] Mix (Mix {.n (+ (.n m) 10) .z (+ (.z m) (f64 (* 2 (weigh-mix m))))})) (defn sum-pair [p Pair] i64 (+ (.a p) (* 100 (.b p)))) (defn sum-quad [q Quad] i64 (+ (+ (.a q) (* 100 (.b q))) (+ (* 10000 (.c q)) (* 1000000 (.d q))))) (defn sum-duo [d Duo] i64 (+ (i64 (.x d)) (* 100 (i64 (.y d))))) (defn sum-mix [m Mix] i64 (+ (.n m) (* 100 (i64 (.z m))))) (defn outer [] i64 (let [p (step-pair (Pair {.a 1 .b 2})) q (step-quad (Quad {.a 1 .b 2 .c 3 .d 4})) d (step-duo (Duo {.x 1.0 .y 2.0})) m (step-mix (Mix {.n 1 .z 2.0}))] (+ (+ (sum-pair p) (sum-quad q)) (+ (sum-duo d) (sum-mix m)))))