-
Notifications
You must be signed in to change notification settings - Fork 787
[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
Conversation
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.
src/wasm/wasm-validator.cpp
Outdated
shouldBeEqual(curr->castType, | ||
Type(Type::none), | ||
curr, | ||
"non-cast br_on* must not set intendedType field"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Landing despite lint failure because the required formatting fix is bogus. |
Implement basic support for
br_on_cast_desc
andbr_on_cast_desc_fail
as new variants of
BrOn
. Include binary and text parsing and printingas 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.