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

Implement parsing of tables with initializer expressions #823

Merged
merged 1 commit into from Nov 17, 2022

Conversation

yurydelendik
Copy link
Contributor

The function references proposal adds initializer for tables when its type is non-nullable reference. The text format is extended with constant expression (which can have ref.func). The binary format adds 0x40 0x00 prefix to the table section entry to indicate expression presence.

https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md

@yurydelendik
Copy link
Contributor Author

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks! Reading over the proposal though I'm not sure if the TableType is the best place to store and parse this. It seems that the initialization expression is only a matter for table definitions, not general type declarations such as table imports. If that's the case, could the parsing here be updated to only parse the initialization expression for a table declaration rather than a general table type?

@yurydelendik
Copy link
Contributor Author

could the parsing here be updated to only parse the initialization expression for a table declaration rather than a general table type?

I made this decision based on implied idea that this default/init expression becomes a "metadata" that affect other operations such as table.grow.

@alexcrichton
Copy link
Member

I don't think that it's type level information, though, but rather runtime information? I could be misunderstanding the spec, though, but for example when a table is imported is the initializer element specified? If so I would expect that the spec would grow more logic around the "matching" semantics to test whether two table types are equivalent, and if not I think it's runtime information that is stateful but not part of the type information.

The function references proposal adds initializer for tables when
its type is non-nullable reference. The text format is extended
with constant expression (which can have ref.func). The binary format
adds `0x40 0x00` prefix to the table section entry to indicate expression
presence.

https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md
@yurydelendik
Copy link
Contributor Author

Simplified patch by moving init_expr out of TableType.

@alexcrichton alexcrichton merged commit ebce499 into bytecodealliance:main Nov 17, 2022
alexcrichton added a commit to alexcrichton/wasm-tools that referenced this pull request Nov 21, 2022
This fixes a recent fuzz-bug found from bytecodealliance#823 where initialization
expressions needed to be expanded before resolution.
alexcrichton added a commit that referenced this pull request Nov 21, 2022
This fixes a recent fuzz-bug found from #823 where initialization
expressions needed to be expanded before resolution.
@yurydelendik yurydelendik deleted the table-not-null branch February 21, 2023 20:52
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.

None yet

2 participants