Repository navigation
Lua: give a class's own allocator as a plain function, not a class-table method - #1537
Merged
Merged
Conversation
…ass-table method An allocation of a class with an allocator of its own called Class:create(), which looked the allocator up in the class table and passed the table, which the allocator never read. The allocator is now a plain function, Class_create(), called directly. Constructor names no longer share the class table's key space with dispatch slots, so the rename that kept them apart goes. On a large real map's optimised Lua this removes every SELF instruction (2245 allocation sites); in stock Lua 5.3 an allocate-and-destroy loop runs about 6% faster.
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. |
FastHashMapTests and TypeClassTests looked for a specialised class's allocator as Class:create(); it is Class_create() now.
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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.
An allocation of a class with its own allocator called
Class:create(). That looks the allocator up in the class table and passes the table asself, which the allocator never reads. The allocator is now a plain function,Class_create(), called directly.The constructor's name no longer shares the class table's key space with the dispatch slots. So the loop in
createMethodsthat renamed a constructor clashing with a slot is removed.Measured on the optimised Lua (
-inline -localOptimizations) of a large real map, counting opcodes with the bundledluac53 -l -p:SELFfell from 2,245 to 0, one per allocation site.SETTABLE−459,SETTABUP+459,GETTABUP−459.CALL,NEWTABLEandCLOSUREare unchanged.In stock Lua 5.3, a loop of two allocations and two destroys ran about 6% faster: median of 7 runs, 1.057 s down to 0.992 s, about 11 ns per allocation. That is the test Lua, not a measurement in the game.
Test.
LuaBackendAuditTests.ownAllocatorIsAPlainFunctionruns on Lua, Jass and the interpreter. It covers inheritance with array fields, an id recycled afterdestroy, dispatch andinstanceof. It also checks that no allocator is a method of its class table, so it fails with master's translator.Seven shape assertions in four test classes now expect
_create:CompiletimeTests,LuaBackendAuditTests,LuaTranslationTestsandLuaNameCompressionTests. These pass:LuaBackendAuditTests,LuaTranslationTests,LuaNameCompressionTests,CompiletimeTests,FieldIterationTests,LuaKeyedMapTests,DeterministicChecksandClassesTests. Only Windows was run.