Closed Bug 1784276 Opened 2 years ago Closed 2 years ago

Add br_on_cast_fail instruction to baseline

Categories

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

task

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: rhunt, Assigned: jseward)

References

Details

Attachments

(3 files)

Implement the following concrete casting instructions in baseline:

br_on_cast
br_on_cast_fail

All of these take a type index, there are some casting operations that operate on a heap type but those will be in a separate bug. ref.cast/test are already implemented in baseline.

Whoah, I completely forgot that I already implemented br_on_cast. The work in this bug will be just to implement the inverted version then.

Summary: Add br_on_cast instructions to baseline → Add br_on_cast_fail instruction to baseline

WIP patch with some initial cleanups and comments. See commit message in patch for details.

This is a cleanup change created while studying what it would take to implement
br_on_cast_fail for wasm baseline. Currently WasmOpIter.h has routines
OpIter<Policy>::popThenPushType and OpIter<Policy>::topWithTypeAndPush which
are almost identical, and neither is well documented.

The names are particularly confusing because they imply different behaviour
with respect to the total number of elements in the stack (pop vs top) whereas
in fact neither routine removes elements from the stack.

This patch merges them and renames the resulting routine
OpIter<Policy>::checkTopTypeMatches, which describes better what it does.
Comments have also been added.

Related small ridealong fix: js::wasm::TypeAndValueT: removed ::typeRef() and
added ::setType() for consistency with ::value/::setValue. And because names
involving "ref" and "type" are a potential source of confusion.

Assignee: nobody → jseward
Status: NEW → ASSIGNED

This patch implements br_on_cast_fail for wasm baseline, in a way which shares
almost all code with the existing br_on_cast. Main changes:

  • BaseCompiler::emitBrOnCast: renamed to ::emitBrOnCastCOMMON, which handles
    both the on-cast-success and on-cast-failure cases.

  • OpIter<Policy>::checkCastedBranchValueAndPush has been removed and then
    reinstated (with changes) as ::readBrOnCastCOMMON, which as above handles
    both the on-cast-success and on-cast-failure cases. Removal of this (in
    effect, inlining it into its one-and-only caller) means the validation logic
    and associated comments are located in only one place rather than two.

  • OpIter<Policy>::readBrOnCastCOMMON: add comments to explain the types
    involved, and the validation and run-time checks required. These are then
    implemented.

  • new test case tests/wasm/gc/br-on-cast-fail.js

Depends on D158492

Pushed by jseward@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/144f430b57b7 Part 1: merge OpIter<Policy>::popThenPushType and ::topWithTypeAndPush. r=rhunt.
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
Pushed by jseward@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3e0946a05331 Part 2: implement br_on_cast_fail for wasm baseline. r=rhunt.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: