Repository navigation
Phase 2: TommyDS corpus as the fourth .wo bundle, header-inline ownership in the migrator, HashIndex facade - #1141
Merged
Merged
Conversation
added 13 commits
September 14, 2026 08:44
…on typedef is a function pointer __builtin_clz/ctz/popcount (and the l/ll forms) lower structurally to (x as u32).clz() / u64 for the wide forms; __builtin_bswapN to .swap_bytes() on the N-bit unsigned (TommyDS tommy_ilog2/tommy_ctz). A CIE_FIELD with d2=2 is a method selected on a value and prints as base.method. A pointer whose pointee is a typedef of a function prototype (tommy_compare_func*) canonicalizes to the function pointer instead of *mut fn. Fixtures: behav_migrate_bit_builtins, behav_migrate_fn_typedef_pointer.
The runtime seam behind std.libc's portable mach_absolute_time (next commit): the same value on every target.
The migrator's libc allowlist admits qsort/rand/srand and mach_absolute_time/mach_timebase_info(_data_t)/kern_return_t (previous migrate commit). mach_absolute_time is the runtime's monotonic clock in nanoseconds and mach_timebase_info reports 1/1, so TommyDS's check.c timing code migrated on macOS computes nanoseconds on every target. Fixtures: behav_migrate_libc_qsort_clock (portable), behav_migrate_libc_mach_clock (darwin-only migration).
build/tommyds.w pins amadvance/tommyds 1f3727fc, migrates the 13 units (tommy.c, the amalgamation, excluded) plus check.c as the harness (module check_: check collides with the prelude), promotes to lib/std/tommyds/, and runs tommycheck as the corpora lane tommyds-test. tommy_wo is wired at every site calg_wo is; the corpus leaves the embedded stdlib in build.w and build/runtime.w; std.tommyds is an internal module. The corpus is the migration's output, never hand-edited.
…it of the same name A `static inline` function defined in a header is that header's API (TommyDS keeps tommy_hashdyn_search, tommy_hashlin_search and the tommy_inthash family in its headers); every includer compiled a private copy, so nothing outside the corpus could call them. The project scan now registers such a definition as owned by the unit whose stem matches the header's (tommyhashdyn.c for tommyhashdyn.h); that unit publishes it and every other unit imports it. A header no unit owns keeps a private copy per includer as before. Fixture: behav_migrate_header_inline_owner.
…n imported inline get their unsafe context The ownership rule from ff4c58b also published a unit's own static inline helpers (tommyhashdyn.c's hashdyn_grow_step) because their location stem matched the unit; a definition is a header's API only when it sits in a header. And a consumer unit's calls to an imported header inline with raw parameters were emitted without an unsafe context, because the unsafe-callee scan skipped every static function; a header-owned one is treated like any imported raw function. The fixture covers both: user_probe runs through the published engine_peek, engine_scale stays private.
tommy_hashdyn_search, tommy_hashlin_search, tommy_hashtable_search and the tommy_list/tommy_inthash inlines are published by their units and imported by every other unit (1,469 lines of private copies gone); check_.w resolves them through the imports. bundle.w is the root the migrate action writes. tommycheck passes.
…engine Node ownership for an intrusive engine (docs/stdlib_sourcing_plan.md, Phase 2): the facade owns every node in one heap slot per entry: the node first, so the engine's node pointer is the slot, then the key comparator the one C trampoline reads, then the key and value. get observes, remove and a replacing insert transfer, clear and drop walk the buckets and release every slot exactly once; lookups reuse one probe slot. Behavior test, complexity row (hash-index, linear), drop-audit cells, and test/benchmark/hash_engines.w (facade vs raw engines vs rt_core HashMap).
Contributor
Author
|
Battery at 376daee, local: |
ehartford
added a commit
that referenced
this pull request
Sep 14, 2026
* Centralize callable, closure, and destructor ABI descriptors Compute immutable FnAbi/ArgAbi records once and share them across named declarations, callable types, adapters, prologues, and call marshalling. Remove parallel ABI tables and 64-bit parameter masks. Preserve owned destructor storage across body/field cleanup without reclassifying it as a borrow. Extend declaration/call audits to check descriptor shapes and actual byval attributes. LLDB evidence: raw_fn_type selected internal_abi_needs_sret=false for a large indirect C return; declare_function_at_inner's owner-type shortcut registered consuming parameters as references. The 65th C aggregate's attribute was skipped at apply_c_abi_byval_attrs+120: x25=64, x8=0, x22=0xffffffffffffffff after the out-of-range shift check. Restore the function-level temporary frame in default trait methods. The native allocator traced one leaked 16-byte clone through Person.name; register_stmt_temp+36 had x0=0, local=2, type=16 and skipped registration from generate_default_trait_method_for_impl. Track the audit's missing synthesized-body ownership coverage in #1117. Validation: source check and -O1 stage1 build; five-target callable and c_va_list IR/audit matrices; 65-parameter aggregate audit; native callback and consuming-receiver results; default-tail and consumed-field allocator fixtures report leak count=0. Full bootstrap battery follows this commit. Refs #1106 * Complete async and wide default-method ABI declarations Register async declarations from finalized signatures, preserving inferred Unit, scalar and aggregate returns. Remove the obsolete 64-parameter default-method guard now that FnAbi uses vectors. Proof: compiler audit identified task_cancel_point missing FnAbi; LLDB declare_async_function showed direct LLVM type construction with an i32 default and no descriptor registration. Wide method LLDB observed w8=66 at generate_default_trait_method_for_impl +1052, taking the >64 early return; IR called undef. Native regressions now return async ok and wide default ok; five-target async audits report zero violations. Audit target-coverage gap filed as #1119. * Lower bare trait objects consistently in FnAbi descriptors The centralized descriptor path exposed missing TY_TRAIT_OBJ branches in both semantic and MIR LLVM type mapping. Share the existing dyn layout and cover direct and callable trait-object arguments. LLDB proof: sema_type_to_llvm and mir_sema_type_to_llvm received kind 17 and returned x0=0 into type_fallback (sealed-kind-proof.txt and dyn-mir-kind-proof.txt under out/fnabi-validation). The MIR fallback produced an i32 parameter for an actual struct{ptr,ptr} argument. Both routes now return the shared dyn type. Validation: source check, stage1 rebuild, sealed_trait_match native test, dyn callback native run, and callable audit:all on all five targets pass. * Preserve source field identity for compiler-modeled records Resolve unregistered LLVM aggregate fields through their MIR source owner, including projected places and reordered literals. Diagnose a failed projected assignment instead of silently emitting an unreachable body. LLDB proof: mir_resolve_field_index returned -1 for generation with two LLVM elements; mir_place_ptr returned zero and mir_emit_stmt took its silent false return at the projected assignment (handle-field-proof.txt). The Handle mapper constructs an anonymous LLVM struct with no field-name registry. SlotMap.ptr reads also lost the field identity. Audit accepted the assignment-last repro with zero violations; #1120 records that tool gap alongside the codegen bug. Validation: compiler source check, -O1 stage1, native field matrix (local, return, reordered literal, nested receiver, tuple, array, Vec), audit:all, SlotMap generation-exhaustion test, and debug allocator pass. Refs #1120 * Add stdlib complexity gates and constant-time SlotMap reuse Inventory current engines and future algorithm families; add an optimized N/4N complexity lane to :test with correctness checks and explicit #937/#938 expected failures. Add opt-in allocation request tracing and empty/positive controls to measure #939's temporary buffers independently of leak reporting. Replace SlotMap's occupancy scan with a FIFO free list and permanently retire exhausted generations. Record the runtime header change as ABI v4. Extend native, spec, allocator, and drop-audit coverage for reuse, growth and cleanup. Exact baseline evidence: LLDB with_slotmap_insert_out+120 observed occupied index zero taking the scan branch (slotmap-scan-proof.txt); with_slotmap_remove +156 observed w20=0xffffffff entering checked-add overflow at rt_core.w:2961 (slotmap-generation-add-proof.txt). The runtime allocator route used the test runner's retained binary with WITH_ALLOC_NO_REUSE=1 and --debug-alloc. Validation so far: runtime source checks and -O1 objects on all five targets; compiler/build/tool source checks; stage1; all SlotMap spec/FIFO tests; exactly 130 Drop calls with zero leaks; optimized complexity cases pass with the known cliffs recorded, and trace controls observe 0/1/6 allocations. Full bootstrap, fixpoint and suite verification follows this commit. Refs #936, #1118 * Preserve collection literal ownership and shared insertion cleanup Fixes #1122. Allocator traps and LLDB identify the premature temporary drop, literal insertion bypass, and comparison copy in docs/phase0-ownership-debug.md. The expanded native fixture has exact destructor counts and zero leaks with and without allocator reuse. Source checks, the development build, and focused audit pass; broader audit coverage is tracked in #1123. * Reject instantiated generic containers as string concat operands Fixes #1121. LLDB observed Sema.check_binary+5452 classify TY_GENERIC_INST as 14, then skip the known-nonstr rejection at +5456. Native concat interpreted a Result header as str. Both Result operand positions and a generic record now fail with the intended diagnostic; development build and focused tests pass. * Recognize leading one-liner flags and report complexity launch failures LLDB observed cli_has_flag begin at argv[2], skipping --trace-alloc before -e. Scan from argv[1], keep the allocation fixture idiomatic, and report process exit codes and capture paths from the complexity lane. Correct stale bundle and sourcing status banners. * Retain the compiler identity across build cache lookups Fixes #1125. LLDB observed build_cache_current_compiler_fingerprint+200 reset its cached global from a 64-byte fingerprint to zero while the ready flag stayed set. Return an explicit clone and cache unresolved identity too. The native regression verifies repeated graph keys against the executable fingerprint; compiler source checks pass. Proof is recorded in docs/build-compiler-fingerprint-debug.md. * Use the shared field projection path for observer places LLVM rejected an i32 undef versus str comparison on a Box payload. LLDB observed lower_field_base_place+204 returning the Box place through lower_observer_probe_arg; lower_expr_place now uses lower_field_access, including its recorded autoderef and payload handling. * spec: record allocation tracing CLI flag blessed by Eric * docs: select stdlib facade engines and align migration phases * docs: align inventory with selected stdlib engines * docs: record completed Phase 0 verification * Preserve C record identity, empty statements, and valid module paths Closes #1124. LLDB observed underscore tags branch to c_void and NullStmt return zero into lower_for_stmt_ir+428; the parser rejected generated use probe.a-b. See docs/c-algorithms-migration-debug.md for the exact evidence and regression scope. * Resolve generic layout applications through the active type bindings LLDB observed Codegen.resolve_type+952 discard NK_INDEX type application node 7425 after frozen Sema returned zero. Both application syntax forms now share the substitution-aware resolver; add nested-record and multi-parameter layout coverage. * Add pinned c-algorithms migration and upstream test targets * fix: retain restored C scope entries and owned generic call results * fix: preserve reference identities and contextualize pointer null comparisons * fix(migrate): distinguish diagnostic macros from stringification * migrate: lower assertion effects and recover Clang string literals Native LLDB stops prove the missing __builtin_expect structural branch, filtered __assert_rtn binding, and StringLiteral cursor 897 returning invalid IR despite a valid Clang spelling. Preserve these paths without weakening upstream assertions. Compiler source check and dev build pass for the effect/builtin paths; final literal recovery and native fixture verification remain pending. * mir: retain concrete closure and async bodies before codegen LLDB proved Codegen.gen_closure lowered node 889 using the last generic specialization type, sending the i32 comparator to with_str_cmp_ref. Prepare anonymous bodies in the concrete lowering context, validate their retained contracts, and read them in codegen. Mixed-width/string comparator and ordinary closure/async captures pass on the dev compiler. LLVM also proved an async result-buffer state leak into nested closure returns; save and restore it across anonymous functions. Full self-host verification follows. * fix: retain declaration identity for visibility and C initializers LLDB proves generic declaration validation reads private Entry from the importing context (#1130), and the C initializer scanner classifies variable2 as initialized from variable1’s equals sign. Use declaring-module context and Clang’s per-variable initializer cursor. Source checking passes; regression and upstream pipeline verification follow. * Reserve complete record field ranges before nested layout resolution Native LLDB proof: monomorphize_struct_nodes recurses at +2184 while resolving an enclosing record; get_llvm_field_index receives source index 1 and returns slot 0. The Trie constructor IR overwrites its engine pointer with the empty entries pointer. Reserve all parallel field columns before resolving nested fields in generic, ordinary, union, and generator records. Source checking passes. Regression covers returned nested generic records, reordered initialization, and owned strings. Native verification follows in the batch; layout audit gap tracked in #1131. * Reject private generic type applications across module boundaries LLDB at resolve_generic_type +404 observed lookup_named_type_visible returning zero from check_let_binding. The declaration-table contains branch at +884 then returned a concrete type (138), bypassing privacy. Check the private symbol path before the declaration-presence fallback. Preserve the negative annotation regression and repair its public marker signature; create the migration fixture output directory. Compiler source check passes; multi-declarator native regression passes. * Bind atoi through std.libc for migrated calls and function values The pinned upstream hash-table test stopped at atoi(val): ci_libc_symbol_kind_mask omitted atoi despite the text call mapper recognizing it. Add the concrete foreign ABI binding and structural allowlist entry, with direct-call and function-pointer coverage. Compiler source check passes; native migration verification follows. * Preserve callback signatures and null sentinels during C migration The upstream test_alloc_testing output contained integer 0 in a function-pointer array and a vacuous unsafe strcmp call. The atoi regression also emitted a local unsafe callback with an unconverted str argument. Coerce array elements against their element types, classify direct function references by canonical Clang type, and use the callable signature for all argument conversions. Stage nested callable parameters before appending their shared extra range. Apply the existing Sema std-module extern policy to every std shared-defs corpus, replacing the pcre2-only migrator condition. Source check passes; regressions include callback arrays, typedefs, local and field callbacks, and nested callback parameters. Native verification follows. * Preserve borrowed dereference places in non-Copy bindings Native allocator trap and LLDB observed str.cmp freeing a live SortedVec element through rt_core.w:2730. MIR copied the shared pointee into an owning local and scheduled drop#10; retain the Sema projection and bind its place instead. Reject owned mutable bindings and clone the two compiler fields that require independent mutable storage. Stage 1: reduced repro, repeated string comparisons, SortedVec, BinaryHeap and eight custom destructor checks pass with debug allocation and zero leaks. Consuming and mutable borrowed bindings reject. Validator gap tracked in #1132. * Load callable values through reference places before invocation Native LLDB stopped at the callbacks data symbol: the array slot address was used as the branch target instead of its stored atoi pointer. Normalize callable reference projections in shared MIR call lowering; FnAbi remains the argument/result authority. Add raw C callback, reference parameter and With closure collection coverage. Validator gap: #1133. * Preserve macro null callbacks and their safety contracts LLDB observed ci_c_initializer_is_null_pointer_cast return true for (void *)0, then the source initializer path only recognized pointer/Option destinations and emitted integer zero for a function pointer. Route macro nulls through the common target coercion. Only wrap indirect calls whose rendered callable contract is unsafe. Compile the raw upstream corpus without the application prelude, matching migration and bundle options. * migrate: render a record forward-declared without a definition as opaque, not an empty struct A TU that only sees a record's forward declaration has an incomplete type with no size. Rendering it as an empty { __pad0 } struct registered a concrete body in the shared defs, so a later TU's real definition could not upgrade it and the corpus lost the fields whenever the incomplete TU sorted first (c-algorithms: test-trie.c before trie.c, _Trie lost root_node). Render it 'type X = opaque' so the definition upgrades it in either order; fixture covers the order. * build: migrate each c-algorithms test as its own program Upstream links each test as a separate program with independent globals (list's variable1 is 50, arraylist's is zero), so a migrate-one pass sharing one defs module cannot represent them. Each test is now a whole migration of engine, framework and test into tests/<name>/, and the test target compiles each from its own module tree. All 17 upstream programs pass under With. * build: c-algorithms is the third .wo bundle The migrated corpus is promoted to lib/std/c_algorithms (generated, never hand-edited) with a bundle.w root, a generated-output check, a root check and a drift lane whose harness is upstream's test-cpp smoke over every module. calg_wo mirrors zlib's plan at every build.w site: stage2/3 and fixpoint links, the release binary and cross plans embed it, stage1 keeps an empty slot. The corpus is excluded from the embedded stdlib and listed as an internal module; :test gains c-algorithms-test as the corpora lane. * std: SortedVec, BinaryHeap and Trie facades over the c-algorithms engines Phase 1 of docs/stdlib_sourcing_plan.md. The engines index void* slots; the facade owns every value in one heap slot (std.collections.engine_slot), observes through &T, transfers on remove/pop, and drops every held value before freeing the engine. Ordered facades compare through one C trampoline that calls the With comparator stored beside each value (#1135 keeps a generic closure from crossing into C directly). Behavior tests, complexity rows and drop-audit cells cover each facade; the corpus global and item-import workarounds are marked for #1136. * sema: ordering two views of a type without an operator method is an error Both operands of < on &T fell through as pointer-like and compiled to an address comparison of the references (#1137; the comparator closure of a sorted facade disassembled to cmp x1, x2, so every insertion kept address order). A view compares the value it observes; only raw pointers compare by address. The diagnostic names the missing method (§11.7). * docs: Phase 1 status of the stdlib sourcing plan and the handoff for it * mir: refresh the eager type caches after registering generic Drop specializations Checking a generic Drop body creates its dependent types (a *mut Slot[T] only the drop mentions) after the loop's preregistration, and lower_concrete_specialization's own refresh compares against a count taken later, so a generic type whose only use was being dropped hit 'is_copy_frozen miss' in lower_let_binding (the facades' empty drop-audit cells). The miss message now names the type. * sema: a source type declaration wins over a same-named bundle interface alias The demand loader collected any interface declaration whose name the program mentions, so c-algorithms' 'pub type Trie = _Trie' and 'BinaryHeap = _BinaryHeap' shadowed the facades' Trie[V] and BinaryHeap[T] whenever the bundle was embedded (the facade tests passed under stage1 and failed under the release binary with 'cannot infer generic method type parameter'). A type name the program's own source declares never demands the interface alias. The views-ordering diagnostic (#1137) now fires only for a declared struct, enum or instantiation target; a template body's &T is rechecked per instantiation. * docs: Phase 1 handoff — verified state, the bisected pre-facade regressions, what remains * mir: lower closure arguments of generic and machinery calls; statement-bodied closures return the implicit default A closure argument to a GENERIC_CALL (the spawn worker, a monomorphized method's callback) was replaced by a placeholder constant, so its body was never prelowered and codegen's gen_closure phase-bugged ('anonymous expression lacks MIR constant') on every scope/spawn fixture since 31a347d. A closure whose body is a statement but whose type returns a value (item => xs.push(item) as fn(i32) -> i32) now returns the implicit default, as Sema already accepts and as a bare return does; the typed-MIR validator rejected the unit operand. * std, tests: conform to D22 §13.6 where 88f0ad3's view rule found bit-copies of non-Copy values JsonWriter.value_str observes its argument, so it takes &str (Serialize for str passed *self, a str view, by value: str owns its buffer, D28). cd_unary's Acc opts into Copy, which is what its deref-copy checks assume. The #1043 fixture's unannotated 'var inferred = h.text' bit-copied an owning str; the typed clones it also checks are the conforming spelling. * std: the collection iterator and place types are pub; tests import the ones they name 92c0c01 closed the privacy bypass through which user code named VecIter and FilterIter without an import. They are user-nameable surface (the type of xs.iter()), so they are pub, and under D29's staged rule a non-prelude std name needs its explicit use. * migrate: read call parameter types from the sugared callable type ci_callable_cxtype canonicalized the callee's type, which erases the va_list typedef the #1104 parameter model keys on (Darwin's canonical va_list is char *), so every argument to a va_list parameter was cast to *mut c_char and the migrated program failed to type-check (behav_migrate_va_list). The canonical type now serves only a callee whose sugared type is not a function or a pointer to one. * sema: only a real type declaration displaces a same-named bundle interface alias std.libc's 'pub type c_int = i32' and the interface's identical alias must coexist (std.regex reaches c_ulong through the interface); a source alias no longer suppresses the interface's, only a struct, enum or generic declaration does (the facades' Trie[V] and BinaryHeap[T]). * abi: re-record the ABI source hash after TypeLayout's diagnostic text change Only the is_copy_frozen phase-bug message changed (it now names the type); no layout or passing convention moved, so WITH_ABI_VERSION stays. Every .wo rebuilds once. * migrate: a declared callee's parameter types come from its declaration; the callable type is the fallback 8a250bc read every call's parameter types from the callee's callable type, which is canonical and erases the va_list typedef identity on Darwin (a 'va_list *' behind a typedef became *mut *mut c_char, behav_migrate_va_list). The declaration's translated parameter type is the renderer that follows typedef identity (#1104), so a declared callee uses it as before e7ddf11; the canonical callable type now serves only a callee without a declaration (a local function pointer, a nested callback parameter), which is what e7ddf11 added it for. * build: the c-algorithms corpora lane compiles checked-in test programs with the release binary A migrate workspace runs in the build driver's own compiler, and the battery's driver is the seed (CI: src/main build :test), whose migrator predates this branch's assert lowering and bails on Darwin's assert. The lane therefore never migrates: c-algorithms-promote-tests promotes the ALLOC_TESTING migration into test/corpora/c_algorithms (one shared engine/, per-program defs.w + test module, all byte-identical engine copies verified), and c-algorithms-test assembles each program under its own project root, compiles it with out/release/bin/with build --no-prelude and runs it. The programs migrate under std.calg_testing: a compiler that embeds the c_algorithms bundle resolves std.c_algorithms.* to the interface first, and only a std package lets std.libc reach c_void under --no-prelude. Re-migration needs a tree compiler as the driver (WITH=out/release/bin/with out/release/bin/with build :c-algorithms-promote). The regenerated corpus reflects the declaration-first parameter typing. * docs: Phase 1 regressions root-caused; the corpora lane's driver rule * migrate: recognize an unnamed record member by its cursor spelling b0434ad made the bridge ask Clang about anonymity instead of matching the type spelling, so the translated text of an unnamed union field became c_void and no longer carried the '(unnamed at' marker the anonymous-record lookup keyed on. The field's record was then not found, the struct was demoted to opaque and its initializer flattened (c-migrator-core-tests: anon_union_init_not_flattened). The lookup now reads the marker from the declaration cursor's spelling. * drop-audit: a cell the baseline could not run and the candidate passes is FIXED, not a regression The three empty facade cells phase-bugged under the seed (the generic Drop-only type, fixed in 27ed60c) and pass under the candidate; the classifier read any difference as a regression. A candidate PASS against a non-PASS baseline is printed as FIXED and never red. * docs: Phase 1 battery green * D41: Ord.cmp(&self, &other) backs <, <=, >, >=; Eq.eq(&self, &other) backs ==, !=; fixed-name methods override Eric's ruling (decisions.md D41). Sema selects the family's primitive when neither operand type defines the fixed-name method and records the derivation (operator_method_derived); MirLower lowers cmp(...) <op> 0 and not eq(...), flipping the ordering's sign when the primitive lives on the right operand's type. The operator sidecars are cleared per recheck: a generic body rechecked per instantiation kept the first T's method (the str/i32 specializations of a T: Ord body called Tag.cmp). Eq.eq and Ord.cmp take other: &Self and every impl in the tree conforms; the facades' element types need only Ord; #1137's diagnostic names the primitive. Fixture behav_ord_cmp_operators covers owned and view operands, the derived four, an override, and a reversed selection. * docs: D41 recorded; the proposed §11.7 wording awaits Eric's blessing * build: the corpora and complexity lanes build their argv by push; the seed miscompiles the literal Same #1122 seed miscompile as the base branch's fix: build-layer code runs on the pinned seed, so a collection literal with moved element temporaries (the compiler path, the program path) is a freed string there. * build: the complexity lane builds its argv by push; the seed miscompiles the literal The action runner is compiled by the pinned seed (v0.15.2.0), which has #1122: a collection literal with moved element temporaries frees them before the collection is used. argv[0] (the compiler path) was a freed string: exit 127 on POSIX (reproduced locally with the pinned seed as the driver), the interior-NUL panic on the CI Linux/macOS lanes, and CreateProcessW's FILE_NOT_FOUND (-2) on Windows aarch64. 9ccd1e2 fixed the compiler in this tree, but build-layer code runs on the seed (D14; the seed-gated build-layer rule), so the literal cannot be used there until the seed carries the fix. * ci(windows): phase profiling during the build, stage captures and two timed probes on failure The Windows x86_64 lane's stage2 has timed out at 1801 s on every run of this branch (main: ~380 s) with no capture uploaded. The build now runs under WITH_PROFILE so a hung stage leaves its last completed phase in out/command/<stage>/stderr.txt; on failure the lane prints those captures, runs stage1 check on the compiler source (Sema/MIR alone) and a single-codegen-unit build (no emit threads), and uploads out/command. * spec: §11.7 — comparison derives from Ord.cmp and Eq.eq over borrowed operands; fixed-name methods override (D41, blessed by Eric 2026-09-14) * codegen: a ref/share-place argument no longer evaluates its place before taking its address The FnAbi call path evaluated every IndirectPlace operand (a whole-aggregate load) and then discarded the value for the place address. SROA scalarizes that dead load into one load per leaf: 1660 for Compilation, before every in-place receiver call; run_cli carried 26 such chains. marshal_ref_operand applies the same address policy without materializing a place operand. * codegen: large aggregate copies lower to memmove/memset before SROA A struct move was 'store (load %T)'; SROA rewrites that first-class aggregate into a load and a store per leaf, so a function moving a few large records carried tens of thousands of scalar stores in one block and SelectionDAG's store merging went quadratic on them: one unit of the windows_x86_64 stage2 build took 635 s (checkMergeStoreCandidatesForDependencies, the #1129 CI timeout), and every other unit 5-70 s. wl_lower_aggregate_copies runs before the per-function cleanup: a store of a loaded aggregate of 64 bytes or more becomes llvm.memmove, a store of a zero aggregate llvm.memset, and a load left without uses is erased. Every windows_x86_64 unit now emits in under 3 s. The hand-declared memcpy/memset intrinsics reuse an existing declaration (LLVM declares them itself once a pass forms one; a second declaration under the same name gets a .N suffix the verifier rejects). * codegen: a reference-typed ref argument marshals its value, not its place address d7c75f2's no-eval marshal sent every non-transparent place operand to mir_try_place_ptr_for_ref, which returns the place ADDRESS for a projected place with no load. For an operand whose type is itself &T/*mut T (a JsonView.source field passed to json_str(js: &str), print(v.source)) the value IS the pointer the ref param wants; the callee received &&str and read through it as the str (behav_derive_deserialize and the jq-scalar one-liner exited 134 in the #1129 battery; IR showed json_str called with the field GEP where main emits a load). Evaluate reference/raw-pointer operands — one scalar load, never the aggregate copy the no-eval path exists to avoid — and let marshal_ref_addr pass the pointer through. * std.libc: the assert.h reporters are modeled portably __assert_rtn (Darwin) and __assert_fail (glibc) were bare externs, so a corpus migrated on macOS could not link on Linux or Windows (#1138: c_algorithms-wo-drift and c-algorithms-test, 'undefined symbol: __assert_rtn'). Both are With functions now: the same report to stderr, then abort, on every target. * migrate: a record named only through a member type renders opaque 72e1067 stopped rendering every underscore-tagged record as c_void, so glibc's __locale_struct now names __locale_data — a record declared only inside a member's type, never at file scope. It had no cursor in the top-level walk and no 'type __locale_data = opaque' was emitted (spec_ss16_ffi_and_c_import under use c_import("time.h") on Linux, #1138). After the declaration walk the session walks every collected declaration's types and appends each undefined record it names, so it renders opaque next to its users. Fixture: behav_migrate_member_only_record. * docs: handoff for Phases 0/1/2 (2026-09-14) * test: the member-only record fixture reads the migrated module and calls the migrated name read_file returns a Result, and the migrated function keeps its C name; the __with_cabi_ prefix is only for runtime-borrow bridges. * test: the assert-macro migration fixture skips on Windows (#1140) UCRT's assert.h expands to _wassert with wide string literals, which the migrator does not lower; corpora migrated elsewhere run on Windows since the reporters are modeled portably. * Phase 2: TommyDS corpus as the fourth .wo bundle, header-inline ownership in the migrator, HashIndex facade (#1141) * migrate: bit builtins lower to integer methods; a pointer to a function typedef is a function pointer __builtin_clz/ctz/popcount (and the l/ll forms) lower structurally to (x as u32).clz() / u64 for the wide forms; __builtin_bswapN to .swap_bytes() on the N-bit unsigned (TommyDS tommy_ilog2/tommy_ctz). A CIE_FIELD with d2=2 is a method selected on a value and prints as base.method. A pointer whose pointee is a typedef of a function prototype (tommy_compare_func*) canonicalizes to the function pointer instead of *mut fn. Fixtures: behav_migrate_bit_builtins, behav_migrate_fn_typedef_pointer. * rt: with_libc_mach_absolute_time, the monotonic clock in nanoseconds The runtime seam behind std.libc's portable mach_absolute_time (next commit): the same value on every target. * std.libc: qsort, rand, srand; Darwin's mach clock modeled portably The migrator's libc allowlist admits qsort/rand/srand and mach_absolute_time/mach_timebase_info(_data_t)/kern_return_t (previous migrate commit). mach_absolute_time is the runtime's monotonic clock in nanoseconds and mach_timebase_info reports 1/1, so TommyDS's check.c timing code migrated on macOS computes nanoseconds on every target. Fixtures: behav_migrate_libc_qsort_clock (portable), behav_migrate_libc_mach_clock (darwin-only migration). * build: the TommyDS corpus as the fourth .wo bundle (Phase 2) build/tommyds.w pins amadvance/tommyds 1f3727fc, migrates the 13 units (tommy.c, the amalgamation, excluded) plus check.c as the harness (module check_: check collides with the prelude), promotes to lib/std/tommyds/, and runs tommycheck as the corpora lane tommyds-test. tommy_wo is wired at every site calg_wo is; the corpus leaves the embedded stdlib in build.w and build/runtime.w; std.tommyds is an internal module. The corpus is the migration's output, never hand-edited. * migrate: a header's static inline definitions are published by the unit of the same name A `static inline` function defined in a header is that header's API (TommyDS keeps tommy_hashdyn_search, tommy_hashlin_search and the tommy_inthash family in its headers); every includer compiled a private copy, so nothing outside the corpus could call them. The project scan now registers such a definition as owned by the unit whose stem matches the header's (tommyhashdyn.c for tommyhashdyn.h); that unit publishes it and every other unit imports it. A header no unit owns keeps a private copy per includer as before. Fixture: behav_migrate_header_inline_owner. * migrate: only a header's inline definitions are published; calls to an imported inline get their unsafe context The ownership rule from ff4c58b also published a unit's own static inline helpers (tommyhashdyn.c's hashdyn_grow_step) because their location stem matched the unit; a definition is a header's API only when it sits in a header. And a consumer unit's calls to an imported header inline with raw parameters were emitted without an unsafe context, because the unsafe-callee scan skipped every static function; a header-owned one is treated like any imported raw function. The fixture covers both: user_probe runs through the published engine_peek, engine_scale stays private. * tommyds: corpus re-promoted with the header-inline rule; bundle root tommy_hashdyn_search, tommy_hashlin_search, tommy_hashtable_search and the tommy_list/tommy_inthash inlines are published by their units and imported by every other unit (1,469 lines of private copies gone); check_.w resolves them through the imports. bundle.w is the root the migrate action writes. tommycheck passes. * std.collections.hash_index: HashIndex[K, V] over the TommyDS hashdyn engine Node ownership for an intrusive engine (docs/stdlib_sourcing_plan.md, Phase 2): the facade owns every node in one heap slot per entry: the node first, so the engine's node pointer is the slot, then the key comparator the one C trampoline reads, then the key and value. get observes, remove and a replacing insert transfer, clear and drop walk the buckets and release every slot exactly once; lookups reuse one probe slot. Behavior test, complexity row (hash-index, linear), drop-audit cells, and test/benchmark/hash_engines.w (facade vs raw engines vs rt_core HashMap). * docs: Phase 2 status (TommyDS bundle, header-inline rule, HashIndex, benchmark table) * docs: handoff for Phases 0/1/2 (2026-09-14, evening) * docs: handoff — Phase 2 battery green, PR #1141 --------- Co-authored-by: Eric Hartford <[email protected]> --------- Co-authored-by: Eric Hartford <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of docs/stdlib_sourcing_plan.md: the TommyDS corpus, whole, and the node-ownership facade. Stacked on #1138 (Phase 1).
Corpus. amadvance/tommyds
1f3727fcis pinned, fetched, migrated raw withwith migrate(the 13 units as modules +defs.w;tommy.c, upstream's amalgamation, is excluded) and promoted tolib/std/tommyds/as the fourth.wobundle (tommy_wo, every site the c-algorithms plan touches). Upstream'scheck.cruns toOKunder With (37 timed sections) and is the corpora lanetommyds-testin:test, plus the drift lane and root check. The corpus is the migration's output, never hand-edited;:tommyds-promotewith the release compiler reproduces it byte for byte.Migrator fixes, all general.
__builtin_clz/ctz/popcount/bswaplower structurally to the integer methods ((x as u32).clz()).tommy_compare_func*) is a function pointer.qsort,rand,srandand Darwin's mach clock are std.libc bindings; the clock is modeled portably (the runtime's monotonic nanoseconds, timebase 1/1), so a harness migrated on macOS times on every target.static inlinedefinitions are that header's API: the unit of the same name publishes them once and every other unit imports them (TommyDS keepstommy_hashdyn_search,tommy_hashlin_search,tommy_inthash_u32in headers; before this every includer carried a private copy and nothing outside the corpus could call them). A unit's own static inline helpers and headers no unit owns stay private per includer; calls to an imported header inline get their unsafe context.Facade (
std.collections.hash_index.HashIndex[K: Hash + Eq, V]overhashdyn): the engine threads intrusive nodes it never allocates; the facade owns every node in one heap slot per entry (the node first, so the engine's node pointer is the slot; then the key comparator the one C trampoline reads; then the key and value).getobserves,removeand a replacinginserttransfer,clear/dropwalk the buckets and release every slot exactly once; lookups reuse one probe slot. Behavior test, complexity row (hash-index, linear), drop-audit cells, andtest/benchmark/hash_engines.w.Benchmark (i32 keys, n = 200000, ns/op, median of 3,
-O1, Eric's laptop): HashIndex 32/3/26 (insert/lookup/remove) vsrt_coreHashMap 41/9/58 vs raw hashdyn 18/5/15, hashlin 24/6/14, hashtable 4/7/10, c-algorithms hash_table 47/1/25. STC remains the selected default owning map engine (Phase 3); the table is the comparison the plan asked for, not a selection.Filed: #1139 (two modules of one package cannot both define a private function of one name; found by the header-inline fixture), #1140 (UCRT
_wassert+ wide string literals on native-Windows migration; the Phase 1 assert fixture skips on Windows).Battery: see the final comment.