Repository navigation
Interpreters and Lua: real division by zero stops, R2I saturates, as measured - #1435
Conversation
…n Jass Measured on the 3.0.0 client: 1. / 0., 0. / 0., 5. % 0. and ModuloReal(5., 0.) stop the thread in Jass. The interpreters answered an infinity and went on; a real division or modulo by zero is now the same error as an integer one.
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b96b0e8c1
ℹ️ 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".
…d values Measured on the 3.0.0 client with operands computed at run time: R2I saturates outside the 32-bit range in Jass and in the game's Lua, and R2S and R2SW print the whole integer part. The wrap the interpreter modelled was Jass's reading of real literals past 2^31. The interpreter's R2I saturates and its R2S and R2SW print the whole number; on Lua the R2I lowering answers the bound itself instead of calling the global R2I, which the test runtime did not define.
|
@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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 441416fc57
ℹ️ 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".
Two interpreter models of Jass's real arithmetic were wrong, and so was the Lua
R2Ioutside the 32-bit range. Each was measured on the 3.0.0 client with operands computed at run time, so no literal reader touches them.A real division by zero stops the thread
Jass stops the thread on
1. / 0.,-1. / 0.,0. / 0.,5. % 0.andModuloReal(5., 0.), each run in a guarded callback in a test map. The interpreters answered an infinity, so a real modulo by zero (Blizzard.j's formula since #1433) answered the dividend, and the program went on.WurstOperator.divideRealthrows the sameArithmeticExceptionas an integer division by zero. The IM interpreter (/and the real modulo) and the Jass interpreter (ILconstNum.div) both divide reals through it.1. / 0.is 1.7014e38 (the largest float, not an infinity),-1. / 0.its negative, and0. / 0.is 1. The Lua backend adds no check, which would cost every real division whose divisor is not a literal.R2I saturates; R2S and R2SW print the whole number; real literals past 2^31 are what wraps
R2I(50000. * 100000.)(5000000320)R2I(-(50000. * 100000.))R2I(a computed 1e20)R2S(30000. * 100000.)3000000000.000-1294967296.000R2SW(-(30000. * 100000.), 1, 3)-3000000000.0001294967296.000The wrap the interpreter modelled came from literals. Jass reads a real literal whose integer part passes 2^31 as wrapped to 32 bits, signed:
3000000000. > 0.is false in Jass, and10000000000.reads as 1410065408. The earlier measurements ofR2I,R2SandR2SWused such literals, so they recorded the literal reader, not the natives.WurstOperator.realToInt(the interpreter'sR2I) saturates, as Java's cast does, with NaN as 0.R2SandR2SWprint the whole integer part, exactly, also past the long range.R2Iand__wurst_rawR2Ianswer the bound themselves outside the range. Before, they called the globalR2I, which the game has but nothing defined for the test runtime. The test runtime's ownR2Ifallback saturates too.docs/WC3_RUNTIME.md: Jass's wrapped reading of such literals (the interpreter, like Lua, reads them correctly), and the game printing a computed 5e9 as5000000320.000.Tests
realDivisionByZeroStopsTheInterpreters(new):1. / 0.,5. % 0.and0. / 0.stop the interpreter and the Jass interpreter.r2iSaturatesInEveryRun(new):R2Iof a computed 5000000320, its negative and its square, plus a real modulo whose quotient leaves the range, in the interpreter, on Jass and on Lua.stringNativesAsMeasured: the literal-basedR2S/R2SW/R2Iexpectations become the computed measurements above.