Repository navigation
Lua hashtables and the interpreter answer as Jass does - #1434
Merged
Merged
Conversation
Measured on the 3.0.0 client: a handle load is typed, saving a null handle stores nothing, FlushParentHashtable destroys the hashtable, and a null hashtable answers defaults and ignores writes. The Lua emulation tags each saved handle with the type of its native and checks it on load, skips null handles, points a flushed hashtable at a table which keeps nothing, and tests for a nil hashtable; the interpreter does the same, told which native was called.
Member
Author
|
@codex review |
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. |
|
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.
The Lua hashtable emulation answered differently from Jass in four cases, and so did the interpreter in three. Each case was measured on the 3.0.0 client, with one probe built as Jass and as Lua; each now answers as Jass on both.
LoadUnitHandle/LoadWidgetHandle/LoadGroupHandleSaveTimerHandle(h, p, c, null)over a saved timerFlushParentHashtable(h)What changes
Lua (
LuaHashtable,LuaHashtableTranslation, the helpers inLuaNatives). The in-place forms and the helpers stay the same as each other.__wurst_ht_htypeunder the same keys. A handle load answers the handle only for a tag it accepts: its own type, a widget's subtypes forLoadWidgetHandle,Widgetfor a widget subtype, andAgent. In place the check is one lookup in a constant main-chunk set (__wurst_htAccepts_Unit = {Unit=true, Widget=true, Agent=true}). Lua cannot tell a handle's type, so a handle saved through a supertype (SaveAgentHandle,SaveWidgetHandle) is answered to a narrower load.if h and v ~= nil then), and a literalnullprints nothing.FlushParentHashtablepoints every subtable at one shared table whose__newindexignores writes. Later saves are lost and every load answers its default.(h and h.T[p] or __wurst_htEmpty), and a save, remove or flush runs underif h then.Interpreter (
HashtableProvider).FlushParentHashtablemarks the table destroyed, and every native answers its default for a null hashtable.Stringis now passed the name of the native called (NativeJassFunction,ReflectionNativeProvider). That is how oneSave/LoadHandlemethod knows its type.CompiletimeFunctionRunner).docs/WC3_RUNTIME.mdrecords the measurement.Effect
Most of it is the null-hashtable test in each operation. Both scripts pass
luac -p. The probe, built as Lua with this branch and run in game, answers every hashtable case as the Jass build does, apart from two kinds of line. Two lines are dividends Jass reads differently (0.1). Two are the Lua null-string convention, which is not touched here: a missing string is nil while thenullliteral is"".Tests
hashtableOperationsBehaveAsTheNatives(Jass, the interpreter and Lua) and its optimised variant: typed loads, a null handle which replaces nothing and is not saved, a flushed hashtable which keeps nothing, and every operation on a null hashtable.anOperandWithAnEffectKeepsTheCallOfTheHelperchecks the same through the helpers.flushingTheWholeTableLeavesNothingToReplaychecks the compile-time replay of a destroyed table. Each fails on master.hashtableOperationsArePrintedWhereTheyAreCalled,hashtableFlushesTestNoSubtableand three Lua translation tests pin the new shapes.