selfhost/cmd/wcc: variadic param N_TSLICE wrap at installparams (cascade Commit 3, #25/#41)
installparams normalises `T...` p.lhs to []T so N_IDENT lookups
(s.decl.lhs) and cgen's variadic-slot synthesis see the effective
slice — mirrors cstage check.c:455 `tp->type = type_slice(c->a, pt)`
and harec check_func_type. cgendecl/cgenexpr drop the on-the-fly
slicewrap and consume p.lhs directly; cgenexpr cgcall peels the
N_TSLICE wrap when reading the element predicates / esz (Ken's
gate: cstage cgen.c:4352 `vsu->kind == TY_SLICE`), and passes
`velem` — not the wrap — into cgwidentaggedstore (cstage cgen.c
:4382). Closes the 22 N_DOT + 9 N_INDEX fires from #36 with the
cascade absorbed by e662156 (#39 arm-6 recursion). Class B "case:
not a variant of scrutinee" did NOT fire post-#39, so Commit 2
(#40 tagged_select_subtype) was not needed.
This commit is contained in:
@@ -3078,29 +3078,42 @@ fn cgcall(c: *cgen, n: *node) void = {
|
||||
// scalars to 8, mismatching the stride at the
|
||||
// callee read site — runtime miscompile in
|
||||
// `(rune...)` callees per #36.
|
||||
// check.ww installparams promotes varp.lhs to
|
||||
// []T (mirrors cstage check.c:455 tp->type
|
||||
// wrap). Element predicates / esz read varp.lhs
|
||||
// .lhs; Ken's gate: only deref when the wrap
|
||||
// shape is confirmed N_TSLICE (mirrors cstage
|
||||
// cgen.c:4352 `vsu->kind == TY_SLICE` guard).
|
||||
let velem: *node = varp.lhs;
|
||||
if (varp.lhs != nil
|
||||
&& varp.lhs.kind == nkind.N_TSLICE) {
|
||||
velem = varp.lhs.lhs;
|
||||
};
|
||||
let esz: i32 = 8;
|
||||
if (varp.lhs != nil) {
|
||||
if (varp.lhs.kind == nkind.N_TNAME) {
|
||||
let ps: i32 = primsize(varp.lhs.str);
|
||||
if (velem != nil) {
|
||||
if (velem.kind == nkind.N_TNAME) {
|
||||
let ps: i32 = primsize(velem.str);
|
||||
if (ps > 0) { esz = ps; }
|
||||
else { esz = slotsize(c, varp.lhs); };
|
||||
else { esz = slotsize(c, velem); };
|
||||
} else {
|
||||
esz = slotsize(c, varp.lhs);
|
||||
esz = slotsize(c, velem);
|
||||
};
|
||||
};
|
||||
if (esz < 1) { esz = 1; };
|
||||
let velemtagged: bool = istaggedtype(c, varp.lhs);
|
||||
let velemstr: bool = isstrtype(c, varp.lhs);
|
||||
let velemslice: bool = isslicetype(c, varp.lhs);
|
||||
let velemtagged: bool = istaggedtype(c, velem);
|
||||
let velemstr: bool = isstrtype(c, velem);
|
||||
let velemslice: bool = isslicetype(c, velem);
|
||||
let doff: i32 = 0;
|
||||
if (nvar > 0) {
|
||||
doff = localadd(c, dname, nvar * esz, nil);
|
||||
};
|
||||
// #60: vararg gather builds a {ptr,len,cap} slice
|
||||
// descriptor — route through tyslicesize so #34's
|
||||
// slice-header bump propagates here.
|
||||
// slice-header bump propagates here. varp.lhs is
|
||||
// already the []T wrap from installparams, so we
|
||||
// consume it directly (re-slicewrap → [][]T).
|
||||
let soff: i32 = localadd(c, sname, tyslicesize(): i32,
|
||||
slicewrap(c, varp.lhs));
|
||||
varp.lhs);
|
||||
let aa2: *node = n.list;
|
||||
let kk3: i32 = 0;
|
||||
for (kk3 < nfixed_v) {
|
||||
@@ -3120,7 +3133,10 @@ fn cgcall(c: *cgen, n: *node) void = {
|
||||
for (aa2 != nil) {
|
||||
let slot: i32 = doff + j * esz;
|
||||
if (velemtagged) {
|
||||
cgwidentaggedstore(c, varp.lhs,
|
||||
// dst is the per-element tagged type;
|
||||
// pass velem (cstage cgen.c:4382 passes
|
||||
// velem, not the slice wrap vsu).
|
||||
cgwidentaggedstore(c, velem,
|
||||
aa2, "BP", slot, esz);
|
||||
} else { if (velemstr) {
|
||||
cgexpr(c, aa2);
|
||||
|
||||
Reference in New Issue
Block a user