Skip to content

Wave 4: []mut T stages 2-3 (#604), borrow &InternPool/&AstPool across phases (#2523), migrate alloca & C11 atomics (D259, #955) - #3675

Draft
ehartford wants to merge 4 commits into
mainfrom
wave4
Draft

ehartford wants to merge 4 commits into
mainfrom
wave4

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Bundled Wave 4 changes (one clean commit per logical issue):

  1. []mut T stages 2–3 (#604) — 8d1ecffe5

    • Allow []mut T local bindings, function return types (checked by §21.1 Rule 6), and slicing mutable arrays/List under []mut T expected type; keep []mut T rejected in struct/union fields (§4.8a).
    • Register exclusive NLL borrows for []mut T bindings, expire dead/reborrowed borrows at final use, and allow disjoint halves from the same split_at_mut lineage to coexist while rejecting reads/writes of the source or parent slice while a half is live.
    • Lower split_at_mut on List, arrays, and slices to return ([]mut T, []mut T) with COW uniqueness in MIR (MirIntrinsic.SPLIT_AT_MUT) and byte-offset fat pointers in LLVM codegen.
    • Added 6 new behavior & compile-error tests (verified leak count=0 under --debug-alloc) and updated Stage-1 placeholder tests.
  2. One InternPool and one AstPool per compilation (#2523) — 95e2887b9

    • Converted compiler phases (AsyncLower, MirBuilder, CCodegen, Codegen, Parser, ResolveState, ComptimeEvaluator) to borrow &AstPool / &InternPool instead of cloning handles.
    • Replaced Zcu.typed_pool_cache with typed_pool_identity: i64, removed Zcu.backend_intern/backend_ast clones and Codegen.init_with_opt throwaway pool allocations, removed self.ast.clone() in SemaCheck via ct_eval_truthy_self, and documented every remaining genuine second-holder .clone() site.
    • Removed both the #2449 and D172 clone-call src allowance lines from build/ceremony-allowances.tsv (clone-call in src fell 60 -> 38, move-arg in src fell 275 -> 267).
  3. with migrate: __builtin_alloca/alloca and C11 <stdatomic.h> builtins (D259, #955) — 6d7047a79

    • Recorded delegated decision D259 (docs/meetings/2026-11-28-D259-migrator-alloca-and-c11-atomics.md).
    • Lowered __builtin_alloca(n) / alloca(n) to a per-function arena (with_arena_new(4096) + defer: with_arena_free(__ci_alloca) + 16-byte aligned with_arena_alloc_aligned) so dynamic and loop allocations keep distinct addresses until function return with zero leaks.
    • Extended ci_atomic_builtin_name, lower_atomic_expr_ir, and lower_value_expr_ir to lower C11 <stdatomic.h> / __c11_atomic_* operations and atomic_thread_fence onto std.sync.Atomic[T] and std.sync.fence.
    • Fixed raw-pointer arrow member access on arrays of pointers (arr[i]->field) in src/CiPrint.with.
    • Added test/behavior/behav_955_migrate_alloca_and_c11_atomics.with (verified leak count=0 under --debug-alloc).

Closes #604
Closes #2523
Progress on #955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant