Skip to content

Lane B train: RT-safe callable contracts (#766), destination-passing and copy_count (#732), memory profiler sites (#740), mixed concat and parse_float (#747) [#1348 #1367 #1366 #1356] - #1348

Merged
godofecht merged 19 commits into
mainfrom
cursor/rt-safe-callable-contracts-7ce9
Oct 8, 2026

Conversation

@godofecht

@godofecht godofecht commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Lane B train: #1348, #1367, #1366 and #1356 rebased onto main together, with one bootstrap regeneration.

Closes #732
Part of #766 (trait-method RT contracts follow in a separate PR)
Closes #740
Closes #747

What each PR brings

Train resolution

Gates (macOS arm64)

On the train rebased onto main 32401c7 (after the lane A and lane C trains), bootstrap regenerated there, with a fresh Stage-A driver:

  • flowc_host selftest: flowc: PASS
  • bootstrap_from_c.sh --regen: fixed point at gen3; --verify: PASS
  • ./flow test --tier2 --strict: 0 transpile and 0 clang failures
  • ./flow test-lang, ./flow test-runtime: pass
  • tests/cgen/run.flow, parity_mlir.flow, tests/mlir_commands/run.flow: pass
  • typecheck_rules.flow, parity_typecheck.flow --check, tests/scripts/rt_callable.flow, tests/scripts/mem_profile.flow, tests/bench_harness/run.flow, tests/fir/run.flow: pass
  • self_host_full.flow (gen2.o == gen3.o), roundtrip.flow, selfcompile_audit.flow: pass
  • tests/tools/run.flow, tests/conformance/run.flow: pass
  • tests/cli/run.flow: all pass except jit_hello and test_mlir
  • gen_stdlib_docs --check, doc_examples --check-ledger, fmt_check --check, parse_coverage --check, python_ratchet, script_refs, ./flow test-scripts: pass

Fixes found by the train gates and the first CI run:

Known local drifts on this Mac: tests/cli jit_hello and test_mlir.

@godofecht
godofecht marked this pull request as ready for review October 5, 2026 02:14
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from a5bc260 to 1ed6901 Compare October 7, 2026 18:48
@godofecht godofecht changed the title feat: first-slice RT-safe callable contracts for closures (#766) Lane B train: RT-safe callable contracts (#766), destination-passing and copy_count (#732), memory profiler sites (#740), mixed concat and parse_float (#747) [#1348 #1367 #1366 #1356] Oct 7, 2026
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch 2 times, most recently from cc1e6a4 to 5a1bcdb Compare October 7, 2026 20:27
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from 5a1bcdb to 75d990b Compare October 8, 2026 00:02
@godofecht
godofecht enabled auto-merge October 8, 2026 00:25
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from 75d990b to 64e07e3 Compare October 8, 2026 00:27
godofecht added a commit that referenced this pull request Oct 8, 2026
…#765)

Close the remaining #765 gaps on top of the landed first slice: a
known-safe extern allow-list so unknown is a hard error from @rt_safe,
impl methods in the call graph (closures stay with #766 / PR #1348),
LD1 through static fields and malloc stores, and a refinement-keyed
incremental summary cache.

Co-authored-by: Abhishek Shivakumar <[email protected]>
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from 64e07e3 to 8caba56 Compare October 8, 2026 01:04
@godofecht
godofecht added this pull request to the merge queue Oct 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 8, 2026
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from 8caba56 to f241386 Compare October 8, 2026 02:38
@godofecht
godofecht enabled auto-merge October 8, 2026 02:38
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from f241386 to 30c308d Compare October 8, 2026 02:51
@godofecht
godofecht added this pull request to the merge queue Oct 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 8, 2026
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from 30c308d to e91f723 Compare October 8, 2026 03:35
@godofecht
godofecht enabled auto-merge October 8, 2026 03:36
@godofecht
godofecht added this pull request to the merge queue Oct 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 8, 2026
cursoragent and others added 17 commits October 8, 2026 06:12
Extend the #1310 `with rt_safe` function-pointer contract so a
callback-safe higher-order function can accept a proven-safe named
function or closure and reject an allocating one.

Closures get a compile-time summary: the body is walked into the existing
pointer/span captures are rejected, and diagnostics name the closure and
the unsafe op. The contract is erased before codegen.

Stop `with E1, E2` on a nested function type from swallowing the next
parameter (`f: (T) -> R with rt_safe, x: i32`). Trait-method contracts
remain a documented gap.

Part of #766.

Co-authored-by: Abhishek Shivakumar <[email protected]>
Single-module functions that return a named struct take a hidden
`T* __flowc_sret` destination; in bundle mode (FLOWC_BUNDLE=1) the
callee keeps a local sret slot so the pointer ABI is not exposed across
modules. Record updates whose destination overlaps a source read go
through a temporary (overwrite dependence); others build in place.
The runtime profile and the #728 harness report copy_count (aggregate
copy operations) next to copies (bytes).

Rebased from PR #1367 onto current main. cgen conflicts with the span
data temps (#729/#1383) and the noalias clone flag (#731): the function
prologue emits the sret slot, then the span temps, then the body; the
buffer keeps na_clone, bounds_hi_* and sret. Doc and harness comment
conflicts keep both sides.

On rebase: `export function`s keep the value-return C signature (no
pointer sret), because a module compiled on its own (roundtrip.flow,
stage_a_self_emit) only sees that declaration; the PR as written failed
roundtrip with "too few arguments" in lexer_flowc.c. The record-update
MLIR goldens (fixture, corpus digests for the three copy-elision
programs, mlir_commands) are re-recorded on top of #1418; parity_mlir
runs all 24 fixtures through MLIR and they pass.
Extend the opt-in FLOW_MEM_PROFILE runtime with hashed live-block
accounting, stack/arena promotion counters, per-compiler-site
attribution, and matching MLIR wrappers. This is runtime accounting
only and does not overlap the #669 static-lifetime work.

Co-authored-by: Abhishek Shivakumar <[email protected]>
The MLIR profiler preamble passed llvm.mlir.addressof @flow_mem_report
to atexit, but @flow_mem_report is a func.func until func-to-llvm, and
addressof must name an llvm.func or a global. Every program failed to
verify (parity_mlir: fixtures did not lower or link). func.constant plus
an unrealized cast to !llvm.ptr lowers to the same addressof once the
function is converted.
Every allocating program now carries the flow_mem_* profiler code, so
parity_mlir fixture goldens and corpus digests (merged onto the old file,
keeping entries this macOS host does not record), ten mlir_commands
goldens, and the compile_hello / compile_isolated_root / python_source
checksums change (darwin and linux hold the same values).
parity_mlir PASS, mlir_commands 88/0.
Finish the remaining #747 gaps after the first slice: flatten mixed
numeric + chains to one concatn, lower n-way string + in MLIR as one
malloc plus per-part memcpy, add a linear parse_float and fail-closed
UTF-8 helpers, and print allocation/copy counters on the harness rows.

Co-authored-by: Abhishek Shivakumar <[email protected]>
… train

Mixed-concat strcat lowering (#747), destination-passing copy_count (#732)
and the profiler sites (#740) change the MLIR of 56 corpus programs and
the C of the compile_hello, compile_isolated_root and python_source
cases (darwin and linux hold the same values).
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
…n; operator-sugar targets keep the value return (#732)

The strict corpus (tests/core/test_production_features, tests/lang/
test_lowered_forms, tests/lang/test_dual_operator_sugar) failed to
compile: `expr?` inside a pointer-ABI sret function emitted
`return __flowc_try;` from a void function, and the Dual operator
sugar calls add/sub/mul/div/neg by name with the value-return
arguments. The try now stores through `*__flowc_sret` and returns;
the operator-sugar names keep the plain C signature.
…or the lane B train

parity_mlir --record on the rebased train (no entry dropped). The
completion list gains the four new std.string exports (#747), and
arena_alloc / frame_alloc now call flow_mem_note_arena (#740).
@godofecht
godofecht force-pushed the cursor/rt-safe-callable-contracts-7ce9 branch from e91f723 to 2d8c1ce Compare October 8, 2026 05:52
@godofecht
godofecht enabled auto-merge October 8, 2026 05:53
@godofecht
godofecht added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 44bdd82 Oct 8, 2026
32 checks passed
godofecht added a commit that referenced this pull request Oct 8, 2026
…#765)

Close the remaining #765 gaps on top of the landed first slice: a
known-safe extern allow-list so unknown is a hard error from @rt_safe,
impl methods in the call graph (closures stay with #766 / PR #1348),
LD1 through static fields and malloc stores, and a refinement-keyed
incremental summary cache.

Co-authored-by: Abhishek Shivakumar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants