Consider using a 32-bit field for BigInt length
Categories
(Core :: JavaScript Engine, enhancement, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox70 | --- | fixed |
People
(Reporter: terpri, Assigned: wingo)
References
Details
Attachments
(3 files, 1 obsolete file)
Currently, the digit length of a BigInt value is stored in the first word of its cell, along with a sign bit and bits reserved by GC. Should it be stored instead in a fixed 32-bit field, similar to JSStrings? This would reduce the space left over for inline digits on some platforms, but might simplify JIT integration since code for strings could be reused.
| Assignee | ||
Updated•7 years ago
|
| Assignee | ||
Comment 1•7 years ago
|
||
| Assignee | ||
Comment 2•7 years ago
•
|
||
To be clear the tradeoff here is that for 32-bit x86, arm32, and mips32, we go from 96 bits of inline storage -- meaning that we can store values in (-2^96, 2^96) without having to malloc external storage -- to 64 bits of inline storage. But probably most values are either in the 64-bit range or rather large; and if the just-over-64-bit space becomes important, we'd need to fix for 64-bit targets as well.
On 64-bit platforms (mips64, arm64, x86-64), we were already limited to 64 bits of inline storage. With this change the maximum possible bigint length decreases from a theoretical 2^64-1 digits, each digit being 64 bits, to 2^32-1 digits. But that's already like 32 GByte for a single value, so no big deal there.
What we gain is easier access to the length field, which makes JIT a bit easier.
Updated•7 years ago
|
Comment 3•6 years ago
|
||
The next part will change BigInt to use the same base class.
Comment 4•6 years ago
|
||
Depends on D39318
Updated•6 years ago
|
Comment 6•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/5055a6b65938
https://hg.mozilla.org/mozilla-central/rev/6aeaedaaa1af
Comment 7•6 years ago
|
||
I had to use try-except instead of "in" because if the value is a pointer type
(like JSString*) then "in" returned false.
I tested this with both 32-bit and 64-bit builds.
Comment 10•6 years ago
|
||
| bugherder | ||
Description
•