Skip to content

D119: migrator array spelling, guaranteed no-heap List lowering, migrator List rule #2301

Closed

Description

@ehartford

Ruling D119 (2026-10-09). In order, after D118's rename:

  1. Migrator spelling: emit [T; N] (not [N]T), type elements by the array's element type instead of casting each one, sizeof(t)/sizeof(t[0]) → t.len(); re-migrate the four corpora (D112). Today: 878 [N]T arrays with per-element casts.
  2. Guaranteed lowering (§4.3c): a List literal never pushed, grown, moved out, stored or retained lives on the stack or in static data. Gate: allocation-count test (today let t = [1, 2, 3, 4] in a function called 1000 times makes 1003 allocations; must be 3).
  3. Migrator rule (with-migrate-spec.md, Arrays): local and file-scope arrays → List literals (zero fill of the length for buffers; List[[T; N]] for 2-D locals; data pointer + length when the address goes to C); struct/union fields stay [T; N]. Benchmark each corpus against its C before and after.

Activity

  1. ehartford commented on Oct 12, 2026

    @ehartford
    ContributorAuthor

    Step 2 (the guaranteed no-heap lowering) is in the tree: mir_mark_stack_literals (MirLower, §4.3c) and the frame-resident build in mir_emit_collection_literal_intrinsic_call. Measured on main c97a00852 with the installed compiler: fn f(i: i32) -> i32: let t = [1, 2, 3, 4]; t[0] + i called a thousand times reports allocations=3 under --debug-alloc, the same three a print(1) program makes, so the literal costs nothing per call (the issue's gate asked for 3; it was 1003). The gate fixture test/debug_alloc/da_d119_literal_no_heap.w (expect allocations=3) goes in with the next stack (~/.local/with-staging/da_d119_literal_no_heap.w).

    Step 1 (migrator spelling [T; N], no per-element casts, sizeof ratio → len(), re-migration) landed earlier on branch d119-spelling per the campaign memory; step 3 (the migrator's List rule for locals and tables, with each corpus benchmarked against its C) is the remaining item and is migrator work (CiMigrate.w "Arrays"), separate from the compiler guarantee.

  2. added 3 commits that reference this issue on Oct 12, 2026
  3. ehartford commented on Oct 12, 2026

    @ehartford
    ContributorAuthor

    D119 step 3 landed in #2364 (squash ede7749, battery GREEN on 23db29c: gate rc=0, uat rc=0, battery-checks rc=0). Steps 1-2 were already on main; this completes the migrator's List rule. The step also fixed, each with a fixture: §9.1c stable-global storage (a stable List global is writable static data, and a migrated file-scope array declares a stable binding, since C cannot assign an array and a var List global cannot cross a bundle), and Emit-C declaring struct types reached only as container elements.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions