-
Notifications
You must be signed in to change notification settings - Fork 786
Update exact reference semantics #7499
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
Revert the following PRs that introduced exactness on HeapType: - #7446 - #7444 - #7432 - #7412 - #7396 Keep only the changes to wasm-type-printing.cpp to fix the assertions that subclasses of TypeNameGeneratorBase correctly override getNames. Although putting exactness on heap types makes the most sense in the Custom Descriptors spec, it is not a great fit for how HeapType is used in Binaryen. In almost all cases, HeapType is used to represent heap type definitions rather than the dynamic types of values. Letting HeapType represent exact heap types is not useful in those cases and opens up a new class of possible bugs. To avoid these bugs, we had been introducing a new HeapTypeDef type to represent heap type definitions, but nearly all uses of HeapType would have had to have been replaced with HeapTypeDef. Rather than introduce HeapTypeDef as a third type alongside Type and HeapType, it will be simpler to continue using HeapType to represent heap type definitions and Type to represent the dynamic types of values, including their exactness. While exactness will syntactically be part of the heap type, it will be part of the `Type` in Binaryen IR. A follow-on PR will restore the original work on exact references, and PRs following that one will update the encoding, parsing, and printing of exact references to match the current spec.
In preparation for disallowing inexact references to abstract heap types, which are no longer allowed by the Custom Descriptors proposal.
Disallow exact references to abstract heap types and update subtyping to match the current proposed semantics.
@@ -795,13 +795,11 @@ Type Type::getLeastUpperBound(Type a, Type b) { | |||
if (auto heapType = HeapType::getLeastUpperBound(heapTypeA, heapTypeB)) { | |||
auto nullability = | |||
(a.isNullable() || b.isNullable()) ? Nullable : NonNullable; | |||
auto exactness = (a.isInexact() || b.isInexact()) ? Inexact : Exact; | |||
// The LUB can only be exact if the heap types are the same or one of them | |||
// is bottom. |
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.
This comment still seems useful, perhaps modified?
|
||
assertLUB(exactSup, exactSup, exactSup, exactSup); | ||
assertLUB(exactSup, nullExactSup, nullExactSup, exactSup); | ||
assertLUB(exactSup, sub, sup, none); |
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.
About the glb being none
, how can I see that in the lattice diagram? I'm confused as to where exact types fit in a lattice like this:
any
|
super
|
sub
|
none
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.
any
| \
super .
| \
sub exact super
| \ \
. exact sub .
|
.
....
\||/
none
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.
Thanks!
@@ -1,6 +1,6 @@ | |||
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | |||
|
|||
;; RUN: foreach %s %t wasm-opt -all --preserve-type-order --string-lowering -S -o - | filecheck %s | |||
;; RUN: wasm-opt %s -all --preserve-type-order --string-lowering -S -o - | filecheck %s |
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 there any harm to using foreach with a single module? it's future-proof...
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.
The only downside is that it makes it slightly more annoying to run the test manually, e.g. to repro bugs. Not much of a downside, but also a very easy change to make or undo, so I think it's worth it.
Disallow exact references to abstract heap types and update subtyping
to match the current proposed semantics.