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

[spec] Update global.get note on constant expressions #481

Merged
merged 2 commits into from
Nov 11, 2023

Conversation

takikawa
Copy link
Contributor

Currently the spec has this note:

Note

Currently, constant expressions occurring in globals, element, or data segments are further constrained in that contained instructions are only allowed to refer to imported globals. This is enforced in the validation rule for modules by constraining the context accordingly.

The definition of constant expression may be extended in future versions of WebAssembly.

https://webassembly.github.io/gc/core/valid/instructions.html#valid-constant

I think this is outdated given that GC allows incremental validation of globals. IIUC, uses of global.get data and element segments are unconstrained now as well. This PR has a minimal change for this wording.

The global.get instruction can refer to previously defined globals in
addition to imported ones now. Uses of global.get in data and element
segments can refer to any global.
@takikawa
Copy link
Contributor Author

I realized after pushing the first version that tables also have constraints that are different from globals (only imported globals for global.get), so I've added that too.

Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

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

Thanks!

@rossberg rossberg merged commit bf5679d into WebAssembly:main Nov 11, 2023
4 checks passed
webkit-commit-queue pushed a commit to takikawa/WebKit that referenced this pull request Nov 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=264616

Reviewed by Yusuke Suzuki.

The GC proposal allows constant expressions in globals to be read sequentially
(previously defined globals are ok). For tables, only imported globals. For
other contexts, any globals are fine.

See WebAssembly/gc#481

* JSTests/wasm/gc/const-exprs.js:
(async testConstExprGlobalOrdering):
* Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp:
(JSC::Wasm::ConstExprGenerator::getGlobal):
* Source/JavaScriptCore/wasm/WasmSectionParser.cpp:
(JSC::Wasm::SectionParser::parseInitExpr):

Canonical link: https://commits.webkit.org/271183@main
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