wcc/ww: global-struct slice-field store widens the str arm to slices
A slice-typed field of a module-global struct stored only the str-form words; widen the arm to the full slice header via the g(SB) base (mirror cgen.c sibling arm). Review item #35; dual-stage rows red-proven.
This commit is contained in:
@@ -32994,12 +32994,16 @@ fn cgassign(c: *cgen, n: *node) void = {
|
||||
};
|
||||
if (n.op == tkind.TK_ASSIGN) {
|
||||
cgexpr(c, n.rhs);
|
||||
if (isstrtype(c, fi.tnode)) {
|
||||
// str IS []u8: cgexpr left
|
||||
// (AX=ptr, BX=len, CX=cap). CX
|
||||
// holds cap, so stage the base
|
||||
// addr in DX and store all three
|
||||
// words (#1/Phase 3).
|
||||
if (isstrtype(c, fi.tnode) || isslicetype(c, fi.tnode)) {
|
||||
// str OR slice field: str IS []u8, so
|
||||
// both store the full {ptr,len,cap}
|
||||
// header (cstage cgen.c:5055 gates
|
||||
// TY_STR||TY_SLICE the same; without the
|
||||
// slice arm this dropped to the 1-word
|
||||
// scalar store below). cgexpr left
|
||||
// (AX=ptr, BX=len, CX=cap). CX holds cap,
|
||||
// so stage the base addr in DX and store
|
||||
// all three words (#1/Phase 3).
|
||||
emitline("\tLEAQ\t");
|
||||
emitsymname(c, bn);
|
||||
emitline("(SB), DX\n");
|
||||
|
||||
@@ -10230,12 +10230,16 @@ fn cgassign(c: *cgen, n: *node) void = {
|
||||
};
|
||||
if (n.op == tkind.TK_ASSIGN) {
|
||||
cgexpr(c, n.rhs);
|
||||
if (isstrtype(c, fi.tnode)) {
|
||||
// str IS []u8: cgexpr left
|
||||
// (AX=ptr, BX=len, CX=cap). CX
|
||||
// holds cap, so stage the base
|
||||
// addr in DX and store all three
|
||||
// words (#1/Phase 3).
|
||||
if (isstrtype(c, fi.tnode) || isslicetype(c, fi.tnode)) {
|
||||
// str OR slice field: str IS []u8, so
|
||||
// both store the full {ptr,len,cap}
|
||||
// header (cstage cgen.c:5055 gates
|
||||
// TY_STR||TY_SLICE the same; without the
|
||||
// slice arm this dropped to the 1-word
|
||||
// scalar store below). cgexpr left
|
||||
// (AX=ptr, BX=len, CX=cap). CX holds cap,
|
||||
// so stage the base addr in DX and store
|
||||
// all three words (#1/Phase 3).
|
||||
emitline("\tLEAQ\t");
|
||||
emitsymname(c, bn);
|
||||
emitline("(SB), DX\n");
|
||||
|
||||
@@ -32994,12 +32994,16 @@ fn cgassign(c: *cgen, n: *node) void = {
|
||||
};
|
||||
if (n.op == tkind.TK_ASSIGN) {
|
||||
cgexpr(c, n.rhs);
|
||||
if (isstrtype(c, fi.tnode)) {
|
||||
// str IS []u8: cgexpr left
|
||||
// (AX=ptr, BX=len, CX=cap). CX
|
||||
// holds cap, so stage the base
|
||||
// addr in DX and store all three
|
||||
// words (#1/Phase 3).
|
||||
if (isstrtype(c, fi.tnode) || isslicetype(c, fi.tnode)) {
|
||||
// str OR slice field: str IS []u8, so
|
||||
// both store the full {ptr,len,cap}
|
||||
// header (cstage cgen.c:5055 gates
|
||||
// TY_STR||TY_SLICE the same; without the
|
||||
// slice arm this dropped to the 1-word
|
||||
// scalar store below). cgexpr left
|
||||
// (AX=ptr, BX=len, CX=cap). CX holds cap,
|
||||
// so stage the base addr in DX and store
|
||||
// all three words (#1/Phase 3).
|
||||
emitline("\tLEAQ\t");
|
||||
emitsymname(c, bn);
|
||||
emitline("(SB), DX\n");
|
||||
|
||||
Reference in New Issue
Block a user