Repository navigation
Propagate copies of values which depend on the local player - #1482
Merged
Merged
Conversation
Constant and copy propagation refused every value the local-player analysis marks as dependent, "deliberately conservative" since #1207. A propagation replaces a read of a local by the local or constant it is known to hold at that point: on every client the replaced read sees the value the original read saw, and no computation moves, appears or disappears, so it cannot make clients diverge. The passes which do move code (the local merger, the branch merger) keep their locality checks. In UI code, where most values derive from client-local frame state, the guard kept almost every copy the inliner makes. Without it the pass needs no locality analysis and is an ordinary pass; the function splitter builds the analysis for the local merger only, after the propagation.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Constant and copy propagation refused every value the local-player analysis marks as dependent. The guard came with #1207 as "deliberately conservative", without a test of its own.
Why it is safe to drop
A propagation replaces a read of a local by the local or constant it is known to hold at that point (
q = voter; f(q)becomesf(voter)). Sources are locals, constants and call results only; a global is never a propagation source. On every client the replaced read sees the value the original read saw, and no computation moves, appears or disappears. So the transformation preserves each client's behaviour exactly and cannot make clients diverge, whatever the value depends on. The passes which do move code keep their locality checks: the local merger (now the only locality-aware pass in the sweep) and the branch merger's hoisting.Without the guard the pass needs no locality analysis, so it is an ordinary
OptimizerPass.FunctionSplitternow builds the analysis for the local merger only, after the propagation (before, the merger was asked about a body the propagation had already rewritten). The analyzer's doc no longer lists the propagation among the passes which move code.Why it matters
In UI code most values derive from client-local frame state, so the analysis marks whole functions dependent and the guard kept almost every copy the inliner makes. On the optimised Lua of two large maps (static luac 5.3 instructions):
Most of it is
MOVE(-13,090 and -8,610). With the aliases gone, the redundant-field-store pass also sees more duplicate field initialisations. For example,ArrayList_size_storage[this] = 0afterArrayList:create()had already written 0 through another alias. That removes 535 and 219 table writes.Tests
OptimizerTests.copyOfLocalPlayerValueIsPropagated: a local copied from a field holdingGetLocalPlayer(), with the source still live (so the merger cannot remove it). On master the optimised Jass keepslocal player q = voter; now every read usesvoter.OptimizerTests(including all local-player tests),LocalPlayerContextAnalyzerTests,LuaBackendAuditTests,LuaTranslationTests,ObservableEffectsTests,DeterministicChecks,CompiletimeTestsand the Lua backend classes, 739 tests.This is independent of #1481 (the other copy-propagation fix), which touches a different part of the same file.