wcc/ww: chained-index str/slice element loads the full header

cgindex read one word for a str/slice ELEMENT of a chained index
(xs[i][j], f().s[i]) — the element-kind gate keyed on node shape and
missed non-simple bases, dropping the 24B/16B header load (review
finding #22). Key on the element-type stamp; 989_chainidx_run pins
cs==ww (red 3/8 pre-fix).
This commit is contained in:
2026-06-12 00:07:45 +09:00
parent cbbfd1a4a6
commit f25f5021d7
5 changed files with 246 additions and 9 deletions

View File

@@ -24573,13 +24573,23 @@ fn cgindex(c: *cgen, n: *node) void = {
// stamped outer element tinfo (indexresult over the inner
// index's value type). cstage reads base->type->sub->size
// for esz (cmd/w6c/cgen.c:2070-2071). Drops the
// indexvaluetnode walk. Kept as its OWN arm (it does not set
// elemisstr/elemisslice) so the chained-index byte-id is
// preserved verbatim; the catch-all below would re-stamp it.
// indexvaluetnode walk.
// #22 (F7-c3): also stamp elemisstr/elemisslice off the same
// chased element tinfo. Without them a chained index whose
// element is a str/slice (`m[i][k]` over [N][M]str) loaded
// only the ptr word — the 24B/16B header (len/cap) was
// dropped (stale BX/CX) → garbage .len downstream. cstage's
// idx_eff path classifies the element uniformly via
// type_isstr/type_isslice (cmd/w6c/cgen.c); align ww UP by
// reading the SAME stamp the esz read above uses. CLASS-N:
// the corpus has no chained str/slice element, so the prior
// byte-id is preserved (this only fires on the missed shape).
let et: *tinfo = n.type_: *tinfo;
if (et != nil) {
esz = et.size: i32;
signed_elem = typeissigned(et);
elemisstr = typeisstr(et);
elemisslice = typeisslice(et);
float_elem = typeisfloat(et);
f32_elem = typeisf32(et);
elem_isarray = tinfoisarray(et);

View File

@@ -1875,13 +1875,23 @@ fn cgindex(c: *cgen, n: *node) void = {
// stamped outer element tinfo (indexresult over the inner
// index's value type). cstage reads base->type->sub->size
// for esz (cmd/w6c/cgen.c:2070-2071). Drops the
// indexvaluetnode walk. Kept as its OWN arm (it does not set
// elemisstr/elemisslice) so the chained-index byte-id is
// preserved verbatim; the catch-all below would re-stamp it.
// indexvaluetnode walk.
// #22 (F7-c3): also stamp elemisstr/elemisslice off the same
// chased element tinfo. Without them a chained index whose
// element is a str/slice (`m[i][k]` over [N][M]str) loaded
// only the ptr word — the 24B/16B header (len/cap) was
// dropped (stale BX/CX) → garbage .len downstream. cstage's
// idx_eff path classifies the element uniformly via
// type_isstr/type_isslice (cmd/w6c/cgen.c); align ww UP by
// reading the SAME stamp the esz read above uses. CLASS-N:
// the corpus has no chained str/slice element, so the prior
// byte-id is preserved (this only fires on the missed shape).
let et: *tinfo = n.type_: *tinfo;
if (et != nil) {
esz = et.size: i32;
signed_elem = typeissigned(et);
elemisstr = typeisstr(et);
elemisslice = typeisslice(et);
float_elem = typeisfloat(et);
f32_elem = typeisf32(et);
elem_isarray = tinfoisarray(et);

View File

@@ -24573,13 +24573,23 @@ fn cgindex(c: *cgen, n: *node) void = {
// stamped outer element tinfo (indexresult over the inner
// index's value type). cstage reads base->type->sub->size
// for esz (cmd/w6c/cgen.c:2070-2071). Drops the
// indexvaluetnode walk. Kept as its OWN arm (it does not set
// elemisstr/elemisslice) so the chained-index byte-id is
// preserved verbatim; the catch-all below would re-stamp it.
// indexvaluetnode walk.
// #22 (F7-c3): also stamp elemisstr/elemisslice off the same
// chased element tinfo. Without them a chained index whose
// element is a str/slice (`m[i][k]` over [N][M]str) loaded
// only the ptr word — the 24B/16B header (len/cap) was
// dropped (stale BX/CX) → garbage .len downstream. cstage's
// idx_eff path classifies the element uniformly via
// type_isstr/type_isslice (cmd/w6c/cgen.c); align ww UP by
// reading the SAME stamp the esz read above uses. CLASS-N:
// the corpus has no chained str/slice element, so the prior
// byte-id is preserved (this only fires on the missed shape).
let et: *tinfo = n.type_: *tinfo;
if (et != nil) {
esz = et.size: i32;
signed_elem = typeissigned(et);
elemisstr = typeisstr(et);
elemisslice = typeisslice(et);
float_elem = typeisfloat(et);
f32_elem = typeisf32(et);
elem_isarray = tinfoisarray(et);