CFG Part 0: Max Stack Size & Peephole Optimizer Fixes/Improvements#2561
Open
ike709 wants to merge 14 commits intoOpenDreamProject:masterfrom
Open
CFG Part 0: Max Stack Size & Peephole Optimizer Fixes/Improvements#2561ike709 wants to merge 14 commits intoOpenDreamProject:masterfrom
ike709 wants to merge 14 commits intoOpenDreamProject:masterfrom
Conversation
added 8 commits
May 9, 2026 23:59
Collaborator
Author
|
I'm calling this PR done barring any review comments. I did another testing pass without any of my other non-committed experimental changes, and confirmed that TG and goon both compile, while also making sure I can start a round on TG. |
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.
This PR does a few things:
Jumpoptimizations from Control Flow Graph #2558AttemptCurrentOpt()switch()cases no longer emit aJumpinstruction if the last operation is a terminal change in control flow (e.g.return)spawn()blocks no longer emitPushNullandReturnif the last operation is a terminal change in control flow (e.g.return)AnnotatedBytecodeVariableduring opt scanningJumpinstructions are more aggressively pruned by the bytecode optimizerI did before & after diffs on /tg/station compilation & disassembly to confirm that this resulted in further optimizations to the bytecode without introducing any apparent regressions. The
NullRefopt in particular was being left on the table in thousands of cases, while the other peephole optimizer changes are less dramatic but still present.The fixes to max stack size are also a huge improvement. Thousands of procs have either had their max stack size reduced to 0 or have seen a reduction from double to single digits. I ran TG through round init to confirm nothing exploded.
This sufficiently beats the codegen and optimizer into submission to the point that we can now implement dead code detection (after CFG is finished) and run it on /tg/station and goonstation without getting false positives.