Skip to content

[custom-descriptors] Branching descriptor casts #7622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 28, 2025
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented May 24, 2025

Implement basic support for br_on_cast_desc and br_on_cast_desc_fail
as new variants of BrOn. Include binary and text parsing and printing
as well as validation. Also handle the new operations anywhere the
compiler would otherwise complain about a non-exhaustive switch over the
BrCastOp enum.

For validation of type immediates during parsing, relax the requirement
that the cast type is a subtype of the input type. Continue validating
in the IR that the non-descriptor branching casts are downcasts, but do
not validate this for the new descriptor casts. See
WebAssembly/custom-descriptors#37 for context.

Add new validation and parsing tests in the form of spec tests in
preparation for creating an upstream spec test suite. While we're at it,
move the ref.get_desc tests to spec tests, add a few test cases, and fix
a bug when the ref.get_desc operand is null.

Implement basic support for `br_on_cast_desc` and `br_on_cast_desc_fail`
as new variants of `BrOn`. Include binary and text parsing and printing
as well as validation. Also handle the new operations anywhere the
compiler would otherwise complain about a non-exhaustive switch over the
`BrCastOp` enum.

For validation of type immediates during parsing, relax the requirement
that the cast type is a subtype of the input type. Continue validating
in the IR that the non-descriptor branching casts are downcasts, but do
not validate this for the new descriptor casts. See
WebAssembly/custom-descriptors#37 for context.

Add new validation and parsing tests in the form of spec tests in
preparation for creating an upstream spec test suite. While we're at it,
move the ref.get_desc tests to spec tests, add a few test cases, and fix
a bug when the ref.get_desc operand is null.
@tlively tlively requested a review from kripken May 24, 2025 02:55
shouldBeEqual(curr->castType,
Type(Type::none),
curr,
"non-cast br_on* must not set intendedType field");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"non-cast br_on* must not set intendedType field");
"non-cast br_on* must not set castType field");

if (ref->type.isNull()) {
// The operation will trap. Model it as returning an uninhabitable type.
type = ref->type.with(NonNullable);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because otherwise the assertion below will fail on the tests where the operands are null.

@tlively
Copy link
Member Author

tlively commented May 28, 2025

Landing despite lint failure because the required formatting fix is bogus.

@tlively tlively merged commit da7ed11 into main May 28, 2025
15 of 16 checks passed
@tlively tlively deleted the br-on-cast-desc branch May 28, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants