Use bailouts for jit::SetDenseElement and jit::ArrayPush
Categories
(Core :: JavaScript Engine: JIT, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox107 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
(Keywords: perf-alert)
Attachments
(4 files)
- Using a bailout for
ArrayPush
makes the alias-set forMArrayPush
a bit more correct. It's currentlyStore(ObjectFields | Elements)
, but it can actually also modify slots whensetOrExtendDenseElements
fails and we executeDefineDataElement
. - Using a bailout for
StoreElementHole
allows to re-add the alias-set override which was removed in bug 1607443.
And finally as an additional improvement, bailouts also makes it easier to add mightAlias
overrides for some guard operations, which allows to move guard instructions before loops. For example:
var arr = [];
for (var i = 0; i < N; ++i) {
arr.push(i);
}
Currently executes the following guards in the loop body:
13 constant object 2a9dfe23c088 (Array)
14 constant function push at 2a9dfe2612a8
...
16 guardshape newarrayobject5:Object
17 guardshape constant13:Object
18 slots guardshape17:Object
51 loaddynamicslotandunbox slots18:Slots (slot 6)
21 guardspecificfunction loaddynamicslotandunbox51:Object constant14:Object
22 objectstaticproto guardshape16:Object
23 guardshape objectstaticproto22:Object
24 objectstaticproto guardshape23:Object
25 guardshape objectstaticproto24:Object
Adding appropriate mightAlias
overrides makes it possible to move these guards before the loop body.
Assignee | ||
Comment 1•3 years ago
|
||
Use a bailout instead of calling DefineDataElement
. This won't lead to
performance issues, because calling DefineDataElement
will add an indexed
property and indexed properties will cause shape guards to fail the next time
this operation is called.
That means we can also change the function to an ABI call, which is slightly
faster than a VM call. We need additional temp registers for the ABI call,
therefore change the Spectre-temp to a normal, unconditional temp register.
Assignee | ||
Comment 2•3 years ago
|
||
Similar to part 1, also prefer a bailout for ArrayPush.
Depends on D157548
Assignee | ||
Comment 3•3 years ago
|
||
Part 1 allows to safely reintroduce the alias-set for MStoreElementHole
,
which was removed in bug 1607443.
Depends on D157549
Assignee | ||
Comment 4•3 years ago
|
||
This allows to hoist shape guards in situations like:
var arr = [];
for (var i = 0; i < N; ++i) {
arr.push(i);
}
Before this patch, we executed the following guards in the loop body:
13 constant object 2a9dfe23c088 (Array)
14 constant function push at 2a9dfe2612a8
...
16 guardshape newarrayobject5:Object
17 guardshape constant13:Object
18 slots guardshape17:Object
51 loaddynamicslotandunbox slots18:Slots (slot 6)
21 guardspecificfunction loaddynamicslotandunbox51:Object constant14:Object
22 objectstaticproto guardshape16:Object
23 guardshape objectstaticproto22:Object
24 objectstaticproto guardshape23:Object
25 guardshape objectstaticproto24:Object
After this patch all guards are moved before the loop body.
Similar improvements for this code snippet:
var arr = [];
for (var i = 0; i < N; ++i) {
arr[i] = i;
}
Where these guards are now moved before the loop body:
7 guardshape newarrayobject5:Object
8 objectstaticproto guardshape7:Object
9 guardshape objectstaticproto8:Object
10 objectstaticproto guardshape9:Object
11 guardshape objectstaticproto10:Object
Depends on D157550
Comment 6•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/4b82ed0bc340
https://hg.mozilla.org/mozilla-central/rev/ca1acbc1f294
https://hg.mozilla.org/mozilla-central/rev/241609720395
https://hg.mozilla.org/mozilla-central/rev/51423d631a9a
Comment 7•3 years ago
|
||
Perfherder has detected a talos performance improvement from push 51423d631a9a. Possible source of the improvement is this bug, Bug 1790990 or Bug 1790989. Which one of these bugs seem like the most plausible to have caused this improvement?
== Change summary for alert #35435 (as of Wed, 21 Sep 2022 17:56:54 GMT) ==
Improvements:
Ratio | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|
5% | kraken | macosx1015-64-shippable-qr | e10s fission stylo webrender | 1,435.76 -> 1,366.65 |
5% | kraken | macosx1015-64-shippable-qr | e10s fission stylo webrender | 1,432.94 -> 1,364.35 |
5% | kraken | windows10-64-shippable-qr | e10s fission stylo webrender | 1,258.41 -> 1,199.58 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=35435
Assignee | ||
Comment 8•3 years ago
|
||
(In reply to Acasandrei Beatrice (needinfo me) from comment #7)
Possible source of the improvement is this bug, Bug 1790990 or Bug 1790989. Which one of these bugs seem like the most plausible to have caused this improvement?
This bug is the most likeliest to have caused the improvement.
Updated•3 years ago
|
Description
•