Repository navigation
Reuse Wasm locals to reduce recursive call frames - #167
Closed
vishvananda wants to merge 1 commit into
Closed
vishvananda wants to merge 1 commit into
vishvananda wants to merge 1 commit into
Conversation
Merged
vishvananda
marked this pull request as ready for review
November 16, 2026 00:27
Owner
Author
|
Superseded by #168, which carries this commit unchanged with the 0.9.3 version bump. |
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.
Clang built by cppgm fails in Safari workers with
RangeError: Maximum call stack size exceeded. The Wasm backend gave almost every SSA result a separate local. A recursive Clang statement visitor had 1,603 locals, which made each native call frame too large for Safari’s worker stack.Reuse same-type Wasm locals when their live ranges do not overlap. The pass uses selected MIR and structured control-flow labels. It keeps parameter indices and zero-initialized values, follows loop edges, and has a work budget. It skips exception landing regions and leaves O0 unchanged. It does not change LowIR or x86 lowering.
The visitor now needs 17 locals. Rebuilding all 2,374 Clang objects with this change passes a 512 KiB WebKit stack limit, including both OpenLara builds and both players. The game outputs have the same hashes as before. A self-compiled native cppgm produces the same Clang objects and module as the host-built cppgm. These full Clang checks used the v0.9.1 base before rebasing this commit onto current main.
Add a PA37 maintainer regression with a recursive switch, values live across calls, loop-carried values, runtime checks and an optimized local-count bound. No student requirements change.
Validation: after rebasing onto main, PA37 (223 checks), full strict report (11,311/11,311), PA36 smoke, debug-info checks, self-host through PA5, native inception, architecture and placement audits, file and format audits, harness tests and student export validation. The WASI two-stage build matches every object and the final compiler; WASI and native compilers produce equal x86 objects at O0 and O2. Counter ABBA observations are retained locally; shared-host noise does not support a precise compile-time improvement claim.
Real Safari testing: the new Clang passes the first files that previously overflowed. An initial full run stopped at an unrelated date mismatch in the unchanged cppgm seed: exactly one byte changed from
Nov 15toNov 16in OpenLara’s__DATE__. The site now freezes project build dates. A full native Safari run with the corrected references is in progress. The experimental compiler package is separate from production.