Skip to content

Three trees T6u: the seal - #437

Open
jfrolich wants to merge 3 commits into
ocaml-to-rust-rewritefrom
bir-lower-emit-builder
Open

jfrolich wants to merge 3 commits into
ocaml-to-rust-rewritefrom
bir-lower-emit-builder

Conversation

@jfrolich

@jfrolich jfrolich commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

The naming replay's walk now applies the flatten rules F1 to F8 to each statement it takes out of a list (new src/bir/lower/seal.rs, through the Js/JsStmt interface only). The new side of check mode no longer runs the flatten pass: it calls bridge_j::qualify and finish_flattened_output. The backend in use flattens where it did before: the call is written out where finish_lowered_output was called, and that helper is deleted. The oracles flatten the legacy side, and their pass lists lose pass 1. Design: compiler-rust/docs/THREE_TREES.md 11.4, "T6u: the seal".

The two posted diffs were applied with git apply as they are, with no retyping or formatting.

Commits

  1. The seal: seal.rs, names.rs, mod.rs, lam_compile.rs, oracle_tests.rs, export.rs, ffi_args.rs, unit.rs, globals.rs.
  2. The hand-built tests.
  3. The changelog fragment changes/three-trees-t6u.internal.md.

git diff --numstat of commit 1: export.rs 4/0, ffi_args.rs 3/0, globals.rs 5/2, mod.rs 6/0, names.rs 194/59, oracle_tests.rs 22/20, seal.rs 433/0, unit.rs 10/5, lam_compile.rs 18/23. Of commit 2: names.rs 489/0, oracle_tests.rs 81/0. Against the start: names.rs 683/59, oracle_tests.rs 103/20, seal.rs 433/0.

Pins, sizes, tests

  • Allocation pins in unit.rs: 85, 103, 85, 155 became 86, 104, 86, 156. The extra allocation is the reserve_exact of the seal's work stack (decision 14).
  • Frame grows to 24 bytes (row_sizes). Held stays at 24. The new test seal::tests::sizes pins Mode at 1, Pending at 8, Marks at 12 and Sealed at 88. No other size_of moved.
  • Changed in commit 1: row_sizes and ten_thousand_nested_lists_move_each_statement_once, which is now built over nested ifs with the same numbers. In the external-shadow tests, only the lines of item (10) of the task changed: pass 1 is dropped from the pass lists, new_text_assigning loses its 1 => flatten arm and that import, step_a and a_copied_function_doubles_… no longer call flatten(..), and export_coercion_… no longer flattens again.
  • Added in commit 2, in names.rs: f1_…, f2_…, f3_…, f4_…, f5_…, f6_…, f7_and_f8_…, the_heads_of_a_returned_sequence_are_sealed_with_their_tests_entered, a_function_literal_in_a_branch_the_seal_drops_is_not_entered, the_seal_offers_each_statement_once_at_any_width_and_depth, the_seal_splices_ten_thousand_nested_blocks_into_one_list, a_branch_a_rule_rewrites_prints_as_the_pass_prints_it, the_statement_written_for_a_located_conditional_has_its_location.
  • Added in commit 2, in oracle_tests.rs: a_global_in_a_branch_the_seal_makes_a_list_of_is_covered_by_the_list_around_it, a_global_in_a_branch_of_a_conditional_used_for_its_effect_is_covered_by_the_list_around_it, a_located_conditional_gives_its_location_to_the_if_the_seal_writes.
  • The only attributes added are #[serde(flatten)] on SwitchStats::sealed and the derives of seal.rs. Nothing uses hashing.

Gates

Test filters (passed / failed / ignored):

--lib bir::lower --lib bir::j --lib emit::builder
base 596/0/0 131/0/0 85/0/0
commit 1 597/0/0 131/0/0 85/0/0
commit 2 613/0/0 131/0/0 85/0/0
  • cargo clippy --manifest-path compiler-rust/Cargo.toml --all-targets -- -D warnings: clean after each commit.
  • cargo check --all-targets: 0 warnings.
  • RUSTDOCFLAGS="-D warnings" cargo doc --locked --all-features --no-deps: clean.
  • python3 ../scripts/check_lowering_cost_docs.py --base origin/ocaml-to-rust-rewrite ends with cost docs: production functions=608; changed/new=27; missing/generic=0; removed=0.
  • python3 ../scripts/count_lowering_ids.py --self-test prints count_lowering_ids self-test ok: 33 files, 0 transition calls.
  • The first | total line of python3 ../scripts/count_lowering_ids.py:
    • base: | total | 16847 | 64 | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 72 |
    • build: | total | 17397 | 64 | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 72 |
    • Only Lines moves (+550): seal.rs adds 416 non-test lines and names.rs grows.

