Milestone 1 of dynamic-by-default, the runtime half: NaN-boxed values in one machine word, a mark-sweep heap, and the operations over them. A double is itself, which is what a language with a physics loop and a float calculator in its corpus wants; everything else hides in the quiet-NaN space, three tag bits and a 48-bit payload that is exactly an x86-64 user pointer. The negative-NaN collision is answered by canonicalising every NaN on the way in, which flan_rt.c had already decided was the right thing to print. An i64 past the payload goes on the heap rather than becoming a 48-bit integer with a 64-bit name. The collector is mark-sweep and nothing else -- no generation, no barrier, no free list -- because the answer to wanting it faster is to type the program. Roots are pushed, not scanned: NaN-boxing makes a conservative guess wrong in both directions, and flan_dev.c's frame chain is the precedent. A fixed ring of the last sixty-four allocations is marked unconditionally, which closes the window where an expression with two constructors in it can collect its own first result before the compiler has rooted either. A type mismatch traps rather than aborting, through a flan_trap exported from flan_rt.c so it takes the same path the six existing traps take: parked for inspection in a dev session, dead where it stands otherwise. The sentence names the operation, both tags as words, and both values. flan_dyn.c is its own translation unit and nothing in the release runtime names a symbol in it, so a program with no dyn operation links no collector and --no-gc can be file-level selection rather than an argument with the linker. docs/SPIKE-DYNAMIC.md carries the argument. test/dyn_ops.c drives every operation and all twenty-four refusals from C, the way dev_limits.c does, including a million allocations against a hundred live and the control that says an unrooted object really is reclaimed.
14 lines
702 B
Plaintext
14 lines
702 B
Plaintext
;;;; The dyn runtime's host, and deliberately almost nothing.
|
|
;;;;
|
|
;;;; There is no [main]: the entry point is test/dyn_ops.c, for the reason
|
|
;;;; dev_limits.c and reload_host.c are C mains. flan_dyn.c's surface is a C
|
|
;;;; ABI with no Flan spelling yet — the compiler lane is what gives it one —
|
|
;;;; so the only way to drive every operation, and every way each one refuses,
|
|
;;;; is from C.
|
|
;;;;
|
|
;;;; The one declaration below is here so that the file is a program the
|
|
;;;; checker accepts and [Build.executable] has something to lower. It is never
|
|
;;;; called. Everything the test links against comes from the runtime objects
|
|
;;;; the build attaches to every program.
|
|
(defn unused [x i64] i64 x)
|