Skip to content

Compute field offsets once in the layout packer - #945

Closed
tachytelicdetonation wants to merge 1 commit into
bendlang:mainfrom
tachytelicdetonation:t3code/simplify-compiler-code
Closed

tachytelicdetonation wants to merge 1 commit into
bendlang:mainfrom
tachytelicdetonation:t3code/simplify-compiler-code

Conversation

@tachytelicdetonation

Copy link
Copy Markdown
Contributor

lay_fields calculated field offsets before lay_pack mutated each offset to account for the constructor tag. This makes lay_pack accept constructor names and field layouts and assign the final offsets while merging word kinds. It removes the intermediate offset calculation and the caller-supplied offsets in arr_lay.

Only bend2/comp.ts changes: +17 / -27 lines (net -10), and 64,941 -> 64,881 ttok. No language features or comments are removed.

Validation against upstream commit 99f9c6cd on macOS arm64:

  • Compared CLI compilation of 263 inputs: every direct .bend file under tests/{compile,run,base,show,rfc,cost} plus all 16 runtime benchmarks. All 235 emitted C files and 235 emitted JavaScript files are byte-identical; the other 28 inputs have identical compilation diagnostics and exit status.
  • Ran 16 representative layout programs on native C (one CPU thread, GPU off) and JavaScript: all 32 runs match their #| output. Four additional rejection tests match their expected errors and exit status.
  • gates/repo.ts: PASS 46 / 46. git diff --check: pass.
  • TypeScript 7.0.2 with the repository tsconfig reports the same four diagnostics before and after: two in bend2/bend.ts and missing canvas declarations in two documentation generators. No diagnostics in comp.ts.
  • The private-cluster test, performance, and release gates were not run. Benchmark source generation was compared; runtime benchmark timings were not measured.

VictorTaelin pushed a commit that referenced this pull request Sep 21, 2026
lay_pack takes constructor names and field layouts and assigns the final offsets while merging word kinds; the intermediate offsets of lay_fields and the caller-supplied offsets in arr_lay are gone. Emission is byte-identical. (PR #945)
@VictorTaelin

Copy link
Copy Markdown
Contributor

Merged into 2.0.25 as one commit under your authorship, thank you. We verified the byte-identical emission over 914 outputs on our side. It landed together with the wide-record fix of #944, so lay_pack now also takes the field lists through lay_wide; the offsets are yours.

Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

Phylliida pushed a commit to Phylliida/bend that referenced this pull request Sep 27, 2026
lay_pack takes constructor names and field layouts and assigns the final offsets while merging word kinds; the intermediate offsets of lay_fields and the caller-supplied offsets in arr_lay are gone. Emission is byte-identical. (PR bendlang#945)
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.

2 participants