Closed Bug 1536703 Opened 5 years ago Closed 5 years ago

Implement StoreToTypedArray for BigInt

Categories

(Core :: JavaScript Engine: JIT, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox68 --- wontfix
firefox72 --- fixed

People

(Reporter: terpri, Assigned: anba)

References

Details

Attachments

(4 files)

No description provided.
Blocks: 1456569
Priority: -- → P2
Assignee: nobody → andrebargull

CacheIR.cpp:
Disallow bigint properties right away in GetPropIRGenerator::tryAttachTypedObject
to fix a null-pointer crash in CacheIRCompiler::emitLoadTypedObjectResultShared,
which passes fail = nullptr to MacroAssembler::loadFromTypedArray, even though
loadFromTypedArray always uses the fail Label for bigint types.

IonBuilder.cpp:
Ensure we don't create MLoadUnboxedScalar or MStoreUnboxedScalar for bigint
types, because the former always leads to a bailout and the latter asserts when
bigint types are used.

Provide an inline assembly implementation of BigInt::toUint64() resp. BigInt::toInt64().

Depends on D48333

Just curious, do you have some micro-benchmarks comparing before/after? It's always nice to see speedups :)

Flags: needinfo?(andrebargull)

Sure:

// store: 465ms -> 35ms
function f() {
    var xs = [
        new BigInt64Array(10),
        new BigInt64Array(10),
    ];
    var t = dateNow();
    for (var i = 0; i < 5000000; ++i) {
        xs[i&1][i&7] = 0n;
    }
    print(dateNow() - t);
}

And for bug 1536702:

// load: 480ms -> 145ms
function f() {
    var xs = [
        new BigInt64Array(10),
        new BigInt64Array(10),
    ];
    var q = 0;
    var t = dateNow();
    for (var i = 0; i < 5000000; ++i) {
        if (xs[i&1][i&7]) q++;
    }
    print(dateNow() - t);
}
Flags: needinfo?(andrebargull)

Nice :D

Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7bb7d2354ec7
Part 1: Avoid crashes for TypedObjects using bigint properties. r=jandem
https://hg.mozilla.org/integration/autoland/rev/e48626d69e77
Part 2: Add support for reading [u]int64 values from a BigInt to the MacroAssembler. r=jandem
https://hg.mozilla.org/integration/autoland/rev/e512b7dafc1f
Part 3: Inline stores to BigInt TypedArray/Objects in CacheIR. r=jandem
https://hg.mozilla.org/integration/autoland/rev/f1e9ada5d498
Part 4: Add test cases for storing BigInt values to TypedArray/Objects. r=jandem

Keywords: checkin-needed
Regressions: 1593801
You need to log in before you can comment on or make changes to this bug.