Repository navigation
Convert an integer stored into a real on Lua - #1492
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76afe45024
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
Jass converts an integer stored where a real is declared:
set r = n,local real r = n, an integer argument for a real parameter. Lua kept the integer, and the game's Lua computes integers in 32 bits, so a product of the stored value wrapped where Jass multiplies reals. Only Jass code stores an integer there (an int is a real only in Jass code).On Lua the translation to IM now converts at those stores (
ExprTranslation.isIntStoredAsReal): the value becomesn + 0., next to the existing case of a literal, which was already translated as the real it stands for. Since the conversion is in the IM from the start, the interpreter, the optimiser and the backend all see it. An operand of an operator gets nothing (the operation converts), and Wurst code gets nothing. The Jass target is unchanged.Tests (LuaBackendAuditTests, each red before the change):
jassIntStoredIntoRealIsARealOnLua: a global, an array element, a local initialiser and a parameter, run on Lua (fourth power of 65536, which wraps at 64 bits in the test Lua too) plus the emitted shape.jassIntStoredIntoRealStaysARealWhenInlinedOnLua: the same with-inline -localOptimizations; before, copy propagation and inlining made each of themn * n * n * n.wurstRealCodeGetsNoIntConversionOnLua: no conversion in Wurst real code.Measured on the 3.0.0 client, Lua maps built by master before and after this change (
-inline -localOptimizations, every operand read from an array at run time):/ 65536.real r = 14 div 2(Wurst),/ 4, x1000, local and global/ 2, x1000set r = nthenset r = r / m, x1000/ 2, x1000/ 2, x1000/ 2, x1000The divisions were already right on Lua, whose
/always gives a real. Jass gives 65536 in the square case.Locally green on Windows: LuaBackendAuditTests, LuaTranslationTests, LuaCodeListTests, LuaHashtableTests, LuaKeyedMapTests, LuaMultipleResultsTests, LuaNativesTests, LuaSyntaxCheckTests, LuaTypecastingTests, BugTests, ExpressionTests, DeterministicChecks, CompiletimeTests. Of the 347 Lua scripts those tests emit, only the two Jass repros get a conversion.
The interpreters and the Jass optimiser rewrites for the same stores are #1484; the runtime test here is Lua only so it does not depend on that.
An integer returned from a function which returns real is left out of the tests and the table on purpose: #1491 makes it a type error, as pjass already does, except on legacy targets. The translation still converts it there, so the two PRs do not depend on each other in either order.