cgen: build the full slice header in the unwrap success shuffle (#6 Mech B)
The N_TRYUNW/N_TRYPROP success shuffle materialized {ptr,len,cap} into {AX,BX,CX} only when the success variant was a str; a slice success got only MOVQ DX,AX (ptr), leaving every slice-unwrap consumer (call-arg push, let-receive store, ident-source) reading junk .len/.cap — silent on BOTH stages (byte-id blind, cstage not the oracle). Widen the success gate to type_isstr||type_isslice (cstage) / typeisstr||typeisslice (wwstage) at all four shuffle sites; str and slice share the identical 24B header shuffle. Stays str||slice-specific — a struct success variant uses a different {AX,DX,CX} ABI (task #12). Value-asserting pin (len!=cap, poison-decoy) reddens under each stage's independent revert.
Follows #6 Mech A (Fix-R); order forced (C1 first or the slice call-arg push reddens byte-id).
This commit is contained in:
@@ -519,9 +519,14 @@ fn cgtryprop(c: *cgen, n: *syntax.node) void = {
|
||||
// shape, any variant order), not a name-keyed call-only lookup of
|
||||
// the first variant. Mirrors cstage cgen.c:10459-10466
|
||||
// (success_is_str = type_isstr(succ_t at cg_tagged_success_tag)).
|
||||
// #6 (Mech B): a slice success variant shares str's 24B {ptr,len,cap}
|
||||
// header in the tagged ABI {DX,CX,R8}; widen the gate so slice rides
|
||||
// the same shuffle. A struct/aggregate success uses a different
|
||||
// {AX,DX,CX} ABI (separate latent, task #12) — keep str||slice-specific.
|
||||
let succisstr: bool = false;
|
||||
if (n.lhs != nil) {
|
||||
succisstr = syntax.typeisstr(successvariant(n.lhs.type_: *syntax.tinfo));
|
||||
let sv: *syntax.tinfo = successvariant(n.lhs.type_: *syntax.tinfo);
|
||||
succisstr = syntax.typeisstr(sv) || syntax.typeisslice(sv);
|
||||
};
|
||||
if (succisstr) {
|
||||
// str IS []u8: success arrives DX=ptr, CX=len, R8=cap
|
||||
@@ -586,9 +591,13 @@ fn cgtryunw(c: *cgen, n: *syntax.node) void = {
|
||||
// Unwrap success value. (Same shuffle pattern as cgtryprop.)
|
||||
// #16: stamped success-variant type, any source/order (twin of
|
||||
// cgtryprop; cstage cgen.c:10595-10602).
|
||||
// #6 (Mech B): slice success shares str's 24B header in the tagged
|
||||
// ABI {DX,CX,R8} — widen the gate (twin of cgtryprop). Struct/aggregate
|
||||
// success uses a different {AX,DX,CX} ABI (task #12) — str||slice only.
|
||||
let succisstr: bool = false;
|
||||
if (n.lhs != nil) {
|
||||
succisstr = syntax.typeisstr(successvariant(n.lhs.type_: *syntax.tinfo));
|
||||
let sv: *syntax.tinfo = successvariant(n.lhs.type_: *syntax.tinfo);
|
||||
succisstr = syntax.typeisstr(sv) || syntax.typeisslice(sv);
|
||||
};
|
||||
if (succisstr) {
|
||||
// str IS []u8: success arrives DX=ptr, CX=len, R8=cap
|
||||
|
||||
Reference in New Issue
Block a user