Closed Bug 1712030 Opened 2 years ago Closed 2 years ago

Improve optimization of polymorphic ToBool ICs

Categories

(Core :: JavaScript Engine: JIT, task, P1)

task

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: iain, Assigned: iain)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

In Bug 1710905, we optimized polymorphic TypeOf using success count data from ICs to reorder type checks based on their dynamic frequency. We can do the same thing for ToBool ICs (And, Or, Not, JumpIfTrue, JumpIfFalse, Not), which are turned into MTest in WarpBuilder. (Not has separate MIR/LIR, but the polymorphic case bottoms out in the same place during codegen, testValueTruthyKernel.

I have a WIP patch that implements the non-Not cases. The main thing left to resolve is handling boolean values. BaselineCodeGen::emitToBoolean has a fast-path for bools before calling the IC, so we never attach a bool-typed stub and don't have any frequency data.

On a deliberately extreme microbenchmark (an Or with a 100:1 ratio of double:undefined, where double is last in the default order), this reduces the time from 3700 ms to 2100ms.

The previous default order had double last, after symbol and bigint, which I think was just an artifact of adding those types after writing this code. I moved double ahead of those two.

Adding branchTestType made this code easier to write. In a subsequent patch I use it to also simplify emitTypeOfCheck.

Depends on D116780

Attachment #9225087 - Attachment description: Bug 1712030: Reorder type checks in testValueTruthyKernel based on observed types r=jandem → Bug 1712030: Reorder type checks in testValueTruthyKernel based on observed types r=jandem!
Pushed by iireland@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cf22942d1b7b
Reorder type checks in testValueTruthyKernel based on observed types r=jandem
https://hg.mozilla.org/integration/autoland/rev/eacd134abf12
Reorder type checks for polymorphic Not r=jandem
https://hg.mozilla.org/integration/autoland/rev/f5bd924ce786
Use branchTestType in emitTypeOfCheck r=jandem
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
You need to log in before you can comment on or make changes to this bug.