Closed Bug 1525664 Opened 7 years ago Closed 6 years ago

Consider using a 32-bit field for BigInt length

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla70
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.

Blocks: js-bigint
Assignee: nobody → wingo

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.

Priority: -- → P2
Attachment #9047369 - Attachment is obsolete: true
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5055a6b65938 part 1 - Move length/flags fields from JSString to a new CellWithLengthAndFlags class. r=tcampbell https://hg.mozilla.org/integration/autoland/rev/6aeaedaaa1af part 2 - Change BigInt to use CellWithLengthAndFlags. r=tcampbell,wingo
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70

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.

Regressions: 1572385
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c44d035213c1 follow-up - Fix GDB pretty printer for JSString. r=jonco
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: