Closed
Bug 1730699
Opened 3 years ago
Closed 3 years ago
Optimize for-in with null/undefined better
Categories
(Core :: JavaScript Engine, task, P3)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
94 Branch
Tracking | Status | |
---|---|---|
firefox94 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
(Blocks 2 open bugs)
Details
Attachments
(4 files)
for-in loops on null/undefined are somewhat common. Speedometer hits this too. We have some performance problems:
- We allocate a new empty iterator for this each time, instead of reusing the same iterator object.
- We don't have CacheIR support for this case. This can result in disabling the IC if this shows up a few times.
A patch stack to fix these issues improves the micro-benchmark below from 220 ms to 5 ms.
function f() {
var t = new Date;
for (var i = 0; i < 1_000_000; i++) {
for (var p in undefined) {}
}
print(new Date - t);
}
f();
Assignee | ||
Comment 1•3 years ago
|
||
This changes the empty iterator objects we create for for-in with null/undefined
to be immutable and unlinked.
The next patch will cache this object on the global.
Assignee | ||
Comment 2•3 years ago
|
||
Depends on D125551
Assignee | ||
Comment 3•3 years ago
|
||
Depends on D125552
Assignee | ||
Comment 4•3 years ago
|
||
Depends on D125553
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c7eae2ddd714 part 1 - Treat empty iterators for null/undefined as immutable and unlinked. r=jonco https://hg.mozilla.org/integration/autoland/rev/cab0e02d59e1 part 2 - Cache empty iterator on the global. r=jonco https://hg.mozilla.org/integration/autoland/rev/48465af484b5 part 3 - Clean up CacheIR code for GetIterator a bit. r=jonco https://hg.mozilla.org/integration/autoland/rev/8a9d97b273e7 part 4 - Add CacheIR optimization for GetIterator with null/undefined. r=jonco
Comment 6•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c7eae2ddd714
https://hg.mozilla.org/mozilla-central/rev/cab0e02d59e1
https://hg.mozilla.org/mozilla-central/rev/48465af484b5
https://hg.mozilla.org/mozilla-central/rev/8a9d97b273e7
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
status-firefox94:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 94 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•