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 asd9f0972: `*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, mirrors368b85e. Verified 132/132 + 995_self_rebuild byte-identity.
This commit is contained in:
@@ -97,17 +97,18 @@ fn bufinit(b: *buf, a: *arena) void = {
|
||||
b.a = a;
|
||||
b.cap = 256u64;
|
||||
b.n = 0u64;
|
||||
b.p = amalloc(a, b.cap): *u8;
|
||||
let np: []u8 = alloc([], b.cap)!;
|
||||
b.p = np.ptr;
|
||||
};
|
||||
|
||||
fn bufgrow(b: *buf, need: u64) void = {
|
||||
if (b.n + need <= b.cap) { return; };
|
||||
let nc: u64 = b.cap;
|
||||
for (nc < b.n + need) { nc = nc * 2u64; };
|
||||
let np: *u8 = amalloc(b.a, nc): *u8;
|
||||
let np: []u8 = alloc([], nc)!;
|
||||
let i: u64 = 0u64;
|
||||
for (i < b.n) { np[i] = b.p[i]; i += 1u64; };
|
||||
b.p = np;
|
||||
b.p = np.ptr;
|
||||
b.cap = nc;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user