Skip to content

Update text format for exact heap types#7501

Merged
tlively merged 34 commits intomainfrom
text-parse-exact-heap-types
Apr 16, 2025
Merged

Update text format for exact heap types#7501
tlively merged 34 commits intomainfrom
text-parse-exact-heap-types

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented Apr 15, 2025

Since exactness is syntactically part of the heap type, it introduces a
new level of parentheses inside the reference type. Update type printing
and the text parser accordingly.

tlively added 6 commits April 14, 2025 19:26
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.
Having decided that storing exactness on the Type rather than HeapType
makes the most sense for our IR, revert the following PRs:

 - #7404
 - #7402

This will restore the original work on exact references. Follow-on PRs
will update it 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.
Since the Type representation only needs to include a bit for sharedness
for basic heap types and only needs to include a bit for exactness for
non-basic heap types, they can use the same bit. Using fewer bits in the
Type representation is beneficial because it reduces the minimum
alignment of HeapTypeInfos required to avoid trampling the reserved
bits.
Since exactness is syntactically part of the heap type, it introduces a
new level of parentheses inside the reference type. Update type printing
and the text parser accordingly.
@tlively tlively requested a review from kripken April 15, 2025 02:31
Base automatically changed from exact-shared-same-bit to main April 16, 2025 02:53
@tlively tlively merged commit 9aa06be into main Apr 16, 2025
14 checks passed
@tlively tlively deleted the text-parse-exact-heap-types branch April 16, 2025 04:04
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