fence (25.1): every allocation goes through the fence - sites, frame judging, census, callers
Every allocation the compiler emits goes through @lp_malloc/@lp_calloc/@lp_realloc/@lp_free, and a Ludic-level one first stores its site (function, file, line, kind) in @lp_site. Off, that is one load and a predictable branch (30 M allocations: 0.87-0.91 s against 0.87-0.90 s on leaks2). On (the default in a headless build, and windowed under R3D_DEV), tracking starts at the first frame on its own and judging once R3D_ALLOC_WARM frames in a row kept nothing (600) or R3D_ALLOC_WARM_MAX after (re)start; Mem.play()/Mem.rewarm() sends a load back to its warm-up. A judged frame that ends holding more than it began with is reported by site with its callers (the unwinder, taken only once judging) and fails the run with exit 86 (R3D_ALLOC_FENCE=off|count|warn|fail). R3D_ALLOC_CENSUS writes the totals and top sites at exit. The build's defaults are --fence=, --fence-warm=, --fence-census= or a fence line in the program's package.ludic; the environment overrides them. The runtime is IR (emit_fence_ir.ludic, generated from a template); tracking is a side table in one calloc'd region, so no block carries a header and pointers crossing to natives stay safe. Examples alloc_fence, alloc_fence_leak and alloc_fence_auto with cases in ludic-dev test; reseeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fc0f3d3790
commit
a8d54e9878
34 changed files with 106868 additions and 82677 deletions
|
|
@ -136,14 +136,14 @@ function emit_str_op(op: pointer, a: Val, b: Val) -> Val {
|
|||
let r = fresh_val(emit_bind(`call ptr @lp_str_concat(ptr {a.code}, ptr {b.code})`), "string")
|
||||
# a half this expression made is copied now and held by nothing: `a + "/" + b` and every
|
||||
# template's pieces once left one string behind per `+`
|
||||
if a.fresh { emit(` call void @free(ptr {a.code})\n`) }
|
||||
if b.fresh and b.code != a.code { emit(` call void @free(ptr {b.code})\n`) }
|
||||
if a.fresh { emit(` call void @lp_free(ptr {a.code})\n`) }
|
||||
if b.fresh and b.code != a.code { emit(` call void @lp_free(ptr {b.code})\n`) }
|
||||
return r
|
||||
}
|
||||
let r = emit_bind(`call i32 @lp_str_eq(ptr {a.code}, ptr {b.code})`)
|
||||
# a side made just to be compared is held by nothing once it has been: `` `{x}` == "..." ``
|
||||
if a.fresh { emit(` call void @free(ptr {a.code})\n`) }
|
||||
if b.fresh and b.code != a.code { emit(` call void @free(ptr {b.code})\n`) }
|
||||
if a.fresh { emit(` call void @lp_free(ptr {a.code})\n`) }
|
||||
if b.fresh and b.code != a.code { emit(` call void @lp_free(ptr {b.code})\n`) }
|
||||
if (op == ("!=")) {
|
||||
let c = emit_bind(`icmp eq i32 {r}, 0`)
|
||||
return val(emit_bind(`zext i1 {c} to i32`), "bool")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue