A block took whatever @lp_site held when it was made. Only malloc, calloc, realloc, concat, the number texts, the float text, a substring and Text.* set one, so every other runtime helper - intern, Text.repeat and the string builders, the Fs, Os, unicode, uuid and crypto helpers - was charged to whichever line had allocated last (walk 9 blamed gvk_tex_storage, m4_new, kept_push$int and survey_op_reward for intern's 16 B copies). - Any `call ptr @lp_*` now takes a site of its own, its kind the callee's name when no better one is known (intern, str_repeat, fs_list, ...). What the helper makes, in however many blocks and through whichever helpers it calls in turn, is that line's. - When the call returns, @lp_site goes back to site 0, now named "(runtime) (no site) unsited": a block made with no site of its own says so instead of borrowing the last one. - The ECS stores' grows and a mod's registered stores - the only allocations emitted outside emit_bind - take a site each. Golden alloc_fence_sites: two lines take turns keeping memory, Text.repeat and a record, every frame judged. Each report names its own line (25 x +32 B str_repeat at :11, 25 x +16 B new Box at :12); the toolchain before this charges 23 of the 32 B texts to the new Box line. The other fence and arena goldens are unchanged; ludic.base's tests pass; the game's frame ratchets are 0 on main 7cb2b164. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
729 B
Text
17 lines
729 B
Text
# alloc_fence_sites.ludic - 25.1: each block is charged to the line that made it. Two lines take turns
|
|
# keeping memory, one through a runtime helper (Text.repeat) and one a record; every frame is judged
|
|
# (R3D_ALLOC_FENCE=warn R3D_ALLOC_WARM_MAX=10) and each report names its own line - a helper once took
|
|
# the site of whatever had allocated last
|
|
program AllocFenceSites {
|
|
property Box { v: int = 0 }
|
|
property Keep { texts: []string = new []string, boxes: []Box = new []Box }
|
|
entry {
|
|
let k = new Keep
|
|
for f in 0 .. 60 {
|
|
if f % 2 == 0 { push(k.texts, Text.repeat("ab", 12)) }
|
|
else { push(k.boxes, new Box { v: f }) }
|
|
Mem.frame()
|
|
}
|
|
print(`texts {len(k.texts)} boxes {len(k.boxes)}`)
|
|
}
|
|
}
|