Closed Bug 1937570 Opened 2 months ago Closed 2 months ago

Optimize JSOp::Lambda in Baseline

Categories

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

task

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(3 files)

js::Lambda will be the most-called VMFunction on Speedometer 3 after bug 1935632. Baseline IC code is likely responsible for most of these calls.

This is a very common operation (arrow functions likely contributed) that should be fast in Baseline too. The simplest option is probably to implement this with an IC similar to what we do for the NewObject and NewArray ops.

A Baseline IC for JSOp::Lambda gets rid of pretty much all of these VM calls. For the micro-benchmark below I get:

--no-ion before: 268 ms
--no-ion after:   94 ms
no flags:         55 ms
function f() {
    var res;
    var t = new Date;
    for (var i = 0; i < 10_000_000; i++) {
        res = x => x + 1;
    }
    print(new Date - t);
    return res;
}
f();

The code for LLambda already relied on this because it copies the flags from
the canonical function to the new function.

This is similar to the NewObject and NewArray IC stubs. We allocate a new
function object in JIT code and copy the shape and most slots from the canonical
function.

js::Lambda is one of our hottest VMFunctions on Speedometer 3 and this gets
rid of most of these calls. On Baseline-only micro-benchmarks this is almost 3x faster.

This improves JetStream's date-format-tofte test by about 8%. This test has a function that uses eval (so no Ion) and this function has a number of inner functions that we now clone more efficiently.

Speedometer 3 shows some medium/high confidence 1-2% improvements on various subtests on Windows 11. Pretty nice for a change like this.

https://treeherder.mozilla.org/perfherder/compare?originalProject=try&newProject=try&newRevision=9a26de7a25c562e8eb3ffc9ff32f91085c2dc7be&framework=13&originalRevision=557eeb4584cde4ababf93bc7fc8f85261f226517&page=1

Severity: -- → N/A
Priority: -- → P2
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3ebb07224094 part 1 - Assert canonical function has not resolved length/name. r=iain https://hg.mozilla.org/integration/autoland/rev/21a62d3a0144 part 2 - Add a Baseline IC for JSOp::Lambda. r=iain https://hg.mozilla.org/integration/autoland/rev/1dbbfc3b5ee2 part 3 - Add Baseline CacheIR stub for JSOp::Lambda. r=iain
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch

11% improvement on Jetstream2-date-format-tofte-SP

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: