mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
Emitted record and class constructors called scr_rt_calloc/scr_cyc_alloc with a constant size, so the size class, the zeroing length and the collector header setup were recomputed per object behind a call (plus an empty scr_obj_alloc_note call and a variable-length memset). llvm/alloc.ts now emits the fast paths inline: pop the class free list (clearing only the bytes the helper does not store itself) or bump, with the old calls as the cold slow path. Releases inline the weak-dispose hook check, the live count, and the free-list push; blocks outside the reservation still go to scr_rt_free. The emitted IR does not know which runtime it links against (the sanitized lane only differs at link time), so the runtime now defines scr_sa in every build. Where the allocator is compiled out (ASan, SCR_RC_AUDIT, wasm32, Windows, 32-bit, thread-instanced libraries) it stays all-zero and the inline paths always take the slow path, which keeps the RC-audit object notes. ScrSaState's layout is pinned with static asserts. Inline emission is additionally gated off for 32-bit, WASI, Windows triples and thread-instanced libraries. Runtime callers with hot constant-size allocations (union boxes, arrays, boxes, closures, dyn nodes) use new static inline twins scr_cyc_alloc_inline/scr_cyc_free_inline; scr_cyc_live is exported. The ABI guard now recognizes function-pointer extern data (scr_weak_dispose_hook). New corpus program 4410 pins recycled-block clearing, size classes, objects above the largest class, cycles and weak observers.