Repository navigation
Keep a loop through ExecuteFunc apart - #1488
Conversation
CyclicFunctionRemover merged functions which reach each other only through ExecuteFunc into one function, which turned each ExecuteFunc into a direct call: the new thread and its own op limit were gone. A loop through ExecuteFunc needs no merging, since ExecuteFunc finds its target by name when it runs. Leaving such a loop apart reached the Jass emitter with a cycle of one ExecuteFunc and one ordinary call, which it reported as a cyclic dependency although it is valid Jass. An ExecuteFunc target is now emitted after the ordered traversal, and takes its place in the script when it is translated rather than when its caller names it, so it comes after the functions it calls.
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. |
|
Measured on the 3.0.0 client, with a Jass map built by master before and after this change ( |
CyclicFunctionRemovermerged functions which reach each other only throughExecuteFuncinto one function with afuncChoiceparameter, and turned eachExecuteFuncinto a direct call of it. So the target no longer ran on a new thread with its own op limit, which is whatExecuteFuncis for. A loop throughExecuteFuncneeds no merging: the call finds its target by name when it runs, so nothing has to be declared first. The cycle search now follows only the edges which order the functions (UsedFunctions.orderingRelevantTargets: calls other thanExecuteFunc, function references, method calls).That exposed a second case in the Jass emitter: a cycle of one
ExecuteFuncand one ordinary call back (valid Jass) was reported as a cyclic dependency, because the traversal descended into theExecuteFunctarget while its caller was still on the stack. Such a target is now queued and translated after the ordered traversal, and it takes its place in the script when it is translated rather than when its caller first names it; otherwise it would land before a function it calls (pjass:Undeclared function outer, checked by removing that half). No other function moves, since only anExecuteFunctarget can be named before it is translated.The Lua backend does not use either of these.
Tests in
BugTests, all red before the change (pjass on):executeFuncLoopIsNotMergedIntoOneFunction(no_opts, inlopt, stacktraceinlopt),executeFuncTargetCallingBackIntoItsCallerCompiles(Jass unit),executeFuncTargetCallingBackAboveItsCallerCompiles. Green locally (Windows): BugTests, OptimizerTests, ClassesTests, DispatchImplementationTests, NewFeatureTests, ModuleTests, ClosureTests, DeterministicChecks.