flan/test/programs/dev-alloc-param.flan

21 lines
622 B
Plaintext

;;;; A function taking an Allocator, redefined while the program runs. The value
;;;; is two words, the record and its incarnation, and the redefined body is
;;;; compiled by the reload emitter and called through the host's cell, so the
;;;; two have to agree on how those words cross. test_dev.ml runs it on both
;;;; backends.
(import agent "vendor:agent")
(defonce region Allocator)
(defn fill [a Allocator n i32] i64
(let [v (vec-new i64 a)]
(dotimes [i n] (push v (i64 i)))
(i64 (length v))))
(defn main [] i32
(agent/start)
(set region (arena-new 4096))
(dotimes [i 4000]
(agent/wait 5))
0)