Breaks (each applied alone and undone)

  1. A second offer as the first line of the Outcome::Final arm of Replay::seal: test result: FAILED. 602 passed; 11 failed. The failures are a_function_literal_in_a_branch_the_seal_drops_is_not_entered, f1_… to f6_…, f7_and_f8_…, the_heads_of_a_returned_sequence_are_sealed_with_their_tests_entered, the_seal_offers_each_statement_once_at_any_width_and_depth and the_seal_splices_ten_thousand_nested_blocks_into_one_list, all in names.
  2. seal::unentered returns mode: 612 passed; 1 failed, the failure being the_heads_of_a_returned_sequence_are_sealed_with_their_tests_entered.
  3. seal::located does not locate: 611 passed; 2 failed, the failures being the_statement_written_for_a_located_conditional_has_its_location and oracle_tests::a_located_conditional_gives_its_location_to_the_if_the_seal_writes.

End-state searches (from compiler-rust)

  • grep -n apply_js_flatten_pass src/lambda/lam_compile.rs: two lines, 29 (the import) and 903 (the backend in use).
  • grep -c finish_lowered_output src/lambda/lam_compile.rs: 0.
  • In names.rs: seal::step 3, set_body_adopting 3, set_literal_body_adopting 1, the text of the debug assertion 2, seal_dropped_literals 4.
  • grep -c 'mod seal' src/bir/lower/mod.rs: 1.
  • In seal.rs: js.own( 2, js.location( 1, locate_stmt 1.
  • grep -c apply_js_flatten_pass src/bir/lower/oracle_tests.rs: 4.
  • The row's search gives 0 for every non-test file of src/bir/lower.

CI

  • Instruction count (compare): base 4,357,435,415, head 4,355,492,019, change -1,943,396 (-0.045%). The default build does not reach this code, so this is noise.
  • Parity jobs (javascript, stdlib, gentype, diagnostics, analysis, oxc) are green, as is every other check.
  • Backend bridge coverage: zero differences. identical equals units everywhere (fixtures 504/504 and 617/617, runtime 113/113, tests/tests 807/807), and the job prints "Backend coverage ratchet passed".

Naming log against the pass (identical on the base and the build):

Naming log against the pass: runtime: compared 112, uncompared 1, adopted_nodes 0, sum of (d) 0
Naming log against the pass: tests/tests: compared 805, uncompared 1, adopted_nodes 52, sum of (d) 0
Naming log against the pass: fixtures: compared 616, uncompared 1, adopted_nodes 0, sum of (d) 0

Coverage counters, base (trunk 9b76caf) to build:

counter fixtures runtime tests/tests
descended 48532 → 47331 5462 → 5293 72139 → 71186
moves 16388 → 18676 1934 → 2286 22236 → 24037
statements 16388 → 18676 1934 → 2286 22236 → 24037
scopes 3608 → 3608 336 → 336 4662 → 4662
reserved 5716 → 5716 583 → 583 8770 → 8770
name_replay_steps 74244 → 75331 8315 → 8498 107807 → 108655
global_steps 22553 → 22553 2729 → 2729 26076 → 26091
globals_qualified 0 → 0 0 → 0 31 → 31
unnamed_references 0 → 0 0 → 0 0 → 0
seal_offered 18885 2303 24203
seal_f1 … f6, f78 23, 0, 61, 0, 1046, 119, 67 7, 0, 5, 0, 166, 7, 3 8, 3, 42, 0, 841, 99, 58
seal_dropped 0 0 0
seal_groups 0 0 2
seal_dropped_literals 0 0 0

On every corpus moves equals statements, and scopes, reserved and globals_qualified equal the base's. The runtime and tests/tests figures match the design turn's exactly. The fixtures corpus had not been run under the seal before: it shows no difference and seal_dropped_literals is 0.

Not run

The check-mode scripts/compare_build_instructions.py comparison: the sandbox was critically low on memory, and the task says the coordinator measures this figure. No number is given here.

Started by Jaap Frolich in this Assistant session

open-session-submodule Bot and others added 3 commits November 29, 2026 16:04
The walk of the naming replay offers each statement it takes out of a
list to the seal (new src/bir/lower/seal.rs, `seal::step`), which
applies the flatten rules F1 to F8 through the interface only: no node
is read. The new side of check mode stops running the flatten pass: it
qualifies and finishes the sealed program (`finish_flattened_output`);
the backend in use flattens where it did, written out where
`finish_lowered_output` was called, and that helper is deleted. The
oracles flatten the legacy side and their passes lists lose pass 1.

Frame gains the seal marks (24 bytes); Held gains the literal and body
modes (still 24); the work stack is reserved once by the node count,
one more allocation per fresh unit (pins 86, 104, 86, 156).

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-db4a997e-9832-772d-8eb1-c67590c7626b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Thirteen tests in names.rs, one per rule F1 to F8 and for the modes,
dropped literals, the one offer per statement at any width and depth
(10,000), the splice of 10,000 nested blocks, the printed branch and the
location of a written conditional; three in oracle_tests.rs for globals
in branches the seal makes a list of and the location the seal gives to
the `if` it writes. Each hand-built tree is judged by `Unit::sealed`
against the flatten pass, and by `bir_passes_oracle` after it.

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-db4a997e-9832-772d-8eb1-c67590c7626b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-db4a997e-9832-772d-8eb1-c67590c7626b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
@jfrolich
jfrolich marked this pull request as ready for review November 29, 2026 16:31

This branch has not been deployed

No deployments
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.

1 participant