wcc+w6c+w6c_ww: tuple slot layout SSoT — checker size = cgen slot stride (C-t0)
The checker computed TY_TUPLE size as the packed element-size sum ((u32,u32) = 8B) while every cgen cursor-transport site strode 8B slots (16B). 16B tuples were blind to the split (slot == packed); packed tuples hit it everywhere: cstage let-receive keyed on sz 16/32 missed sz 8 and dropped word 1, the cgfn param receive spilled 8B/element into a packed-sized local (saved-BP clobber, SIGSEGV), and mixed (u32,f64)/(u32,str) shapes missed the receive arms entirely. Slot layout is now the SSoT (user-ratified): the flip lives in the two checkers' N_TTUPLE size computation only (check.c, check.ww tupleelemslot + stamp); cgen's packed-keyed walks (t.N read, #235 len arm, over-cap sret send/receive pair) align onto the slot stride, and the wwstage t.N read gains the natural-width load (tnodeloadop) to byte-id with cstage's fldloadop. ttupleelem.offset re-stamped slot-cumulative (no consumers yet). The #242/#243 eightbyte-share loud-stop dissolves by construction (no two narrows ever share an eightbyte) — 940's eightbyte_share row graduates to a runtime round-trip. Hare-layout divergence documented at both checker sites; re-alignment is task #60. #32 send skew and #33 wwstage literal-let receive are separate commits on this base. 941_tuple_slot_layout_run pins the matrix: 4 packed rows fail at the parent (8/21 checks), 3 neutral anchors prove 16B/32B emission untouched.
This commit is contained in:
@@ -11926,8 +11926,15 @@ fn tupleelemslot(pt: *tinfo) u64 = {
|
||||
pk == tykind.TY_I32 || pk == tykind.TY_U8 ||
|
||||
pk == tykind.TY_U16 || pk == tykind.TY_U32 ||
|
||||
pk == tykind.TY_F32 || pk == tykind.TY_ENUM) { return 8u64; };
|
||||
// Composite — struct/tuple/array/tagged carry their own slot total.
|
||||
return t.slotsize;
|
||||
// Composite — one 8B eightbyte, NOT t.slotsize: cgen's cursor
|
||||
// transport strides `wide ? size : 8` at every tuple site (both
|
||||
// stages), so a composite element rides one register word today.
|
||||
// The checker mirrors what cgen emits (tuple arc C-t0; cstage
|
||||
// check.c N_TTUPLE twin) — a slotsize answer here would re-open the
|
||||
// checker-vs-cgen layout split the slot-SSoT ruling closed. No
|
||||
// composite-element tuple exists in the corpus; transport for >8B
|
||||
// composites is its own unwired gap.
|
||||
return 8u64;
|
||||
};
|
||||
|
||||
// #61 A.5 helper: per-field slot size mirroring cgenutil.ww
|
||||
@@ -12128,16 +12135,20 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = {
|
||||
r.align = storage.align;
|
||||
r.slotsize = storage.size;
|
||||
case nkind.N_TTUPLE:
|
||||
// Cstage cmd/wcc/check.c:329-345: sum of element sizes with
|
||||
// per-element alignment NOT padded — cstage uses raw sums for
|
||||
// tuples and 8B-rounding lives at the call/return ABI layer.
|
||||
// Slot layout is the tuple SSoT (tuple arc C-t0, user-ratified):
|
||||
// ti.size = ti.slotsize = per-element slot sum (tupleelemslot —
|
||||
// a str/slice its header, everything else one 8B eightbyte),
|
||||
// the stride cgen's cursor transport actually writes. ww-
|
||||
// internal ABI only (tuples never cross extern);
|
||||
// size((u32,u32))=16 is observable via size() and diverges from
|
||||
// Hare (harec type_store.c:533-580 anonymous-struct rule) AND
|
||||
// from ww's own structs (which pack narrow fields post-
|
||||
// fldloadop) — that internal inconsistency is what task #60
|
||||
// eventually fixes; re-open before any serialization/FFI/
|
||||
// density use. Pre-C-t0 ti.size was the packed raw sum while
|
||||
// cgen strode 8B slots — the checker-says-8/cgen-does-16 split
|
||||
// behind the packed-tuple miscompile family (#32/#33/#48).
|
||||
// Pre-bind for cycle protection (recursive tuple shapes).
|
||||
//
|
||||
// #61 A.5: ti.size = natural sum (cstage parity); ti.slotsize
|
||||
// = per-element slot sum mirroring cgenutil.ww:2018-2029
|
||||
// slotsize TTUPLE — narrow scalars pad to 8 (cgen spills each
|
||||
// tuple element into its own register / stack-slot eightbyte),
|
||||
// composites contribute their own ti.slotsize.
|
||||
r = newtype(tykind.TY_TUPLE);
|
||||
tinfocachebind(c.tc, n, r);
|
||||
// #57 A.6.3i-phase-1: populate r.tupleelems as a ttupleelem
|
||||
@@ -12145,37 +12156,32 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = {
|
||||
// size/align accumulator. Harec analog ref/harec/src/type_
|
||||
// store.c:532-589 tuple_init_from_atype — {type, offset, next}
|
||||
// per member onto type->tuple.next chain. Diverges from cstage
|
||||
// cmd/wcc/check.c:329-345 which stores tuple positionals on
|
||||
// t->params (Tparam, no offset, consumer recomputes by walking
|
||||
// at cgen.c:5723-5750); the offset-stored shape lets Phase
|
||||
// 2/J consumers (dotchainresolve) read offsets directly per
|
||||
// the A.6 stamp-once-read-many arc. Direct analog
|
||||
// 26724fe (#50 phase 1, A.6.3f-a) for the head/tail append
|
||||
// pattern. Offset matches cstage's raw-sum layout (no per-
|
||||
// element padding) — rule 10 aligns wwstage tuple layout down
|
||||
// to cstage, distinct from harec's add_padding(&offset,
|
||||
// memb.align) at type_store.c:561.
|
||||
// cmd/wcc/check.c N_TTUPLE which stores tuple positionals on
|
||||
// t->params (Tparam, no offset, consumer recomputes by
|
||||
// walking); the offset-stored shape lets consumers
|
||||
// (dotchainresolve) read offsets directly per the A.6
|
||||
// stamp-once-read-many arc. Direct analog 26724fe (#50 phase 1,
|
||||
// A.6.3f-a) for the head/tail append pattern. Offsets are
|
||||
// slot-cumulative (C-t0), distinct from harec's
|
||||
// add_padding(&offset, memb.align) at type_store.c:561.
|
||||
let teh: *ttupleelem = nil;
|
||||
let tet: *ttupleelem = nil;
|
||||
let total: u64 = 0u64;
|
||||
let slottotal: u64 = 0u64;
|
||||
let maxal: u64 = 1u64;
|
||||
let p: *node = n.list;
|
||||
for (p != nil) {
|
||||
let pt: *tinfo = tinfofornode(c, p.lhs);
|
||||
let elemoff: u64 = total;
|
||||
let te: *ttupleelem = alloc(ttupleelem{type_=pt, offset=elemoff, tnext=nil})!;
|
||||
let te: *ttupleelem = alloc(ttupleelem{type_=pt, offset=slottotal, tnext=nil})!;
|
||||
if (teh == nil) { teh = te; } else { tet.tnext = te; };
|
||||
tet = te;
|
||||
if (pt != nil) {
|
||||
if (pt.align > maxal) { maxal = pt.align; };
|
||||
total += pt.size;
|
||||
slottotal += tupleelemslot(pt);
|
||||
};
|
||||
p = p.next;
|
||||
};
|
||||
r.tupleelems = teh;
|
||||
r.size = total;
|
||||
r.size = slottotal;
|
||||
r.align = maxal;
|
||||
r.slotsize = slottotal;
|
||||
case nkind.N_TSTRUCT:
|
||||
@@ -22876,8 +22882,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
emitline("(BP), X0\n");
|
||||
return;
|
||||
};
|
||||
let sz: i32 = slotsize(c, tpt);
|
||||
let op: str = tnodeloadop(c, tpt, sz);
|
||||
// C-t0: load at the element's NATURAL
|
||||
// width (narrow MOVL/MOVSXD/... at the
|
||||
// slot base), not the 8B slot width —
|
||||
// byte-id twin of cstage's fldloadop
|
||||
// in the N_DOT TY_TUPLE arm.
|
||||
let nsz: i32 = 8;
|
||||
let tpti: *tinfo = tpt.type_: *tinfo;
|
||||
if (tpti != nil) { nsz = tpti.size: i32; };
|
||||
let op: str = tnodeloadop(c, tpt, nsz);
|
||||
emitline("\t");
|
||||
emitline(op);
|
||||
emitline("\t");
|
||||
|
||||
@@ -2658,8 +2658,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
emitline("(BP), X0\n");
|
||||
return;
|
||||
};
|
||||
let sz: i32 = slotsize(c, tpt);
|
||||
let op: str = tnodeloadop(c, tpt, sz);
|
||||
// C-t0: load at the element's NATURAL
|
||||
// width (narrow MOVL/MOVSXD/... at the
|
||||
// slot base), not the 8B slot width —
|
||||
// byte-id twin of cstage's fldloadop
|
||||
// in the N_DOT TY_TUPLE arm.
|
||||
let nsz: i32 = 8;
|
||||
let tpti: *tinfo = tpt.type_: *tinfo;
|
||||
if (tpti != nil) { nsz = tpti.size: i32; };
|
||||
let op: str = tnodeloadop(c, tpt, nsz);
|
||||
emitline("\t");
|
||||
emitline(op);
|
||||
emitline("\t");
|
||||
|
||||
@@ -1599,8 +1599,15 @@ fn tupleelemslot(pt: *tinfo) u64 = {
|
||||
pk == tykind.TY_I32 || pk == tykind.TY_U8 ||
|
||||
pk == tykind.TY_U16 || pk == tykind.TY_U32 ||
|
||||
pk == tykind.TY_F32 || pk == tykind.TY_ENUM) { return 8u64; };
|
||||
// Composite — struct/tuple/array/tagged carry their own slot total.
|
||||
return t.slotsize;
|
||||
// Composite — one 8B eightbyte, NOT t.slotsize: cgen's cursor
|
||||
// transport strides `wide ? size : 8` at every tuple site (both
|
||||
// stages), so a composite element rides one register word today.
|
||||
// The checker mirrors what cgen emits (tuple arc C-t0; cstage
|
||||
// check.c N_TTUPLE twin) — a slotsize answer here would re-open the
|
||||
// checker-vs-cgen layout split the slot-SSoT ruling closed. No
|
||||
// composite-element tuple exists in the corpus; transport for >8B
|
||||
// composites is its own unwired gap.
|
||||
return 8u64;
|
||||
};
|
||||
|
||||
// #61 A.5 helper: per-field slot size mirroring cgenutil.ww
|
||||
@@ -1801,16 +1808,20 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = {
|
||||
r.align = storage.align;
|
||||
r.slotsize = storage.size;
|
||||
case nkind.N_TTUPLE:
|
||||
// Cstage cmd/wcc/check.c:329-345: sum of element sizes with
|
||||
// per-element alignment NOT padded — cstage uses raw sums for
|
||||
// tuples and 8B-rounding lives at the call/return ABI layer.
|
||||
// Slot layout is the tuple SSoT (tuple arc C-t0, user-ratified):
|
||||
// ti.size = ti.slotsize = per-element slot sum (tupleelemslot —
|
||||
// a str/slice its header, everything else one 8B eightbyte),
|
||||
// the stride cgen's cursor transport actually writes. ww-
|
||||
// internal ABI only (tuples never cross extern);
|
||||
// size((u32,u32))=16 is observable via size() and diverges from
|
||||
// Hare (harec type_store.c:533-580 anonymous-struct rule) AND
|
||||
// from ww's own structs (which pack narrow fields post-
|
||||
// fldloadop) — that internal inconsistency is what task #60
|
||||
// eventually fixes; re-open before any serialization/FFI/
|
||||
// density use. Pre-C-t0 ti.size was the packed raw sum while
|
||||
// cgen strode 8B slots — the checker-says-8/cgen-does-16 split
|
||||
// behind the packed-tuple miscompile family (#32/#33/#48).
|
||||
// Pre-bind for cycle protection (recursive tuple shapes).
|
||||
//
|
||||
// #61 A.5: ti.size = natural sum (cstage parity); ti.slotsize
|
||||
// = per-element slot sum mirroring cgenutil.ww:2018-2029
|
||||
// slotsize TTUPLE — narrow scalars pad to 8 (cgen spills each
|
||||
// tuple element into its own register / stack-slot eightbyte),
|
||||
// composites contribute their own ti.slotsize.
|
||||
r = newtype(tykind.TY_TUPLE);
|
||||
tinfocachebind(c.tc, n, r);
|
||||
// #57 A.6.3i-phase-1: populate r.tupleelems as a ttupleelem
|
||||
@@ -1818,37 +1829,32 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = {
|
||||
// size/align accumulator. Harec analog ref/harec/src/type_
|
||||
// store.c:532-589 tuple_init_from_atype — {type, offset, next}
|
||||
// per member onto type->tuple.next chain. Diverges from cstage
|
||||
// cmd/wcc/check.c:329-345 which stores tuple positionals on
|
||||
// t->params (Tparam, no offset, consumer recomputes by walking
|
||||
// at cgen.c:5723-5750); the offset-stored shape lets Phase
|
||||
// 2/J consumers (dotchainresolve) read offsets directly per
|
||||
// the A.6 stamp-once-read-many arc. Direct analog
|
||||
// 26724fe (#50 phase 1, A.6.3f-a) for the head/tail append
|
||||
// pattern. Offset matches cstage's raw-sum layout (no per-
|
||||
// element padding) — rule 10 aligns wwstage tuple layout down
|
||||
// to cstage, distinct from harec's add_padding(&offset,
|
||||
// memb.align) at type_store.c:561.
|
||||
// cmd/wcc/check.c N_TTUPLE which stores tuple positionals on
|
||||
// t->params (Tparam, no offset, consumer recomputes by
|
||||
// walking); the offset-stored shape lets consumers
|
||||
// (dotchainresolve) read offsets directly per the A.6
|
||||
// stamp-once-read-many arc. Direct analog 26724fe (#50 phase 1,
|
||||
// A.6.3f-a) for the head/tail append pattern. Offsets are
|
||||
// slot-cumulative (C-t0), distinct from harec's
|
||||
// add_padding(&offset, memb.align) at type_store.c:561.
|
||||
let teh: *ttupleelem = nil;
|
||||
let tet: *ttupleelem = nil;
|
||||
let total: u64 = 0u64;
|
||||
let slottotal: u64 = 0u64;
|
||||
let maxal: u64 = 1u64;
|
||||
let p: *node = n.list;
|
||||
for (p != nil) {
|
||||
let pt: *tinfo = tinfofornode(c, p.lhs);
|
||||
let elemoff: u64 = total;
|
||||
let te: *ttupleelem = alloc(ttupleelem{type_=pt, offset=elemoff, tnext=nil})!;
|
||||
let te: *ttupleelem = alloc(ttupleelem{type_=pt, offset=slottotal, tnext=nil})!;
|
||||
if (teh == nil) { teh = te; } else { tet.tnext = te; };
|
||||
tet = te;
|
||||
if (pt != nil) {
|
||||
if (pt.align > maxal) { maxal = pt.align; };
|
||||
total += pt.size;
|
||||
slottotal += tupleelemslot(pt);
|
||||
};
|
||||
p = p.next;
|
||||
};
|
||||
r.tupleelems = teh;
|
||||
r.size = total;
|
||||
r.size = slottotal;
|
||||
r.align = maxal;
|
||||
r.slotsize = slottotal;
|
||||
case nkind.N_TSTRUCT:
|
||||
|
||||
@@ -11926,8 +11926,15 @@ fn tupleelemslot(pt: *tinfo) u64 = {
|
||||
pk == tykind.TY_I32 || pk == tykind.TY_U8 ||
|
||||
pk == tykind.TY_U16 || pk == tykind.TY_U32 ||
|
||||
pk == tykind.TY_F32 || pk == tykind.TY_ENUM) { return 8u64; };
|
||||
// Composite — struct/tuple/array/tagged carry their own slot total.
|
||||
return t.slotsize;
|
||||
// Composite — one 8B eightbyte, NOT t.slotsize: cgen's cursor
|
||||
// transport strides `wide ? size : 8` at every tuple site (both
|
||||
// stages), so a composite element rides one register word today.
|
||||
// The checker mirrors what cgen emits (tuple arc C-t0; cstage
|
||||
// check.c N_TTUPLE twin) — a slotsize answer here would re-open the
|
||||
// checker-vs-cgen layout split the slot-SSoT ruling closed. No
|
||||
// composite-element tuple exists in the corpus; transport for >8B
|
||||
// composites is its own unwired gap.
|
||||
return 8u64;
|
||||
};
|
||||
|
||||
// #61 A.5 helper: per-field slot size mirroring cgenutil.ww
|
||||
@@ -12128,16 +12135,20 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = {
|
||||
r.align = storage.align;
|
||||
r.slotsize = storage.size;
|
||||
case nkind.N_TTUPLE:
|
||||
// Cstage cmd/wcc/check.c:329-345: sum of element sizes with
|
||||
// per-element alignment NOT padded — cstage uses raw sums for
|
||||
// tuples and 8B-rounding lives at the call/return ABI layer.
|
||||
// Slot layout is the tuple SSoT (tuple arc C-t0, user-ratified):
|
||||
// ti.size = ti.slotsize = per-element slot sum (tupleelemslot —
|
||||
// a str/slice its header, everything else one 8B eightbyte),
|
||||
// the stride cgen's cursor transport actually writes. ww-
|
||||
// internal ABI only (tuples never cross extern);
|
||||
// size((u32,u32))=16 is observable via size() and diverges from
|
||||
// Hare (harec type_store.c:533-580 anonymous-struct rule) AND
|
||||
// from ww's own structs (which pack narrow fields post-
|
||||
// fldloadop) — that internal inconsistency is what task #60
|
||||
// eventually fixes; re-open before any serialization/FFI/
|
||||
// density use. Pre-C-t0 ti.size was the packed raw sum while
|
||||
// cgen strode 8B slots — the checker-says-8/cgen-does-16 split
|
||||
// behind the packed-tuple miscompile family (#32/#33/#48).
|
||||
// Pre-bind for cycle protection (recursive tuple shapes).
|
||||
//
|
||||
// #61 A.5: ti.size = natural sum (cstage parity); ti.slotsize
|
||||
// = per-element slot sum mirroring cgenutil.ww:2018-2029
|
||||
// slotsize TTUPLE — narrow scalars pad to 8 (cgen spills each
|
||||
// tuple element into its own register / stack-slot eightbyte),
|
||||
// composites contribute their own ti.slotsize.
|
||||
r = newtype(tykind.TY_TUPLE);
|
||||
tinfocachebind(c.tc, n, r);
|
||||
// #57 A.6.3i-phase-1: populate r.tupleelems as a ttupleelem
|
||||
@@ -12145,37 +12156,32 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = {
|
||||
// size/align accumulator. Harec analog ref/harec/src/type_
|
||||
// store.c:532-589 tuple_init_from_atype — {type, offset, next}
|
||||
// per member onto type->tuple.next chain. Diverges from cstage
|
||||
// cmd/wcc/check.c:329-345 which stores tuple positionals on
|
||||
// t->params (Tparam, no offset, consumer recomputes by walking
|
||||
// at cgen.c:5723-5750); the offset-stored shape lets Phase
|
||||
// 2/J consumers (dotchainresolve) read offsets directly per
|
||||
// the A.6 stamp-once-read-many arc. Direct analog
|
||||
// 26724fe (#50 phase 1, A.6.3f-a) for the head/tail append
|
||||
// pattern. Offset matches cstage's raw-sum layout (no per-
|
||||
// element padding) — rule 10 aligns wwstage tuple layout down
|
||||
// to cstage, distinct from harec's add_padding(&offset,
|
||||
// memb.align) at type_store.c:561.
|
||||
// cmd/wcc/check.c N_TTUPLE which stores tuple positionals on
|
||||
// t->params (Tparam, no offset, consumer recomputes by
|
||||
// walking); the offset-stored shape lets consumers
|
||||
// (dotchainresolve) read offsets directly per the A.6
|
||||
// stamp-once-read-many arc. Direct analog 26724fe (#50 phase 1,
|
||||
// A.6.3f-a) for the head/tail append pattern. Offsets are
|
||||
// slot-cumulative (C-t0), distinct from harec's
|
||||
// add_padding(&offset, memb.align) at type_store.c:561.
|
||||
let teh: *ttupleelem = nil;
|
||||
let tet: *ttupleelem = nil;
|
||||
let total: u64 = 0u64;
|
||||
let slottotal: u64 = 0u64;
|
||||
let maxal: u64 = 1u64;
|
||||
let p: *node = n.list;
|
||||
for (p != nil) {
|
||||
let pt: *tinfo = tinfofornode(c, p.lhs);
|
||||
let elemoff: u64 = total;
|
||||
let te: *ttupleelem = alloc(ttupleelem{type_=pt, offset=elemoff, tnext=nil})!;
|
||||
let te: *ttupleelem = alloc(ttupleelem{type_=pt, offset=slottotal, tnext=nil})!;
|
||||
if (teh == nil) { teh = te; } else { tet.tnext = te; };
|
||||
tet = te;
|
||||
if (pt != nil) {
|
||||
if (pt.align > maxal) { maxal = pt.align; };
|
||||
total += pt.size;
|
||||
slottotal += tupleelemslot(pt);
|
||||
};
|
||||
p = p.next;
|
||||
};
|
||||
r.tupleelems = teh;
|
||||
r.size = total;
|
||||
r.size = slottotal;
|
||||
r.align = maxal;
|
||||
r.slotsize = slottotal;
|
||||
case nkind.N_TSTRUCT:
|
||||
@@ -22876,8 +22882,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
emitline("(BP), X0\n");
|
||||
return;
|
||||
};
|
||||
let sz: i32 = slotsize(c, tpt);
|
||||
let op: str = tnodeloadop(c, tpt, sz);
|
||||
// C-t0: load at the element's NATURAL
|
||||
// width (narrow MOVL/MOVSXD/... at the
|
||||
// slot base), not the 8B slot width —
|
||||
// byte-id twin of cstage's fldloadop
|
||||
// in the N_DOT TY_TUPLE arm.
|
||||
let nsz: i32 = 8;
|
||||
let tpti: *tinfo = tpt.type_: *tinfo;
|
||||
if (tpti != nil) { nsz = tpti.size: i32; };
|
||||
let op: str = tnodeloadop(c, tpt, nsz);
|
||||
emitline("\t");
|
||||
emitline(op);
|
||||
emitline("\t");
|
||||
|
||||
Reference in New Issue
Block a user