wcc/ww: struct-local stack slot is the checker's natural size, not slot-padded
wwstage's slotsize() shared its TY_STRUCT arm with TUPLE/ARRAY and
returned ti.slotsize — the SUM of the slot-padded field widths. For a
struct LOCAL that over-reserves the frame slot whenever a field is a
sub-8 nested composite: a nested inner{x:u8,y:u8} (size 2, slotsize 8)
pads its in-struct footprint, and the local inherits that pad. cstage
has no slotsize SSoT — it reserves the local at f->type->size, the
checker's NATURAL r.size (cmd/w6c/cgen.c). So on outer{a:u8,
p:inner{x:u8,y:u8}, z:i64} wwstage emitted frame $32 / struct-base
-24(BP) while cstage emitted $16 / -16(BP): a uniform -8 BP shift on
every field access. Both stages exit 0 (each self-consistent), so it is
runtime-invisible — but it is a cs!=ww .s divergence (rule 10) and a
latent byte-id gate-landmine the day such a struct enters the corpus.
Same dual-SSoT leak as #44 (field-OFFSET) / #55, one notion over:
struct-local-slot-SIZE.
Fix: split the TY_STRUCT arm out and return round8(ti.size). The TUPLE
arm (8B/elem slot, user ruling #60) and the ARRAY arm (element stride,
#48 [N]Alias 24B) keep ti.slotsize — those are deliberate, ruled
divergences and are untouched. The struct-local slot consumers
(cgendecl.ww letslotsize via cglet, cgenstmt.ww) all flow through this
arm; si.totsize (registerstruct → structabisize / global-emit) is a
separate consumer and is not this path.
CLASS-N corpus-neutral: every corpus struct local is 8-aligned, so
round8(ti.size) == slotsize for all of them and the w6c_ww/wwdump_ww
emission does not move (994 byte-id on 18 corpus inputs + 995 5-tool
self-rebuild both green post-fix). 989_structlocal_frame is the
FRAME-ABSOLUTE proof (w6c vs w6c_ww .s byte-diff; nested3 + tail_u32 +
flat control) — the .s twin of the runtime 989_nestfield_run, which
deliberately does not gate the frame and points here for it.
This commit is contained in:
@@ -2559,8 +2559,19 @@ fn slotsize(c: *cgen, typn: *node) i32 = {
|
||||
kk == tykind.TY_STR || kk == tykind.TY_TAGGED) {
|
||||
return ti.size: i32;
|
||||
};
|
||||
if (kk == tykind.TY_STRUCT || kk == tykind.TY_TUPLE ||
|
||||
kk == tykind.TY_ARRAY) {
|
||||
// #75: a struct LOCAL's stack slot is the struct's NATURAL size
|
||||
// rounded up to the 8B slot grain — NOT ti.slotsize, which sums the
|
||||
// slot-padded field widths and over-reserves on sub-8 nested
|
||||
// composites (e.g. outer{a:u8, p:inner{x:u8,y:u8}, z:i64} → ww $32 vs
|
||||
// cstage $16). cstage reserves the local at f->type->size (cmd/w6c/
|
||||
// cgen.c), i.e. the checker's natural r.size (check.ww:2256). Same
|
||||
// dual-SSoT leak as #44 (field-offset) / #55, one notion over. The
|
||||
// TUPLE arm (8B/elem slot, user ruling #60) and ARRAY arm (element
|
||||
// stride, #48 [N]Alias 24B) keep ti.slotsize — deliberate divergences.
|
||||
if (kk == tykind.TY_STRUCT) {
|
||||
return ((ti.size + 7u64) & ~7u64): i32;
|
||||
};
|
||||
if (kk == tykind.TY_TUPLE || kk == tykind.TY_ARRAY) {
|
||||
return ti.slotsize: i32;
|
||||
};
|
||||
return 8;
|
||||
|
||||
Reference in New Issue
Block a user