Enable the gc/global.wast spec test#1296
Closed
fitzgen wants to merge 1 commit into
Closed
Conversation
This involved queuing up table init expressions for later validation because: * Tables (and their init expressions) come before globals are defined in the binary format, * constant expressions can contain `global.get`s of defined globals now, * and therefore a table init can validly reference a global before it is defined. This is not ideal, but is fine, since we have some other end-of-module checking already in `validate_end`. However, that alone isn't good enough. Because constant expressions can contain `ref.func $f` instructions, which need to insert `$f` into the "referenced function" set, we need mutable access to the `Arc<Module>` when processing constant expressions. So we need to drain the unchecked table init expressions *before* processing each code body, when we still have unique access to the `Arc<Module>`. But not all Wasm modules have code sections, so at the same time, we still need to do the checking inside `validate_end`. And when there was a code section, the queue of table init expressions will have already been drained by the time we are in `validate_end`, so it is okay that we no longer have unique access to the `Arc<Module>`.
alexcrichton
left a comment
Member
There was a problem hiding this comment.
Huh I'm a bit surprised that bulk-memory went with a data-count section and gc went this direction. To confirm this is what other engines are doing?
Also can this new validation behavior be gated behind the gc feature?
Member
Author
|
Aha, I guess that our copy of the test suite is a bit out of date, because they fixed this upstream so that the contex that table initializers are evaluated within do not have defined globals present anymore: |
Member
Author
|
Just FYI, I started trying to update the testsuite and plumb that through to this repo, but I probably won't finish today and I go on vacation for three weeks starting tomorrow. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This involved queuing up table init expressions for later validation because:
global.gets of defined globals now,This is not ideal, but is fine, since we have some other end-of-module checking already in
validate_end. However, that alone isn't good enough. Because constant expressions can containref.func $finstructions, which need to insert$finto the "referenced function" set, we need mutable access to theArc<Module>when processing constant expressions. So we need to drain the unchecked table init expressions before processing each code body, when we still have unique access to theArc<Module>. But not all Wasm modules have code sections, so at the same time, we still need to do the checking insidevalidate_end. And when there was a code section, the queue of table init expressions will have already been drained by the time we are invalidate_end, so it is okay that we no longer have unique access to theArc<Module>in that case.