Skip to content
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

Flesh out more text support for GC types in components #1813

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Sep 20, 2024

This commit builds on the work of #1764 to support the text format for GC types in components more than before. This notably bring support for:

  • (sub ...) types in components and module types
  • (rec ...) groups in components and module types
  • types can refer to themselves like with core wasm

The main consequence of this work is that unlike most other $foo identifiers in the component model the identifiers found in types will not automatically inject outer aliases to refer to outer types. For example this will not parse:

(component $C
  (type $t (struct))
  (component
    (type (array (ref $t)))
  )
)

The reason for this is that automatic injection of an outer alias requires that types are resolved and then their names are registered. The resolution process queues up aliases to inject which are accounted for during registration when indices are assigned. Here though because types can refer to themselves (or future types in rec groups) the registration process has to happen first before resolution. This means that if resolution were to inject more type indices then that would mess up the indexes already assigned.

This is hopefully relatively minor in terms of how often this'll bite someone. For now various changes have been made to the name resolution pass of components to handle this and some tests have been added too for both positive and negative situations.

Closes #1808

This commit builds on the work of bytecodealliance#1764 to support the text format for
GC types in components more than before. This notably bring support for:

* `(sub ...)` types in components and module types
* `(rec ...)` groups in components and module types
* types can refer to themselves like with core wasm

The main consequence of this work is that unlike most other `$foo`
identifiers in the component model the identifiers found in types will
not automatically inject outer aliases to refer to outer types. For
example this will not parse:

    (component $C
      (type $t (struct))
      (component
        (type (array (ref $t)))
      )
    )

The reason for this is that automatic injection of an outer alias
requires that types are resolved and then their names are registered.
The resolution process queues up aliases to inject which are accounted
for during registration when indices are assigned. Here though because
types can refer to themselves (or future types in `rec` groups) the
registration process has to happen first before resolution. This means
that if resolution were to inject more type indices then that would mess
up the indexes already assigned.

This is hopefully relatively minor in terms of how often this'll bite
someone. For now various changes have been made to the name resolution
pass of components to handle this and some tests have been added too for
both positive and negative situations.
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Nice!

@fitzgen fitzgen added this pull request to the merge queue Sep 20, 2024
Merged via the queue into bytecodealliance:main with commit 90fd388 Sep 20, 2024
30 checks passed
@alexcrichton alexcrichton deleted the component-gc-types branch September 20, 2024 23:29
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.

Fill out support for GC types in the component model text format
2 participants