Closed Bug 1695778 (Core-Wasm-EH-Ion) Opened 3 years ago Closed 2 years ago

Implement the core wasm exception handling instructions in the optimizing compiler

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: idimitriou, Assigned: idimitriou)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

For the WebAssembly Exception Handling proposal, extend support for try-catch and throw to the Ion compiler.

Note that we're in the process of landing Ion on ARM64 (bug 1678097) and until it lands you'll not have test coverage on that platform.

Severity: -- → N/A
Status: NEW → ASSIGNED
OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All

Adds support for the core of the WebAssembly Exception Handling instructions, try-catch/catch_all and throw.

This initial patch does not add support for WebAssembly values of type reftype inside exception packages.

This patch also does not implement the instructions rethrow or delegate, which will be part of a different bug.
Due to this, the tests that are targeting these two instructions are made conditional on the test being run with the baseline compiler.
There are tests added for side effects in try blocks, and tests with complex control flow with exceptions thrown from calls.

This builds on the current, landed version of Wasm EH, without the latest spec changes,
according to which try can have no catches and events are renamed to tags.
When the relevant bugs for baseline are closed (1716869, 1716041, 1716043, 1717118),
I will update this patch accordingly.

The latest update implements catchless try blocks, since bug 1716043 has landed.

Attachment #9227924 - Attachment description: Bug 1695778 - Core Wasm EH instructions in Ion without reftypes. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt

Adds tests mentioned in Bug 1727953.

Depends on D118283

Implements the instruction try-delegate from the WebAssembly Exception Handling proposal, and enables try-delegate related tests for the optimizing compiler.

Spec:
https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md#try-delegate-blocks

Changes:

  • Adds a try-tracker which notes the try-depths of all surrounding
    Wasm-labels.
  • Shifts the pad-patches vector by 1, so patches delegated to the
    function body get collected at padsPatches_[0].
  • When EmitEnd has LabelKind::Body, any above pad patches are bound to a
    landing pad that just rethrows the exception.
  • Once we read delegate l at a try-depth (say d0), we calculate the
    try-depth for relative depth l (say d1), and we move padsPatches[d0] to
    append them to padsPatches[d1], thus "tunnelling" any exceptions thrown
    in the delegate's try block to the target landing pad.

Depends on D123884

I updated the revisions to the current stand, and added some documentation, in comments and in the commit messages. I also added part 3, which implements try-delegate.

The revision stack is now dependent on revision D124550, and part-1 adds the Ion parts in that implementation of the suggestions from the latest review comment.

Only one revision is now missing, support for reftype values in exceptions. A first implementation I have locally stills fails tests when gczeal(2, 1) is enabled (the last test in reftypes.js).

Attachment #9227924 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=lth
Attachment #9238367 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=lth
Attachment #9242595 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=lth
Attachment #9227924 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=lth → Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt,lth
Attachment #9238367 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=lth → Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=rhunt,lth
Attachment #9242595 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=lth → Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=lth,rhunt
Attachment #9227924 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt,lth → Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt
Attachment #9238367 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=rhunt,lth → Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=rhunt
Attachment #9242595 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=lth,rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=rhunt

This patch concludes support for the WebAssembly Exception Handling proposal.

Spec: https://github.com/WebAssembly/exception-handling

Changes:

  • Mirroring the Baseline approach, and the Ion approach for numeric values,
    this patch adds two MIR and LIR nodes:
    • WasmExceptionRefsPointer to get a pointer to the ArrayObject REFS of a
      WasmExceptionObject, and
    • WasmLoadExceptionRefsValue to get a RefOrNull value from a
      WasmExceptionRefsPointer
  • Storing a RefOrNull value in the exception is done via the instance call
    SASigPushRefIntoExn. Since this pushes the value in the Refs Array, we
    iterate backwards.
  • The above mentioned instance call is changed to follow this review
    comment on part 1 of this patchset:
    https://phabricator.services.mozilla.com/D118283#inline-716841
  • Enables all tests in .../wasm/exceptions/, and adds reftypes in some
    existing tests.

Depends on D126425

Depends on: 1744663
Attachment #9227924 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=lth
Attachment #9238367 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 2: rethrow. r=lth
Attachment #9242595 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 3: try-delegate. r=lth
Attachment #9253316 - Attachment description: Bug 1695778 - (Core-Wasm-EH-Ion) part 4: Support reftypes in exceptions. r=rhunt → Bug 1695778 - (Core-Wasm-EH-Ion) part 4: Support reftypes in exceptions. r=lth

With the help of @dbezhetskov, we fixed the issues with Wasm-baseline (bug 1744663).

Everything should be working now and I think all review comments are addressed.

Just did a mach try auto with this patchset, including the patch from bug 1744663:
https://treeherder.mozilla.org/jobs?repo=try&revision=d1772434dfc2ce459d1d8e756b830bccaee1dd9d

I had forgotten to put v128 related parts of the last test in bug-1744663-extended.js under the flag wasmSimdEnabled, which caused test failures.

Fixed this and rebased to the current tip. Some failing tests in the try, not sure how these failures are related to the code in these patches:
https://treeherder.mozilla.org/jobs?repo=try&revision=a8e469b98477c8054032f8894658d938929e8760

Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/integration/autoland/rev/6823e921b023
(Core-Wasm-EH-Ion) part 1: try-catch/throw without reftypes. r=rhunt
https://hg.mozilla.org/integration/autoland/rev/4f1b07ddbdd5
(Core-Wasm-EH-Ion) part 2: rethrow. r=lth
https://hg.mozilla.org/integration/autoland/rev/6af2787fb743
(Core-Wasm-EH-Ion) part 3: try-delegate. r=lth
https://hg.mozilla.org/integration/autoland/rev/9f3a22091abd
(Core-Wasm-EH-Ion) part 4: Support reftypes in exceptions. r=rhunt
Regressions: 1747562
Regressions: 1747704
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: