Repository navigation
Interpreter: return and exitwhen by a flag, locals in a small array, plain stores without an address - #1450
Merged
Conversation
…plain stores without an address - A return threw a Java exception which unwound through the interpreter's frames to the call, and an exitwhen one to its loop. They set a flag on the call's local state now; a statement list stops when it is set, a loop ends on an exitwhen and the call on a return. Inside a statement expression, which cannot stop the expression around it, they still leave by the exception, which the call and the loop still catch. - Every call allocated a hash map for its locals. They are kept in a small array compared by identity, and a function with more than 16 locals goes over to the map. - An assignment to a variable allocated an address object to store through. It stores directly; finding the variable's state evaluates nothing. A large map: compile-time functions execute about 5 % to 12 % faster (cold 2075 to 1916 ms, warm first build 1890 to 1641 ms, warm later builds 890 to 840 ms, medians). Output and object data identical.
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. |
…ds exitwhen and return
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.
Per-call costs of the compile-time interpreter which remained after #1442:
returnthrew aReturnExceptionwhich unwound through the interpreter's frames (statement lists, ifs, loops) torunFunc, and anexitwhenanExitwhenExceptionto its loop. They set a flag on the call'sLocalStatenow:RunStatement.run(ImStmts)stops when it is set, a loop ends on an exitwhen (a return stays set), a vararg loop stops and leaves the flag to the loop around it as the exception did, and the call ends on a return. A return or exitwhen inside a statement expression cannot stop the expression around it by a flag, so it still leaves by the exception, whichrunFuncandImLoopstill catch. An exitwhen outside any loop fails as before.LocalStatekeeps them in a small array compared by identity (ImVarhas noequals), and a function with more than 16 locals goes over to the map ofState.ILaddressto store through.ImSetstores directly when the left side is a variable; finding the variable's state evaluates nothing, so the order of evaluation is unchanged.Compile-time functions of a large map (Jass, thousands of compile-time functions), execute phase against master: cold 2075 to 1916 ms, warm first build 1890 to 1641 ms, warm later builds 890 to 840 ms (medians of alternating runs). A modest gain; the exceptions and maps cost less than the samples suggested. Jass output and exported object data identical.
InterpreterTests.returnAndExitwhenLeaveTheRightStatementscovers a return from nested loops and ifs, an exitwhen in an if in an inner loop, a return from a vararg loop and an early return from a void function. Run locally: InterpreterTests, CompiletimeTests, CompiletimeNativesTest, CompiletimeHashtableTests, ClassesTests, ClassesExtTests, InterfaceTests, GenericsTests, GenericsWithTypeclassesTests, TypeClassTests, ClosureTests, ModuleTests, NewFeatureTests, BugTests, StdLibStringTests, StdLibOwnTests, OptimizerTests, VarargTests, TupleTests, ArrayTests.