Repository navigation
Conversation
…er's holder count in its allocation header (list_holders, with_vec_retain, with_vec_release_last, with_vec_is_unique, with_vec_make_unique_bits), Sema's is_copy of a List of values, and the LIST_MAKE_UNIQUE intrinsic name. Codegen's retain and release-last gate, the make-unique emission (CodegenDispatch, CCodegen, Analysis) and MIR's insertion before every List mutation are the rest of the stage.
…s is_copy(T). Runtime: the buffer's holders beyond the first in its allocation header's second word (list_holders; an over-aligned buffer's block holds it; a compiler-owned static buffer is never counted, written in place or freed), with_vec_retain, with_vec_release_last, with_vec_is_unique, with_vec_make_unique_bits. Codegen: a List copy retains (mir_emit_copy_glue_ptr), the List drop runs its element drops and free only for the last holder, and LIST_MAKE_UNIQUE copies a shared buffer before a mutation, then runs the element copy glue over the fresh buffer. MIR: make_unique_before_mutation on the receiver place before every writing List intrinsic (push, set, remove, clear, pop, extend, slot, iter_place, get_disjoint, restore_front, take_front) and before a mut self method of a value List. The C backend copies bits and refuses, loudly, a list whose elements carry copy glue. Test: a copy leaves its source alone, through three generations and a List[str]; a List[Tok] still moves.
…eled (§16.11), not 'v as i64', which under D120 copies the now-Copy List (D22 §6.2) and has no cast to an integer
…teps away from a shared buffer instead of freeing it, and the buffer free releases a shared buffer instead of freeing it, so a mutation or drop path the lowering missed is memory-safe; release_last never decrements the sole holder; an element write by index (xs[i] = v) makes the list unique first; no explicit & at list_data_i64 and no discarded-call binding
…he receiver is the call's first argument; the one before covered only the len/payload path, so no mutation was ever made unique — found by nm: with_vec_make_unique_bits was never linked), the intrinsic last in MirIntrinsic, a value List cast into or out of its distinct type retains a copy and consumes a temporary (the ordinary cast path, now that a List is Copy), the C backend emits one definition per string constant, and WITH_TRACE_COW=1 prints every make-unique decision
… a move on List[i32] (the canonical non-Copy type until D120) now pin it on a List of a Drop type, Tok (tools/d120_fixture_sweep.w did the mechanical part: the element type, number and string list literals, push arguments, the expectation line; five were finished by hand — a List[u8] field, an expectation's line number, two fixtures with their own Tok enum); the bundle-interface once check consumes a List of a Drop type; the move audit expects a value List's field to copy on every form, as a str's does, while an explicit move still invalidates (105 cells, 0 vs-expected, 0 vs-baseline)
…(inspect, inspect_err, context, with_context retire the subject) is taken, not retained — a value List payload held one count too many and leaked; the C backend's copy-on-write of a List[str] copies each element of the fresh buffer with with_str_clone_ref (other glue elements still refuse, loudly)
…time/with_runtime.h, and the C output makes a list unique by its bits for every element type, as it copies every value by its bits (the element copy glue is the LLVM backend's)
…bove 0: a compiler-owned literal has capacity 0, D119), not by asking the allocator — rt_payload_start_is_owned walked the slab tables at every push and free and cost a third of the self-host check (45.4 s to 60.3 s, three interleaved rounds); tools/ab_bench.w is the interleaved A/B measurement the D120 gate asks for
|
Second interleaved set on the tip (6e6d6ab), same workload:
Every round above 1.02: by the ruling this is a counted regression, the merge holds, and the call is Eric's (optimize first, accept, or revisit). Where the cost lands ( Not yet measured: the pcre2/zlib suites and the three microbenchmarks. A battery on this tip is running. |
|
Battery on the tip 6e6d6ab: green, 344 s ( |
… bar is 5%; the plan and tools/ab_bench.w's verdict follow
|
Eric, 2026-10-16: "relax the bar to 5%" — D120 Amendment 1, recorded in the decision record and the plan; |
D120 stage 1 of
docs/proposals/d120-implementation-plan.md: aListof values is a value.List[T]is Copy whenTis; a copy shares the buffer under an atomic holder count in the allocation header (thestrdesign, D111); the first mutation of a shared buffer copies it; aListof resources moves as before.Pieces. Sema
is_copy(a List generic instance follows its element). Runtime:list_holders,with_vec_retain,with_vec_release_last,with_vec_is_unique,with_vec_make_unique_bits(a compiler-owned literal has capacity 0 and is never counted, written in place or freed; over-aligned buffers keep the count in their block). Codegen: a List copy retains; the List drop drops elements and frees only for the last holder;LIST_MAKE_UNIQUEcopies a shared buffer and runs the element copy glue over the fresh one. MIR:make_unique_before_mutationbefore every writing List intrinsic, amut selfmethod of a value List, an index write; a payload forwarded out of a decomposed Result carrier is taken, not retained; a value List cast into or out of its distinct type retains a copy or consumes a temporary. Runtime nets: a growing or freed shared buffer is released, never freed, so a missed path is memory-safe. emit-c: bits-only make-unique, prototypes inwith_runtime.h.Fallout under the ruling. 64 compile-error fixtures pinned a move on
List[i32];tools/d120_fixture_sweep.wmoved them onto a List of a Drop type (five finished by hand). The bundle-interfaceoncefixture, the move audit's vec field cells (copy like a str's; explicitmovestill invalidates),Codegen.list_data_i64's address cast.Found on the way. The intrinsic must be last in
MirIntrinsic; the make-unique hook at the wrong call path meant no mutation was ever made unique (nmshowed the runtime symbol unlinked) and the compiler's own paths went wrong when self-compiled;WITH_TRACE_COW=1prints each decision.Battery: green (battery5, 560 s) at the commit before the final runtime change; a battery on the tip follows.
The 2% gate (
tools/ab_bench.w, interleaved A B A B, baseline = installed main 007fdb2, candidate = this tree's release, workloadcheck src/main.w):The remaining cost is the check itself at every mutation (the plan's stage 4 hoists it) and the retain/release at copies. The pcre2/zlib suite A/B and the three microbenchmarks are not measured yet. Held for Eric's call per the ruling: not merged.