selfhost/cmd/w6a+w6l: rt.malloc/amalloc β grow → alloc([], n)! (β-2)

Phase 0 second β-batch. 6 alloc sites across 3 β grow loops:
 - selfhost/cmd/w6a/obj.ww:100,108  buf bufinit/bufgrow (amalloc)
 - selfhost/cmd/w6a/asm.ww:26,63    asm_ emitbyte/emitdatabyte text+data (rt.malloc)
 - selfhost/cmd/w6l/obj.ww:113,135  lnk emittext/emitdata text+data (rt.malloc)

Same β shape as d9f0972: `*u8 = (rt.malloc|amalloc)(_, n): *u8`
→ `[]u8 = alloc([], n)!`, inner copy bounded by the manual length
counter (b.n / textlen / datalen) unchanged, struct field stays
*u8, writeback via .ptr. Bear-trap N/A (slice .len = 0 never read).

w6a/asm.ww `import rt;` (line 15) is now dead — deferred to a
post-Phase-0 import-hygiene sweep, mirrors 368b85e.

Verified 132/132 + 995_self_rebuild byte-identity.
This commit is contained in:
2026-05-21 09:38:40 +09:00
parent d9f097250b
commit f07a032104
5 changed files with 24 additions and 22 deletions

View File

@@ -110,13 +110,13 @@ fn emittext(l: *lnk, src: *u8, n: u64) void = {
// Grow by mmap'ing a fresh region and copying. The old buffer
// is leaked into the page allocator; for a linker run this is
// trivial waste.
let nb: *u8 = rt.malloc(nc): *u8;
let nb: []u8 = alloc([], nc)!;
let i: u64 = 0u64;
for (i < l.textlen) {
nb[i] = l.text[i];
i += 1u64;
};
l.text = nb;
l.text = nb.ptr;
l.textcap = nc;
};
let i: u64 = 0u64;
@@ -132,13 +132,13 @@ fn emitdata(l: *lnk, src: *u8, n: u64) void = {
let nc: u64 = l.datacap;
if (nc == 0u64) { nc = 256u64; };
for (nc < l.datalen + n) { nc = nc * 2u64; };
let nb: *u8 = rt.malloc(nc): *u8;
let nb: []u8 = alloc([], nc)!;
let i: u64 = 0u64;
for (i < l.datalen) {
nb[i] = l.data[i];
i += 1u64;
};
l.data = nb;
l.data = nb.ptr;
l.datacap = nc;
};
let i: u64 = 0u64;