Skip to content

Commit

Permalink
threads: add initial flags for shared-everything-threads (#1475)
Browse files Browse the repository at this point in the history
The [shared-everything-threads] proposal adds new `shared` annotations
in more places, new atomic instructions, new component model thread
intrinsics, etc. This change just sets the ground work by adding the
shared-everything-threads flags in all the places I found to be needed;
more PRs to follow.

[shared-everything-threads]: https://github.com/WebAssembly/shared-everything-threads
  • Loading branch information
abrown authored Mar 28, 2024
1 parent 6de5fbf commit cbf7c01
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/wasm-shrink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl ShrinkRun {
bulk_memory: true,
simd: true,
threads: true,
shared_everything_threads: false,
tail_call: true,
multi_memory: true,
exceptions: true,
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-smith/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn parser_features_from_config(config: &Config) -> WasmFeatures {
gc: config.gc_enabled,

threads: false,
shared_everything_threads: false,
floats: true,
extended_const: false,
component_model: false,
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-smith/tests/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ fn parser_features_from_config(config: &Config) -> WasmFeatures {
tail_call: config.tail_call_enabled,

threads: false,
shared_everything_threads: false,
floats: true,
extended_const: false,
component_model: false,
Expand Down
5 changes: 5 additions & 0 deletions crates/wasmparser/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ pub struct WasmFeatures {
pub relaxed_simd: bool,
/// The WebAssembly threads proposal (enabled by default)
pub threads: bool,
/// The WebAssembly shared-everything-threads proposal; includes new
/// component model built-ins.
pub shared_everything_threads: bool,
/// The WebAssembly tail-call proposal (enabled by default)
pub tail_call: bool,
/// Whether or not floating-point instructions are enabled.
Expand Down Expand Up @@ -266,6 +269,7 @@ impl WasmFeatures {
simd: true,
relaxed_simd: true,
threads: true,
shared_everything_threads: true,
tail_call: true,
floats: true,
multi_memory: true,
Expand Down Expand Up @@ -377,6 +381,7 @@ impl Default for WasmFeatures {
gc: false,
component_model_values: false,
component_model_nested_names: false,
shared_everything_threads: false,

// On-by-default features (phase 4 or greater).
mutable_global: true,
Expand Down
1 change: 1 addition & 0 deletions fuzz/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub fn validate_raw_bytes(u: &mut Unstructured<'_>) -> Result<()> {
reference_types: u.arbitrary()?,
multi_value: u.arbitrary()?,
threads: u.arbitrary()?,
shared_everything_threads: u.arbitrary()?,
simd: u.arbitrary()?,
component_model: u.arbitrary()?,
tail_call: u.arbitrary()?,
Expand Down
3 changes: 3 additions & 0 deletions src/bin/wasm-tools/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ fn parse_features(arg: &str) -> Result<WasmFeatures> {
("function-references", |f| &mut f.function_references),
("simd", |f| &mut f.simd),
("threads", |f| &mut f.threads),
("shared-everything-threads", |f| {
&mut f.shared_everything_threads
}),
("bulk-memory", |f| &mut f.bulk_memory),
("multi-value", |f| &mut f.multi_value),
("tail-call", |f| &mut f.tail_call),
Expand Down
5 changes: 5 additions & 0 deletions tests/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ impl TestState {
fn wasmparser_validator_for(&self, test: &Path) -> Validator {
let mut features = WasmFeatures {
threads: true,
shared_everything_threads: false,
reference_types: true,
simd: true,
relaxed_simd: true,
Expand Down Expand Up @@ -637,6 +638,10 @@ impl TestState {
"tail-call" => features.tail_call = true,
"memory64" => features.memory64 = true,
"component-model" => features.component_model = true,
"shared-everything-threads" => {
features.component_model = true;
features.shared_everything_threads = true;
}
"multi-memory" => features.multi_memory = true,
"extended-const" => features.extended_const = true,
"function-references" => features.function_references = true,
Expand Down

0 comments on commit cbf7c01

Please sign in to comment.