w6c: keep unwrap destination off the call stack

This commit is contained in:
2026-08-09 03:44:12 +09:00
parent a030268c52
commit edacb40bfe
3 changed files with 113 additions and 28 deletions

View File

@@ -3623,10 +3623,10 @@ fn cgdot(c: *cgen, n: *syntax.node) void = {
// IDENT(p)). Substitute the inner IDENT as dotlhs so the
// pointer-auto-deref branch (lhs.kind == N_IDENT && N_TPTR
// tnode) fires the same as `p.f`. Mirror of the N_ASSIGN N_DOT
// lhs retarget in cgassign. v1 scope: N_IDENT inner only;
// (*expr).f follow-up task pending. Enum-leaf lookup above and
// lhs retarget in cgassign. Enum-leaf lookup above and
// chained-N_DOT branches below keep checking raw lhs since
// (*p) is neither shape.
// (*p) is neither shape; remaining addressable bases use the
// shared place resolver.
let dotlhs: *syntax.node = lhs;
if (dotlhs != nil) {
if (dotlhs.kind == syntax.nkind.N_UN) {
@@ -8780,9 +8780,14 @@ fn cgassign(c: *cgen, n: *syntax.node) void = {
os.write(2, m16.ptr, m16.len: u64);
os.exit(1);
};
emitline("\tPUSHQ\tBX\n");
let dstscr: i32 = localadd(c, "@unwrapdst", 8, nil);
emitline("\tMOVQ\tBX, ");
emitoff(dstscr: i64);
emitline("(BP)\n");
cgexpr(c, n.rhs);
emitline("\tPOPQ\tBX\n");
emitline("\tMOVQ\t");
emitoff(dstscr: i64);
emitline("(BP), BX\n");
cgaggregstore(c, "BX", 0, ssz, false);
return;
};
@@ -10876,7 +10881,8 @@ fn cgassign(c: *cgen, n: *syntax.node) void = {
// is rare and not yet needed by our fixtures). Base accepts the
// explicit-deref form `(*p).f = ...` (parser N_UN(STAR, IDENT))
// by retargeting to the inner IDENT so the via_ptr branch fires
// the same as auto-deref `p.f = v`. v1 scope: bare-IDENT inner.
// the same as auto-deref `p.f = v`. Other addressable bases use
// the shared place resolver below.
if (lhs != nil) {
if (lhs.kind == syntax.nkind.N_DOT) {
let base: *syntax.node = lhs.lhs;