flan/spike/x86/p4-convention.flan
Joseph Ferano 2e203f64b8 bytes copies, bytes-view aliases, and a dev-session segfault parks
The INSERTIONSORT crash, all three rulings (FIX.org 2026-09-20):

- (bytes s) allocates a writable copy through the allocator surface —
  context or (bytes s a), StorageExhausted with retry, a registry note in
  dev builds (flan_bytes_dup, lowered like vec-new). (bytes-view s) is the
  old zero-cost reinterpret, renamed, read-only by convention; every
  in-repo reader swept over to it. (string b) unchanged.
- String constants were already read-only on both backends at -O0; now
  pinned — bytes-copy.flan rows on LLVM/-O0/--x86, and dies_segv rows
  asserting the write-through-view trap on both backends.
- A dev build installs a SIGSEGV/SIGBUS handler by the same dev-only
  constructor slot that arms the registry: one line naming the address and
  the innermost frame, then the trap-hook park — stopped, not dead, the
  daemon serving. No agent: message and re-raise. Release builds untouched.
  Pinned by trap_park over dev-segv.flan.
2026-09-20 23:12:42 +07:00

28 lines
847 B
Plaintext

;; The internal calling convention, which the fizz program does not touch at
;; all: an aggregate argument, an aggregate return, a float in the SSE half,
;; and more integer arguments than there are registers for.
(defstruct V3 [x f32 y f32 z f32])
(defn scale [v V3 k f32] V3
(V3 {.x (* (.x v) k) .y (* (.y v) k) .z (* (.z v) k)}))
(defn sum3 [v V3] f32
(+ (+ (.x v) (.y v)) (.z v)))
(defn eight [a i64 b i64 c i64 d i64 e i64 f i64 g i64 h i64] i64
(+ (+ (+ a b) (+ c d)) (+ (+ e f) (+ g h))))
(defn taglen [s [u8]] i64
(i64 (len s)))
(defn main [] i32
(let [v (V3 {.x 1.0 .y 2.0 .z 3.0})
w (scale v 2.0)]
(print (sum3 v)) (println "")
(print (sum3 w)) (println "")
(print (eight 1 2 3 4 5 6 7 8)) (println "")
(print (taglen (bytes-view "hello"))) (println "")
(print (.z w)) (println ""))
0)