23 lines
995 B
Plaintext
23 lines
995 B
Plaintext
;;;; spec-memory.md, "Every build detects a released region".
|
|
;;;;
|
|
;;;; A Vec records the epoch of the allocator it was made with, and free-all
|
|
;;;; bumps that counter. Any operation on a container whose recorded epoch has
|
|
;;;; moved traps, naming the site. This is the shipping answer to the section
|
|
;;;; the spec leaves open — detection, loud and immediate, rather than the
|
|
;;;; static prevention that with-allocator and context/allocator deny.
|
|
;;;;
|
|
;;;; It is a separate counter from the per-Vec generation word, which answers a
|
|
;;;; different question (a stale slice), and the two must not be conflated.
|
|
(defn main [] i32
|
|
(let [a (arena-new 4096)]
|
|
(let [v (vec-new i32 a)]
|
|
(push v 1)
|
|
(push v 2)
|
|
(println (at v 1))
|
|
;; The region goes. v is still in scope and still looks fine — nothing
|
|
;; is released at scope exit and nothing marked v — which is exactly the
|
|
;; case a static rule cannot see.
|
|
(free-all a)
|
|
(println (at v 1))))
|
|
0)
|