Warp: Transpile BigInt operations.
Categories
(Core :: JavaScript Engine: JIT, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox86 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(24 files)
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details |
Assignee | ||
Comment 1•4 years ago
|
||
Add MacroAssembler::xor32(Address, Register)
based on the already existing
MacroAssembler::and32(Address, Register)
method.
The next part will call this method.
Assignee | ||
Comment 2•4 years ago
|
||
Inline BigInt comparison by looping over all digits, starting with the left-most one
until the first difference was found.
A later patch in this series will rename the existing
MacroAssembler::branchIfNegativeBigInt()
method to match the newly added
branchIfBigIntIsNonNegative()
method.
Depends on D98155
Assignee | ||
Comment 3•4 years ago
|
||
Reverse the comparison operator for "{Int32,Number,String} <comp> BigInt" when
emitting the CacheIR ops, so that we can remove Compare{Int32,Number,String}BigIntResult
in favour of using only CompareBigInt{Int32,Number,String}Result
.
This change allows to remove near duplicated code and helps to avoid writing more
duplicated code in the next parts.
Depends on D98156
Assignee | ||
Comment 4•4 years ago
|
||
Also rename branchIfNegativeBigInt
to branchIfBigIntIsNegative
to match
the other branch methods from part 2 and part 8.
Depends on D98157
Assignee | ||
Comment 5•4 years ago
|
||
Depends on D98158
Assignee | ||
Comment 6•4 years ago
|
||
Uses an ABI call to perform the actual comparison, because
BigInt::compare(BigInt*,double)
is too much code to easily implement with
inline assembly.
Depends on D98159
Assignee | ||
Comment 7•4 years ago
|
||
Uses a VM call similar to the CacheIR implementation.
Depends on D98160
Assignee | ||
Comment 8•4 years ago
|
||
Add branchIfBigIntIs{Non}Zero()
in preparation for the next parts. Also
updates existing code to use the new methods.
Depends on D98161
Assignee | ||
Comment 9•4 years ago
|
||
Add MacroAssembler::branchAddPtr()
in preparation for the next part.
Depends on D98162
Assignee | ||
Comment 10•4 years ago
|
||
The inline assembly code has an optimised path when both operands and the result
can be loaded in pointer-sized registers. Restricting the optimised path to
pointer-sized values instead of Int64 makes it easier to implement this code and
on x86 Int64 values can't be used anyway, because there aren't enough registers
available.
BigInt addition can throw when the resulting BigInt exceeds the maximum BigInt
digit length. Nonetheless MBigIntAdd
isn't marked as a guard instruction,
because (1) this matches the behaviour of MConcat
and (2) BigInt benchmarks
are available which rely on engines optimising out unused BigInt operations and
other engines already do just that.
Similar to number addition, MBigIntAdd
also provides recover support for DCE.
When a BigInt addition is recovered, we throw an "out of memory" error instead
of a RangeError when the result is too large. The "recover-bigint.js" test file
covers this case.
The BigIntArithPolicy
type policy matches the existing ArithPolicy
. Both
type policies may no longer be necessary for Warp, but this can be cleaned up
later.
The "bigint-add.js" test file was generated. It covers additions near the usual
limits (0, 2^31, 2^32, 2^63, 2^64).
Depends on D98163
Assignee | ||
Comment 11•4 years ago
|
||
The next part will call this method.
Depends on D98164
Assignee | ||
Comment 12•4 years ago
|
||
Transpile BigInt subtraction similar to BigInt addition from part 10.
Depends on D98165
Assignee | ||
Comment 13•4 years ago
|
||
Depends on D98166
Assignee | ||
Comment 14•4 years ago
|
||
Depends on D98167
Assignee | ||
Comment 15•4 years ago
|
||
Increment and decrement operations are for now implemented through separate
MBigIntIncrement
and MBigIntDecrement
MIR nodes. If we ever add cached
BigInt constants, we could think about implementing these operations through
MBigInt{Add,Sub}
similar to how their number counterparts are implemented.
Depends on D98168
Assignee | ||
Comment 16•4 years ago
|
||
The next part will call this method.
Depends on D98169
Assignee | ||
Comment 17•4 years ago
|
||
BigInt negation doesn't have any pointer-sized restrictions, but instead any
BigInt with inline digits can be handled in assembly code.
Depends on D98170
Assignee | ||
Comment 18•4 years ago
|
||
Depends on D98171
Assignee | ||
Comment 19•4 years ago
|
||
The next part will call this method.
Depends on D98172
Assignee | ||
Comment 20•4 years ago
|
||
The implementation follows the BigInt C++ code.
Depends on D98173
Assignee | ||
Comment 21•4 years ago
|
||
Add additional MacroAssembler shift methods in preparation for the next part.
Depends on D98174
Assignee | ||
Comment 22•4 years ago
|
||
The inlined shift operations are based on the BigInt C++ code.
Depends on D98175
Assignee | ||
Comment 23•4 years ago
|
||
BigInt division throws when the divisor is zero, so we can't optimise out
this operation, unless we can prove the divisor is non-zero.
Depends on D98177
Assignee | ||
Comment 24•4 years ago
|
||
Depends on D98178
Updated•4 years ago
|
Comment 25•4 years ago
|
||
Comment 26•4 years ago
|
||
Backed out 24 changesets (Bug 1679750) for causing build bustages in CodeGenerator.cpp CLOSED TREE
Failure log: https://treeherder.mozilla.org/logviewer?job_id=325160508&repo=autoland&lineNumber=3655
Backout: https://hg.mozilla.org/integration/autoland/rev/e10b35152bae741154eed0e098a8a50783001580
Assignee | ||
Updated•4 years ago
|
Comment 27•4 years ago
|
||
Comment 28•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a2193bebbaf3
https://hg.mozilla.org/mozilla-central/rev/74f4e8e94b07
https://hg.mozilla.org/mozilla-central/rev/a5fc93c132b9
https://hg.mozilla.org/mozilla-central/rev/db4fc233784d
https://hg.mozilla.org/mozilla-central/rev/751f898e3a42
https://hg.mozilla.org/mozilla-central/rev/956d262dbb5e
https://hg.mozilla.org/mozilla-central/rev/0c0e75cffd17
https://hg.mozilla.org/mozilla-central/rev/2ecab5047f08
https://hg.mozilla.org/mozilla-central/rev/7283ed22071c
https://hg.mozilla.org/mozilla-central/rev/41aaa79b1af2
https://hg.mozilla.org/mozilla-central/rev/2efc0c5f4e83
https://hg.mozilla.org/mozilla-central/rev/82ef5872f7db
https://hg.mozilla.org/mozilla-central/rev/84a4422d3959
https://hg.mozilla.org/mozilla-central/rev/b9a80dc531fe
https://hg.mozilla.org/mozilla-central/rev/0516b5a77d4f
https://hg.mozilla.org/mozilla-central/rev/a3eb45b67a5c
https://hg.mozilla.org/mozilla-central/rev/a089c0974d10
https://hg.mozilla.org/mozilla-central/rev/192a24886dd3
https://hg.mozilla.org/mozilla-central/rev/3e1ba8d59f6d
https://hg.mozilla.org/mozilla-central/rev/792e8850bba8
https://hg.mozilla.org/mozilla-central/rev/b8ecaacf7d5a
https://hg.mozilla.org/mozilla-central/rev/ea4aa0fe4e76
https://hg.mozilla.org/mozilla-central/rev/c00bf1a5a25a
https://hg.mozilla.org/mozilla-central/rev/916fe4f3e31a
Description
•