Warp: Make Number.is{Safe}Integer inlinable again
Categories
(Core :: JavaScript Engine: JIT, enhancement, P3)
Tracking
()
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(4 files)
Ion used to be able to inline Number.is{Safe}Integer() and also inline away most of its instructions.
| Assignee | ||
Comment 1•5 years ago
|
||
Instead of Math.abs() and Math.floor(), directly use Math.trunc() in
both Number.isInteger() and Number.isSafeInteger(). Also replace the last
if-statement in Number.isSafeInteger() with a return statement to avoid
exceeding the small, inlinable function size limit. And add a test to ensure we
don't regress that size limit.
Drive-by change:
- Remove the function declaration for
OptimizationInfo::isSmallFunction().
| Assignee | ||
Comment 2•5 years ago
|
||
MCallOptimize optimised away int32 inputs to Math.{ceil, floor, round, trunc}.
Add the same optimisation to CacheIR, so Warp can also optimise these calls
away.
Depends on D97910
| Assignee | ||
Comment 3•5 years ago
|
||
MUnbox was previously using BoxInputsPolicy and BoxInputsPolicy has an
optimisation to reuse the input of MUnbox operands, see BoxAt(). This
prevented to use the MToDouble optimisation in MUnbox::foldsTo(), which
in turn disabled the MToDouble optimisation in
MCompare::evaluateConstantOperands().
This issue prevented to optimise away the integer <= (2 ** 53) - 1 check
in Number.isSafeInteger when it is called with int32 inputs:
When Number.isSafeInteger(number) was called with number being an int32,
the call to Math.trunc(number) was correctly optimised away. But then CacheIR
was using CompareDoubleResult for integer <= (2 ** 53) - 1, which applies
GuardIsNumber on both inputs. GuardIsNumber is transpiled to MUnbox, so
we ended up with unbox input to Double. But when input is already another
MUnbox, we get unbox (unbox value to Int32) to Double and BoxAt() was
then reusing the previous MUnbox and returned unbox value to Double. This
prevented applying the MToDouble optimisation in MUnbox::foldsTo(), which
then prevented the other MToDouble optimisation in
MCompare::evaluateConstantOperands(). Therefore we couldn't successfully
optimise away the whole integer <= (2 ** 53) - 1 comparison, even though we
knew that integer was an int32 and therefore is always lower than the safe
integer limit.
Depends on D97911
| Assignee | ||
Comment 4•5 years ago
|
||
This change allows to optimise away the number - integer === 0 comparison
in Number.is{Safe}Integer() for int32 inputs.
Depends on D97912
Updated•5 years ago
|
Updated•5 years ago
|
Comment 6•5 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/5dcf6e5a3f6f
https://hg.mozilla.org/mozilla-central/rev/1f893388f957
https://hg.mozilla.org/mozilla-central/rev/940b0d3275f3
https://hg.mozilla.org/mozilla-central/rev/7c9098ae666d
Updated•5 years ago
|
Description
•