Skip to content

Restrict all context.{get,set} in same component to use same elem type#645

Open
lukewagner wants to merge 2 commits intomainfrom
limit-context
Open

Restrict all context.{get,set} in same component to use same elem type#645
lukewagner wants to merge 2 commits intomainfrom
limit-context

Conversation

@lukewagner
Copy link
Copy Markdown
Member

This PR adds validation rules that require all context.get and context.set definitions inside a component to use the same element type (currently either i32 or, with #624, i64). Conceptually, this validation rule would be attached to what it means for a component definition to be valid. In the short-term, this might allow context.set i32 to avoid a store-zero when implemented on 32-bit CPUs (to clear the high bits of the underlying i64 storage) if there's no whole-component information to indicate the absence of context.set i64s in the same component. In the longer-term, this change would allow core wasm reference types to be efficiently used as element types, since the simple aliasing approach of i32/i64 wouldn't work.

(cc @adambratschikaye)

@lukewagner
Copy link
Copy Markdown
Member Author

Additionally, the second commit tweaks the binary format rules in Binary.md to use validation to gate context.{get,set} and (type (resource (rep v))) to i32/i64 instead of decoding rules. This mostly only shows up in whether WAST tests report a decoding vs. validation error, as highlighted in wasm-tools/#2502.

Comment thread design/mvp/Binary.md
Comment thread design/mvp/Binary.md
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