Closed Bug 1907557 Opened 1 year ago Closed 1 year ago

Lazy tiering: replace signal-based tier-up requests with compiled code

Categories

(Core :: JavaScript: WebAssembly, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: jseward, Assigned: jseward)

References

Details

Attachments

(4 files)

Bug 1907151 provides an initial implementation of lazy tiering. Tier-up
requests are done by generating SIGILL (or OSX/Windows equivalents) and
handling the request in the signal handler. This is expensive and inflexible.
This bug is for replacing that mechanism with a compiled-code solution similar
to how debug-breakpoint trapping is done.

For the pieces of code that wasm-baseline uses for debugging, we use a
confusing mismash of terms: debug-trap/stub/breakpoint. Also, it isn't clear
from the naming that there are two kinds of code fragments involved:
per-function and per-module fragments.

This patch reworks some names and comments, so that

  • pieces of code are referred to as "stubs"

  • "trap" is restricted to denoting the general event of temporarily leaving
    baseline execution so as to enter the debug trap handler

  • the distinction between per-function and per-module stubs is clearer, and
    better documented

All of the above changes are for debug-support only events. There is no
change to terminology/names for other "trap" style events.

There are no functional changes at all.

This implements lazy tier-up requesting by:

  • adding a new routine, WasmHandleRequestTierUp, which handles tier-up
    requests

  • creating a "request tier-up stub" in each module, which calls to on to the
    above routine; this is similar to how debug-breakpoint requests are handled

  • reimplementing BaseCompiler::addHotnessCheck, so as to call to the above
    stub when required.

The code for the hotness check has been streamlined.

The previous SIGILL-based implementation remains in place, partially commented
out. It will be removed by the next patch in this series.

This removes wasm::Trap::CheckHotness, the code that generates that trap, and
the code that handles it. This mechanism has been replaced by a call-based
scheme in the previous patch in this series.

Currently WasmHandleRequestTierUp calls GetNearestEffectiveInstance to find
the relevant Instance*. This can be very expensive if the stack is deep.
It's also pointless, because the tier-up request it is responding to itself
knows the Instance*. So this patch merely causes the request-tier-up stub to
pass the value in InstanceReg as a parameter. This is easy to do because
we're guaranteed that InstanceReg has the right value at the start of the
request-tier-up, even on targets where it isn't pinned.

Blocks: 1908903
Pushed by jseward@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d126e058b96e part 1: improve terminology and documentation for debug traps. r=rhunt. https://hg.mozilla.org/integration/autoland/rev/ab7cabbd6494 part 2: request tier-up by making a call rather than using SIGILL. r=rhunt. https://hg.mozilla.org/integration/autoland/rev/b86ce0e6556b part 3: remove SIGILL-based tier-up-request mechanism. r=rhunt. https://hg.mozilla.org/integration/autoland/rev/b26822e772f3 part 4: pass Instance* from the request-tier-up stub. r=rhunt. https://hg.mozilla.org/integration/autoland/rev/d231ea667322 apply code formatting via Lando
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: