-
Notifications
You must be signed in to change notification settings - Fork 825
[threads] Validate shared-to-unshared edges in heap types #6698
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| ;; Shared array declaration syntax | ||
| (module | ||
| (type (shared (array i8))) | ||
| (type (sub final (shared (array i8)))) | ||
| (rec | ||
| (type (sub final (shared (array i8)))) | ||
| ) | ||
|
|
||
| (global (ref 0) (array.new_default 1 (i32.const 1))) | ||
| (global (ref 1) (array.new_default 2 (i32.const 1))) | ||
| (global (ref 2) (array.new_default 0 (i32.const 1))) | ||
| ) | ||
|
|
||
| ;; Shared arrays are distinct from non-shared arrays | ||
| (assert_invalid | ||
| (module | ||
| (type (shared (array i8))) | ||
| (type (array i8)) | ||
|
|
||
| (global (ref 0) (array.new_default 1 (i32.const 1))) | ||
| ) | ||
| "not a subtype" | ||
| ) | ||
|
|
||
| (assert_invalid | ||
| (module | ||
| (type (shared (array i8))) | ||
| (type (array i8)) | ||
|
|
||
| (global (ref 1) (array.new 0)) | ||
| ) | ||
| "not a subtype" | ||
| ) | ||
|
|
||
| ;; Shared arrays may not be subtypes of non-shared arrays | ||
| (assert_invalid | ||
| (module | ||
| (type (sub (array i8))) | ||
| (type (sub 0 (shared (array i8)))) | ||
| ) | ||
| "invalid supertype" | ||
| ) | ||
|
|
||
| ;; Non-shared arrays may not be subtypes of shared arrays | ||
| (assert_invalid | ||
| (module | ||
| (type (sub (shared (array i8)))) | ||
| (type (sub 0 (array i8))) | ||
| ) | ||
| "invalid supertype" | ||
| ) | ||
|
|
||
| ;; Shared arrays may not contain non-shared references | ||
| (assert_invalid | ||
| (module | ||
| (type (shared (array anyref))) | ||
| ) | ||
| "invalid field" | ||
| ) | ||
|
|
||
| ;; But they may contain shared references | ||
| (module | ||
| (type (shared (array (ref null (shared any))))) | ||
| ) | ||
|
|
||
| ;; Non-shared arrays may contain shared references | ||
| (module | ||
| (type (array (ref null (shared any)))) | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| ;; Shared struct declaration syntax | ||
| (module | ||
| (type (shared (struct))) | ||
| (type (sub final (shared (struct)))) | ||
| (rec | ||
| (type (sub final (shared (struct)))) | ||
| ) | ||
|
|
||
| (global (ref 0) (struct.new 1)) | ||
| (global (ref 1) (struct.new 2)) | ||
| (global (ref 2) (struct.new 0)) | ||
| ) | ||
|
|
||
| ;; Shared structs are distinct from non-shared structs | ||
| (assert_invalid | ||
| (module | ||
| (type (shared (struct))) | ||
| (type (struct)) | ||
|
|
||
| (global (ref 0) (struct.new 1)) | ||
| ) | ||
| "not a subtype" | ||
| ) | ||
|
|
||
| (assert_invalid | ||
| (module | ||
| (type (shared (struct))) | ||
| (type (struct)) | ||
|
|
||
| (global (ref 1) (struct.new 0)) | ||
| ) | ||
| "not a subtype" | ||
| ) | ||
|
|
||
| ;; Shared structs may not be subtypes of non-shared structs | ||
| (assert_invalid | ||
| (module | ||
| (type (sub (struct))) | ||
| (type (sub 0 (shared (struct)))) | ||
| ) | ||
| "invalid supertype" | ||
| ) | ||
|
|
||
| ;; Non-shared structs may not be subtypes of shared structs | ||
| (assert_invalid | ||
| (module | ||
| (type (sub (shared (struct)))) | ||
| (type (sub 0 (struct))) | ||
| ) | ||
| "invalid supertype" | ||
| ) | ||
|
|
||
| ;; Shared structs may not contain non-shared references | ||
| (assert_invalid | ||
| (module | ||
| (type (shared (struct anyref))) | ||
| ) | ||
| "invalid field" | ||
| ) | ||
|
|
||
| ;; But they may contain shared references | ||
| (module | ||
| (type (shared (struct (ref null (shared any))))) | ||
| ) | ||
|
|
||
| ;; Non-shared structs may contain shared references | ||
| (module | ||
| (type (struct (ref null (shared any)))) | ||
| ) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems surprising this only applies to references, when we have shared Memories for example, so we do have shared i32s etc. But I guess they must be referred to indirectly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't have separate shared
i32as a type.i32and other non-reference types validate just fine in both shared and unshared contexts.