Open
Bug 1983130
Opened 5 months ago
Updated 3 months ago
Optimize comparisons with object-or-null values better
Categories
(Core :: JavaScript Engine: JIT, task, P2)
Core
JavaScript Engine: JIT
Tracking
()
NEW
People
(Reporter: jandem, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
One of the hottest functions in JetStream3's raytrace tests with both private and public class fields has a !== operation where we use a BinaryBoolCache IC in Ion.
The LHS is always an object but the RHS is an object or null. This is likely quite common and we should find a way to optimize this without using an IC in Ion.
Below is a micro-benchmark for this (if I change the null value in the array to {} we're almost 2x faster with --spectre-mitigations=off).
function f() {
var arr = [{}, null];
var res = 0;
var t = Date.now();
for (var i = 0; i < 100_000_000; i++) {
res += arr[0] !== arr[i & 1];
}
print(Date.now() - t);
return res;
}
f();
Updated•5 months ago
|
Severity: -- → N/A
Priority: -- → P2
| Reporter | ||
Comment 1•4 months ago
|
||
A related case shows up in prettier-wtb. Their traversal code uses a marker object (from the non-minified version):
const traverseDocOnExitStackMarker = {};
And then inside a function:
const doc = docsStack.pop();
if (doc === traverseDocOnExitStackMarker) {
We use an IC for the comparison in Ion (I think the values can be strings?) but the RHS is always going to be an object.
Summary: Optimize comparions with object-or-null values better → Optimize comparisons with object-or-null values better
You need to log in
before you can comment on or make changes to this bug.
Description
•