diff --git a/crates/wasm-encoder/src/component/builder.rs b/crates/wasm-encoder/src/component/builder.rs index 8c78b40d43..13c0eec03f 100644 --- a/crates/wasm-encoder/src/component/builder.rs +++ b/crates/wasm-encoder/src/component/builder.rs @@ -379,9 +379,9 @@ impl ComponentBuilder { inc(&mut self.core_funcs) } - /// Declares a new `thread.hw_concurrency` intrinsic. - pub fn thread_hw_concurrency(&mut self) -> u32 { - self.canonical_functions().thread_hw_concurrency(); + /// Declares a new `thread.available_parallelism` intrinsic. + pub fn thread_available_parallelism(&mut self) -> u32 { + self.canonical_functions().thread_available_parallelism(); inc(&mut self.core_funcs) } diff --git a/crates/wasm-encoder/src/component/canonicals.rs b/crates/wasm-encoder/src/component/canonicals.rs index e1ea1783ce..7c5a253ea8 100644 --- a/crates/wasm-encoder/src/component/canonicals.rs +++ b/crates/wasm-encoder/src/component/canonicals.rs @@ -169,7 +169,7 @@ impl CanonicalFunctionSection { /// Defines a function which will return the number of threads that can be /// expected to execute concurrently. - pub fn thread_hw_concurrency(&mut self) -> &mut Self { + pub fn thread_available_parallelism(&mut self) -> &mut Self { self.bytes.push(0x06); self.num_added += 1; self diff --git a/crates/wasm-encoder/src/reencode/component.rs b/crates/wasm-encoder/src/reencode/component.rs index c19f4da3e2..12b08130f6 100644 --- a/crates/wasm-encoder/src/reencode/component.rs +++ b/crates/wasm-encoder/src/reencode/component.rs @@ -964,8 +964,8 @@ pub mod component_utils { let func_ty = reencoder.type_index(func_ty_index); section.thread_spawn(func_ty); } - wasmparser::CanonicalFunction::ThreadHwConcurrency => { - section.thread_hw_concurrency(); + wasmparser::CanonicalFunction::ThreadAvailableParallelism => { + section.thread_available_parallelism(); } wasmparser::CanonicalFunction::TaskBackpressure => { section.task_backpressure(); diff --git a/crates/wasmparser/src/readers/component/canonicals.rs b/crates/wasmparser/src/readers/component/canonicals.rs index 6fe9f16536..bd3c06b4c7 100644 --- a/crates/wasmparser/src/readers/component/canonicals.rs +++ b/crates/wasmparser/src/readers/component/canonicals.rs @@ -74,7 +74,7 @@ pub enum CanonicalFunction { }, /// A function which returns the number of threads that can be expected to /// execute concurrently - ThreadHwConcurrency, + ThreadAvailableParallelism, /// A function which tells the host to enable or disable backpressure for /// the caller's instance. TaskBackpressure, @@ -272,7 +272,7 @@ impl<'a> FromReader<'a> for CanonicalFunction { 0x05 => CanonicalFunction::ThreadSpawn { func_ty_index: reader.read()?, }, - 0x06 => CanonicalFunction::ThreadHwConcurrency, + 0x06 => CanonicalFunction::ThreadAvailableParallelism, 0x08 => CanonicalFunction::TaskBackpressure, 0x09 => CanonicalFunction::TaskReturn { result: match reader.read_u8()? { diff --git a/crates/wasmparser/src/validator.rs b/crates/wasmparser/src/validator.rs index 86dc227d7e..11b30088ca 100644 --- a/crates/wasmparser/src/validator.rs +++ b/crates/wasmparser/src/validator.rs @@ -1307,8 +1307,8 @@ impl Validator { crate::CanonicalFunction::ThreadSpawn { func_ty_index } => { current.thread_spawn(func_ty_index, types, offset, features) } - crate::CanonicalFunction::ThreadHwConcurrency => { - current.thread_hw_concurrency(types, offset, features) + crate::CanonicalFunction::ThreadAvailableParallelism => { + current.thread_available_parallelism(types, offset, features) } crate::CanonicalFunction::TaskBackpressure => { current.task_backpressure(types, offset, features) diff --git a/crates/wasmparser/src/validator/component.rs b/crates/wasmparser/src/validator/component.rs index 1ccd1a5e64..06aadcbeda 100644 --- a/crates/wasmparser/src/validator/component.rs +++ b/crates/wasmparser/src/validator/component.rs @@ -1733,7 +1733,7 @@ impl ComponentState { Ok(()) } - pub fn thread_hw_concurrency( + pub fn thread_available_parallelism( &mut self, types: &mut TypeAlloc, offset: usize, @@ -1742,7 +1742,7 @@ impl ComponentState { if !features.shared_everything_threads() { bail!( offset, - "`thread.hw_concurrency` requires the shared-everything-threads proposal" + "`thread.available_parallelism` requires the shared-everything-threads proposal" ) } diff --git a/crates/wasmprinter/src/component.rs b/crates/wasmprinter/src/component.rs index 626a0c1bef..762af3f7ec 100644 --- a/crates/wasmprinter/src/component.rs +++ b/crates/wasmprinter/src/component.rs @@ -902,11 +902,11 @@ impl Printer<'_, '_> { self.end_group()?; state.core.funcs += 1; } - CanonicalFunction::ThreadHwConcurrency => { + CanonicalFunction::ThreadAvailableParallelism => { self.start_group("core func ")?; self.print_name(&state.core.func_names, state.core.funcs)?; self.result.write_str(" ")?; - self.start_group("canon thread.hw_concurrency")?; + self.start_group("canon thread.available_parallelism")?; self.end_group()?; self.end_group()?; state.core.funcs += 1; diff --git a/crates/wast/src/component/binary.rs b/crates/wast/src/component/binary.rs index 5e2cd29959..f8a86c8d83 100644 --- a/crates/wast/src/component/binary.rs +++ b/crates/wast/src/component/binary.rs @@ -353,9 +353,9 @@ impl<'a> Encoder<'a> { self.core_func_names.push(name); self.funcs.thread_spawn(info.ty.into()); } - CanonicalFuncKind::ThreadHwConcurrency(_info) => { + CanonicalFuncKind::ThreadAvailableParallelism(_info) => { self.core_func_names.push(name); - self.funcs.thread_hw_concurrency(); + self.funcs.thread_available_parallelism(); } CanonicalFuncKind::TaskBackpressure => { self.core_func_names.push(name); diff --git a/crates/wast/src/component/expand.rs b/crates/wast/src/component/expand.rs index 5f171feec5..abd95bb88d 100644 --- a/crates/wast/src/component/expand.rs +++ b/crates/wast/src/component/expand.rs @@ -269,7 +269,7 @@ impl<'a> Expander<'a> { | CanonicalFuncKind::ResourceRep(_) | CanonicalFuncKind::ResourceDrop(_) | CanonicalFuncKind::ThreadSpawn(_) - | CanonicalFuncKind::ThreadHwConcurrency(_) + | CanonicalFuncKind::ThreadAvailableParallelism(_) | CanonicalFuncKind::TaskBackpressure | CanonicalFuncKind::TaskReturn(_) | CanonicalFuncKind::TaskWait(_) @@ -338,12 +338,12 @@ impl<'a> Expander<'a> { name: func.name, kind: CanonicalFuncKind::ThreadSpawn(info), }), - CoreFuncKind::ThreadHwConcurrency(info) => { + CoreFuncKind::ThreadAvailableParallelism(info) => { ComponentField::CanonicalFunc(CanonicalFunc { span: func.span, id: func.id, name: func.name, - kind: CanonicalFuncKind::ThreadHwConcurrency(info), + kind: CanonicalFuncKind::ThreadAvailableParallelism(info), }) } CoreFuncKind::TaskBackpressure => ComponentField::CanonicalFunc(CanonicalFunc { diff --git a/crates/wast/src/component/func.rs b/crates/wast/src/component/func.rs index 8d68065e0d..ee3e4dec3f 100644 --- a/crates/wast/src/component/func.rs +++ b/crates/wast/src/component/func.rs @@ -52,7 +52,7 @@ pub enum CoreFuncKind<'a> { ResourceDrop(CanonResourceDrop<'a>), ResourceRep(CanonResourceRep<'a>), ThreadSpawn(CanonThreadSpawn<'a>), - ThreadHwConcurrency(CanonThreadHwConcurrency), + ThreadAvailableParallelism(CanonThreadAvailableParallelism), TaskBackpressure, TaskReturn(CanonTaskReturn<'a>), TaskWait(CanonTaskWait<'a>), @@ -100,8 +100,8 @@ impl<'a> Parse<'a> for CoreFuncKind<'a> { Ok(CoreFuncKind::ResourceRep(parser.parse()?)) } else if l.peek::()? { Ok(CoreFuncKind::ThreadSpawn(parser.parse()?)) - } else if l.peek::()? { - Ok(CoreFuncKind::ThreadHwConcurrency(parser.parse()?)) + } else if l.peek::()? { + Ok(CoreFuncKind::ThreadAvailableParallelism(parser.parse()?)) } else if l.peek::()? { parser.parse::()?; Ok(CoreFuncKind::TaskBackpressure) @@ -341,7 +341,7 @@ pub enum CanonicalFuncKind<'a> { ResourceRep(CanonResourceRep<'a>), ThreadSpawn(CanonThreadSpawn<'a>), - ThreadHwConcurrency(CanonThreadHwConcurrency), + ThreadAvailableParallelism(CanonThreadAvailableParallelism), TaskBackpressure, TaskReturn(CanonTaskReturn<'a>), @@ -509,11 +509,11 @@ impl<'a> Parse<'a> for CanonThreadSpawn<'a> { /// Information relating to the `thread.spawn` intrinsic. #[derive(Debug)] -pub struct CanonThreadHwConcurrency; +pub struct CanonThreadAvailableParallelism; -impl<'a> Parse<'a> for CanonThreadHwConcurrency { +impl<'a> Parse<'a> for CanonThreadAvailableParallelism { fn parse(parser: Parser<'a>) -> Result { - parser.parse::()?; + parser.parse::()?; Ok(Self) } } diff --git a/crates/wast/src/component/resolve.rs b/crates/wast/src/component/resolve.rs index ddec257c52..5a61068c80 100644 --- a/crates/wast/src/component/resolve.rs +++ b/crates/wast/src/component/resolve.rs @@ -386,7 +386,7 @@ impl<'a> Resolver<'a> { CanonicalFuncKind::ThreadSpawn(info) => { self.resolve_ns(&mut info.ty, Ns::CoreType)?; } - CanonicalFuncKind::ThreadHwConcurrency(_) + CanonicalFuncKind::ThreadAvailableParallelism(_) | CanonicalFuncKind::TaskBackpressure | CanonicalFuncKind::TaskYield(_) | CanonicalFuncKind::SubtaskDrop @@ -964,7 +964,7 @@ impl<'a> ComponentState<'a> { | CanonicalFuncKind::ResourceRep(_) | CanonicalFuncKind::ResourceDrop(_) | CanonicalFuncKind::ThreadSpawn(_) - | CanonicalFuncKind::ThreadHwConcurrency(_) + | CanonicalFuncKind::ThreadAvailableParallelism(_) | CanonicalFuncKind::TaskBackpressure | CanonicalFuncKind::TaskReturn(_) | CanonicalFuncKind::TaskWait(_) diff --git a/crates/wast/src/lib.rs b/crates/wast/src/lib.rs index 109316f612..632dee3dc0 100644 --- a/crates/wast/src/lib.rs +++ b/crates/wast/src/lib.rs @@ -555,7 +555,7 @@ pub mod kw { custom_keyword!(import_info = "import-info"); custom_keyword!(thread); custom_keyword!(thread_spawn = "thread.spawn"); - custom_keyword!(thread_hw_concurrency = "thread.hw_concurrency"); + custom_keyword!(thread_available_parallelism = "thread.available_parallelism"); custom_keyword!(task_backpressure = "task.backpressure"); custom_keyword!(task_return = "task.return"); custom_keyword!(task_wait = "task.wait"); diff --git a/src/bin/wasm-tools/dump.rs b/src/bin/wasm-tools/dump.rs index b86ffdd0be..8ea31b6c15 100644 --- a/src/bin/wasm-tools/dump.rs +++ b/src/bin/wasm-tools/dump.rs @@ -419,7 +419,7 @@ impl<'a> Dump<'a> { | CanonicalFunction::ResourceDrop { .. } | CanonicalFunction::ResourceRep { .. } | CanonicalFunction::ThreadSpawn { .. } - | CanonicalFunction::ThreadHwConcurrency => { + | CanonicalFunction::ThreadAvailableParallelism => { ("core func", &mut i.core_funcs) } CanonicalFunction::TaskBackpressure diff --git a/tests/local/missing-features/component-model/shared-everything-threads-builtins.wast b/tests/local/missing-features/component-model/shared-everything-threads-builtins.wast index 2468bc28b8..9e5483f2f5 100644 --- a/tests/local/missing-features/component-model/shared-everything-threads-builtins.wast +++ b/tests/local/missing-features/component-model/shared-everything-threads-builtins.wast @@ -8,6 +8,6 @@ (assert_invalid (component - (core func $concurrency (canon thread.hw_concurrency)) + (core func $parallelism (canon thread.available_parallelism)) ) - "`thread.hw_concurrency` requires the shared-everything-threads proposal") + "`thread.available_parallelism` requires the shared-everything-threads proposal") diff --git a/tests/local/shared-everything-threads/builtins.wast b/tests/local/shared-everything-threads/builtins.wast index 7f5e1e1cbd..66c4907945 100644 --- a/tests/local/shared-everything-threads/builtins.wast +++ b/tests/local/shared-everything-threads/builtins.wast @@ -3,24 +3,24 @@ (component (core type $start (shared (func (param $context i32)))) (core func $spawn (canon thread.spawn $start)) - (core func $concurrency (canon thread.hw_concurrency)) + (core func $parallelism (canon thread.available_parallelism)) ) (component (core type $start (shared (func (param $context i32)))) (core func $spawn (canon thread.spawn $start)) - (core func $concurrency (canon thread.hw_concurrency)) + (core func $parallelism (canon thread.available_parallelism)) (core module $m (type $st (shared (func (param $context i32)))) (import "" "spawn" (func (param (ref null $st)) (param i32) (result i32))) - (import "" "concurrency" (func (result i32))) + (import "" "parallelism" (func (result i32))) ) (core instance (instantiate $m (with "" (instance (export "spawn" (func $spawn)) - (export "concurrency" (func $concurrency)) + (export "parallelism" (func $parallelism)) )) )) ) diff --git a/tests/snapshots/local/missing-features/component-model/shared-everything-threads-builtins.wast.json b/tests/snapshots/local/missing-features/component-model/shared-everything-threads-builtins.wast.json index 81b0f5ec7f..ff57d4bccb 100644 --- a/tests/snapshots/local/missing-features/component-model/shared-everything-threads-builtins.wast.json +++ b/tests/snapshots/local/missing-features/component-model/shared-everything-threads-builtins.wast.json @@ -13,7 +13,7 @@ "line": 10, "filename": "shared-everything-threads-builtins.1.wasm", "module_type": "binary", - "text": "`thread.hw_concurrency` requires the shared-everything-threads proposal" + "text": "`thread.available_parallelism` requires the shared-everything-threads proposal" } ] } \ No newline at end of file diff --git a/tests/snapshots/local/shared-everything-threads/builtins.wast/0.print b/tests/snapshots/local/shared-everything-threads/builtins.wast/0.print index 77e3cfd1c3..ce876bb64e 100644 --- a/tests/snapshots/local/shared-everything-threads/builtins.wast/0.print +++ b/tests/snapshots/local/shared-everything-threads/builtins.wast/0.print @@ -1,5 +1,5 @@ (component (core type $start (;0;) (shared (func (param i32)))) (core func $spawn (;0;) (canon thread.spawn $start)) - (core func $concurrency (;1;) (canon thread.hw_concurrency)) + (core func $parallelism (;1;) (canon thread.available_parallelism)) ) diff --git a/tests/snapshots/local/shared-everything-threads/builtins.wast/1.print b/tests/snapshots/local/shared-everything-threads/builtins.wast/1.print index 79906b58ac..fdd383db84 100644 --- a/tests/snapshots/local/shared-everything-threads/builtins.wast/1.print +++ b/tests/snapshots/local/shared-everything-threads/builtins.wast/1.print @@ -1,17 +1,17 @@ (component (core type $start (;0;) (shared (func (param i32)))) (core func $spawn (;0;) (canon thread.spawn $start)) - (core func $concurrency (;1;) (canon thread.hw_concurrency)) + (core func $parallelism (;1;) (canon thread.available_parallelism)) (core module $m (;0;) (type $st (;0;) (shared (func (param i32)))) (type (;1;) (func (param (ref null $st) i32) (result i32))) (type (;2;) (func (result i32))) (import "" "spawn" (func (;0;) (type 1))) - (import "" "concurrency" (func (;1;) (type 2))) + (import "" "parallelism" (func (;1;) (type 2))) ) (core instance (;0;) (export "spawn" (func $spawn)) - (export "concurrency" (func $concurrency)) + (export "parallelism" (func $parallelism)) ) (core instance (;1;) (instantiate $m (with "" (instance 0))