Skip to content

Wave 3: @[ffi_stack] (#583), List.new_in(allocator) (#570), float MinMax in std (#3483) - #3674

Merged
ehartford merged 5 commits into
mainfrom
wave3
Nov 28, 2026
Merged

ehartford merged 5 commits into
mainfrom
wave3

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Summary

Bundled Wave 3 commits verified under one seed-driven battery:

  1. runtime/codegen: implement @[ffi_stack] OS-thread stack switching (#583)

    • Parses @[ffi_stack] on functions and impl methods (src/Ast.with, src/Parser.with, src/ComptimeTransform.with).
    • Enforces §14.19 in Sema: rejects @[ffi_stack] on async fn and on any function that may suspend directly or transitively (src/SemaCheck.with).
    • Adds per-worker guard-paged 2 MiB FFI stack switching via with_fiber_run_on_ffi_stack reusing with_fiber_prepare_initial_context + with_fiber_switch across Darwin/Linux (rt/fiber_core_darwin.with), Windows (rt/fiber_core_windows.with), and direct call stub (rt/fiber_stubs.with), with nested depth tracking, panic cleanup, and runtime yield guard.
    • Emits LLVM trampoline + wrapper in src/CodegenDispatch.with (handling sret and byval attributes) and fails loudly on wasm32 and --emit-c.
    • Marks §14.19 @[ffi_stack] implemented in test/conformance/conformance.tsv with 4 behavior/compile-error tests.
    • Closes Implement optional FFI stack switching and @[ffi_stack] mode (§14.19) #583.
  2. std/runtime/sema: implement List.new_in(allocator) with ephemeral virality (§8.3, #570)

    • Adds region arena runtime (with_arena_*) and allocator-backed List cells (start < 0 in the existing 32-byte List header, zero ABI change) supporting growth, O(1) take_front/restore_front, D120 copy-on-write sharing, and clean drops (rt/rt_core.with).
    • Refactors std.alloc.Arena and FrameArena to interior-mutable state pointers matching TempArena (lib/std/alloc.with) so &Arena/&FrameArena/Rc[A]/Arc[A] allocate directly.
    • Implements MirIntrinsic.LIST_NEW_IN / CcBuiltin.LIST_NEW_IN across Sema, MIR, LLVM, and C backends, enforcing §8.3 ephemeral virality (borrowed &Arena/&FrameArena/&TempArena creates ephemeral Lists that cannot escape or be stored in structs; owned Rc[A]/Arc[A]/A creates storable Lists), and fixes UFCS Rc.clone(&a) / Arc.clone(&a) generic type inference.
    • Marks §8.3 List.new_in(allocator) implemented in test/conformance/conformance.tsv with behavior, --debug-alloc (leak count=0), and compile-error tests.
    • Closes List.new_in(allocator): allocator-parameterized builtin List (§8.3) #570.
  3. std/sema/codegen: move float min/max onto MinMax trait and delete MIN/MAX intrinsics (#3483)

    • Adds impl MinMax for f32 and impl MinMax for f64 (IEEE 754 minNum/maxNum NaN semantics) in lib/std/traits.with.
    • Removes float.min/float.max from src/BuiltinSigs.with, deletes MirIntrinsic.MIN/MAX and CcBuiltin.MIN/MAX from Sema, LLVM codegen, and C codegen.
    • Adds behav_3483_float_min_max_in_library.with covering f32/f64 min/max, NaN handling, generic MinMax dispatch, and f64.min/f32.max constants.

Verification

  • Running full seed-driven battery (WITH=$PWD/src/main with run tools/battery.with); verdict will be posted before marking ready.

@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery verdict at a39ec1438:

out/battery/battery.log: rc=0 green
battery rc=0 wall=1588s
battery: GREEN (a39ec1438)

@ehartford
ehartford marked this pull request as ready for review November 28, 2026 15:32
@ehartford
ehartford merged commit 01141dc into main Nov 28, 2026
1 check passed
@ehartford
ehartford deleted the wave3 branch November 28, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement optional FFI stack switching and @[ffi_stack] mode (§14.19) List.new_in(allocator): allocator-parameterized builtin List (§8.3)

1 participant