Closed Bug 1680602 Opened 3 years ago Closed 3 years ago

Implement Warp Compiled Async Functions

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: mgaudet, Assigned: mgaudet)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(13 files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

Currently Warp cannot compile generators nor async functions. This limits our potential performance.

This also leads to potential performance cliffs as developers adopt APIs that use promises, where writing async functions substantially eases the burden of working with them.

The TrySkipAwait opcode optimization is challenging to JIT compile because of
the complicate semantics of its return values. In order to make this
dramatically more simple to JIT implement, this patch splits TrySkipAwait into
two ops: CanSkipAwait and MaybeExtractAwaitValue.

The first op, CanSkipAwait does the preparation to ensure that it would be
legal to skip the await enqueue. The second op, MaybeExtractAwaitValue uses
the result of the CanSkipAwait to decide if it should leave the value alone
or instead replace it with the awaited value. This pair of ops is a bit easier
for Warp to model in MIR than a single op.

Depends on D98755

When Warp compiled generators are enabled, we can no longer rely on
BaselineFrameReg being preserved, so we should instead recompute it from the
frame descriptor.

Depends on D98757

This doesn't matter at the moment, but once we can Warp compile generators we
will need the JIT stack to be JitStack aligned. As well, we will need
BaselineBailouts to understand that one of the possible stack frames could be
the BaselineFrame created by a generator body OSR'ing into Warp.

We need to zero out the area for alignment, as during GC it can be inspected
assuming it contains valid values.

Depends on D98758

This patch allows us to warp compile a function that has been marked as async
unnecessarily; for example async foo() { return 10; }.

Handling this case doesn't require too much special code as we are able to
identify these via bytecode inspection, and the semantics of the newly required
bytecode aren't too complex. We don't need to handle yield or resume.

Depends on D98760

MPseudoReturn generates the same sequence as MReturn, but from the perspective
of MIR is simply a regular opcode which consumes a value. This will be used to
handle yields in async functions and generators.

Depends on D98761

Blocks: 1681336
Blocks: 1681338
Severity: -- → N/A
Status: NEW → ASSIGNED
Priority: -- → P1

(Marking leave open, as we're landing in a disabled state)

Keywords: leave-open
Attachment #9191293 - Attachment description: Bug 1680602 - Add MPseudoReturn in anticipation of its use in Warp async functions r?jandem → Bug 1680602 - Add MGeneratorReturn in anticipation of its use in Warp async functions r?jandem
Pushed by mgaudet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8cc2056a0216
Eagerly allocate storage for generator saved slots r=jorendorff
https://hg.mozilla.org/integration/autoland/rev/db358fced289
Split `TrySkipAwait` into two opcodes r=arai
https://hg.mozilla.org/integration/autoland/rev/e4c40b24f5dd
Add IonAbort JitSpew when a script is Warp disabled r=jandem
https://hg.mozilla.org/integration/autoland/rev/15983b7d4b34
Prepare for Warp compiled generator functions by recomputing BaselineFrameReg in Resume implementation r=iain
https://hg.mozilla.org/integration/autoland/rev/038847f6366c
Align stack pointer, and clear alignment area, before calling GeneratorResume r=iain
https://hg.mozilla.org/integration/autoland/rev/81978ede452f
Implement GetRVal in Warp r=iain
https://hg.mozilla.org/integration/autoland/rev/94851e694f9c
Add JitOption for warp compiling generators and async functions r=iain
https://hg.mozilla.org/integration/autoland/rev/6dda9ceb4625
Warp compile 'Accidentally Async' functions r=iain
https://hg.mozilla.org/integration/autoland/rev/04b71d7076e3
Add MGeneratorReturn in anticipation of its use in Warp async functions r=jandem
https://hg.mozilla.org/integration/autoland/rev/9b74983c1c00
Support Await in Warp compiled Generator Bodies r=iain
https://hg.mozilla.org/integration/autoland/rev/553d30e157b4
Implement CanSkipAwait and MaybeExtractAwaitValue in Warp r=iain
https://hg.mozilla.org/integration/autoland/rev/e3e9dda1ede2
Add OSR Mismatch JitSpew r=iain
https://hg.mozilla.org/integration/autoland/rev/dd3293cb1a1b
Disable Warp compiled Async Functions by default r=iain
Blocks: 1682616
Keywords: leave-open
Summary: Warp Compile Async Functions → Implement Warp Compiled Async Functions

(Will add a new bug to enable, allowing this one to get closed)

Blocks: 1682623
Regressions: 1683306
Regressions: 1683309
Regressions: 1683614
Whiteboard: [sp3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: