21-gc-mixed.scm (1254B)
1 ;; Mixed-allocator churn: every iteration allocates one value of each 2 ;; of the four heap shapes so pair-arena and obj-arena GCs overlap 3 ;; within a single run. 4 ;; 5 ;; (cons n n) — pair arena, 16 bytes 6 ;; (make-vector 6 n) — obj arena, 56 bytes (sub-128 7 ;; class 56 free list) 8 ;; (make-vector 24 n) — obj arena, 200 bytes (>128 9 ;; coalesce path) 10 ;; (string-append "x" "y") — obj arena, short string 11 ;; ((lambda (x) x) n) — obj arena, 32-byte closure 12 ;; allocated then immediately called 13 ;; and dropped 14 ;; 15 ;; 400 iterations × (1 pair + 4 obj) exhausts both arenas multiple 16 ;; times, interleaving sweep and free-list recycle across every 17 ;; size class plus the pair bitmap. A missed root or mis-classified 18 ;; chunk in either arena would surface as a crash, a wrong checksum, 19 ;; or a stuck loop. 20 21 (define churn 22 (lambda (n) 23 (if (= n 0) 24 42 25 (begin 26 (cons n n) 27 (make-vector 6 n) 28 (make-vector 24 n) 29 (string-append "x" "y") 30 ((lambda (x) x) n) 31 (churn (- n 1)))))) 32 33 (churn 400)