[Perf] compiler: eliminate the --no-opt self-compilation memory floor & stack-unsafety (#40) - #41
Merged
Merged
Conversation
…dle-end normally normalizes (--no-opt)
…free compilation pass
…itch, addInternStr
…he foreign module
…, many functions, wide array)
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.
What & why
This PR partially resolves #40 by addressing all currently identified scalability problems
except those originating in the optimization passes. With these fixes, purs-wasm can now
compile itself to Wasm under
--no-opt(running the self-compiled output is still gated onST support — see follow-ups).
Changes
Stop retaining CoreFn, MIR, and ANF IR in memory through code generation.
Previously, keeping all intermediate representations alive imposed a linear memory floor
proportional to compilation progress — the front-half OOM that blocked self-compilation.
Convert Effect impurification into a trampolined execution model (stack-safe on deep ASTs).
Fix several secondary issues uncovered by
--no-optbuilds:stripNewtypedid not traverseaspatterns (name@pat).letbindings failed to recognize functions built viamkFnN/mkEffectFnN(and let-wrapped / saturated point-free forms) as functions.genBodyspine,genSwitch/genLitSwitch,addInternStr).Arrayin rawEffect(whole-program emission loops).These interacted and collectively caused OOMs, hangs, and
Maximum call stack size exceededfailures in
--no-optbuilds.Fix uncovered while running the self-compiled compiler
Externs.Decoderimported PureScript ADT constructors from within a foreign module, relying onthe JS runtime representation of PS values. Reworked to pass the constructors in from the PS side
(the ADR-0014 foreign-provider idiom). In general, foreign modules must not depend on the JS
representation of PureScript values.
Follow-ups (not in this PR)
ulib/arraysfromFoldableand the broader ST mutable-array support on wasm — tracked on aseparate branch; the self-compiled compiler currently traps at the marshalling boundary for the
Data.Array.ST/Control.Monad.STforeign layer.Checklist
docs/+ ADRs reflect the changes (frontiers, supported-features, ADR 0020 / 0035 / 0036).unit lane; the codegen / serialize stack-safety fixes are currently validated only by the
self-compile, not by a routine-lane guard.
optimizer gate); the changes in this PR are bug/perf fixes within the existing ADR 0009 model.
node bench/run.mjs <dir>all withinnoise;
bench/snapshots/baseline.jsonnot overwritten.[ ] N/A Runtime GC-type / ABI — no value-substrate / host-ABI change.