Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/wasm-encoder/src/component/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ impl ComponentBuilder {
self.core_funcs.add(Some("thread.index"))
}

/// Declares a new `thread.new_indirect` intrinsic.
/// Declares a new `thread.new-indirect` intrinsic.
pub fn thread_new_indirect(&mut self, func_ty_idx: u32, table_index: u32) -> u32 {
self.canonical_functions()
.thread_new_indirect(func_ty_idx, table_index);
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-encoder/src/component/canonicals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ impl CanonicalFunctionSection {
self
}

/// Declare a new `thread.new_indirect` intrinsic, used to create a new
/// Declare a new `thread.new-indirect` intrinsic, used to create a new
/// thread by invoking a function indirectly through a `funcref` table.
pub fn thread_new_indirect(&mut self, ty_index: u32, table_index: u32) -> &mut Self {
self.bytes.push(0x27);
Expand Down
10 changes: 5 additions & 5 deletions crates/wasmparser/src/validator/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ impl ComponentState {
if !self.features.cm_threading() {
bail!(
offset,
"`thread.new_indirect` requires the component model threading feature"
"`thread.new-indirect` requires the component model threading feature"
)
}

Expand Down Expand Up @@ -2310,7 +2310,7 @@ impl ComponentState {
if !self.features.shared_everything_threads() {
bail!(
offset,
"`thread.spawn_ref` requires the shared-everything-threads proposal"
"`thread.spawn-ref` requires the shared-everything-threads proposal"
)
}
let core_type_id = self.validate_spawn_type(func_ty_index, types, offset)?;
Expand Down Expand Up @@ -2338,7 +2338,7 @@ impl ComponentState {
if !self.features.shared_everything_threads() {
bail!(
offset,
"`thread.spawn_indirect` requires the shared-everything-threads proposal"
"`thread.spawn-indirect` requires the shared-everything-threads proposal"
)
}
let _ = self.validate_spawn_type(func_ty_index, types, offset)?;
Expand All @@ -2347,7 +2347,7 @@ impl ComponentState {
// `OperatorValidatorTemp::check_call_indirect_ty`), but loosen the
// table type restrictions to just a `funcref`. See the component model
// for more details:
// https://github.com/WebAssembly/component-model/blob/6e08e283/design/mvp/CanonicalABI.md#-canon-threadspawn_indirect.
// https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#-canon-threadspawn-indirect.
let table = self.table_at(table_index, offset)?;

SubtypeCx::table_type(
Expand Down Expand Up @@ -2382,7 +2382,7 @@ impl ComponentState {
/// This is currently limited to shared functions with the signature `[i32]
/// -> []`. See component model [explanation] for more details.
///
/// [explanation]: https://github.com/WebAssembly/component-model/blob/6e08e283/design/mvp/CanonicalABI.md#-canon-threadspawn_ref
/// [explanation]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#-canon-threadspawn-ref
fn validate_spawn_type(
&self,
func_ty_index: u32,
Expand Down
6 changes: 3 additions & 3 deletions crates/wasmprinter/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,15 +923,15 @@ impl Printer<'_, '_> {
})?;
}
CanonicalFunction::ThreadSpawnRef { func_ty_index } => {
self.print_intrinsic(state, "canon thread.spawn_ref ", &|me, state| {
self.print_intrinsic(state, "canon thread.spawn-ref ", &|me, state| {
me.print_idx(&state.core.type_names, func_ty_index)
})?;
}
CanonicalFunction::ThreadSpawnIndirect {
func_ty_index,
table_index,
} => {
self.print_intrinsic(state, "canon thread.spawn_indirect ", &|me, state| {
self.print_intrinsic(state, "canon thread.spawn-indirect ", &|me, state| {
me.print_idx(&state.core.type_names, func_ty_index)?;
me.result.write_str(" ")?;
me.start_group("table ")?;
Expand Down Expand Up @@ -1146,7 +1146,7 @@ impl Printer<'_, '_> {
func_ty_index,
table_index,
} => {
self.print_intrinsic(state, "canon thread.new_indirect ", &|me, state| {
self.print_intrinsic(state, "canon thread.new-indirect ", &|me, state| {
me.print_idx(&state.core.type_names, func_ty_index)?;
me.result.write_str(" ")?;
me.start_group("table ")?;
Expand Down
6 changes: 3 additions & 3 deletions crates/wast/src/component/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl<'a> Parse<'a> for CanonResourceRep<'a> {
}
}

/// Information relating to the `thread.spawn_ref` intrinsic.
/// Information relating to the `thread.spawn-ref` intrinsic.
#[derive(Debug)]
pub struct CanonThreadSpawnRef<'a> {
/// The function type that is being spawned.
Expand All @@ -526,7 +526,7 @@ impl<'a> Parse<'a> for CanonThreadSpawnRef<'a> {
}
}

/// Information relating to the `thread.spawn_indirect` intrinsic.
/// Information relating to the `thread.spawn-indirect` intrinsic.
///
/// This should look quite similar to parsing of `CallIndirect`.
#[derive(Debug)]
Expand Down Expand Up @@ -958,7 +958,7 @@ impl<'a> Parse<'a> for CanonErrorContextDebugMessage<'a> {
}
}

/// Information relating to the `thread.new_indirect` intrinsic.
/// Information relating to the `thread.new-indirect` intrinsic.
#[derive(Debug)]
pub struct CanonThreadNewIndirect<'a> {
/// The function type for the thread start function.
Expand Down
6 changes: 3 additions & 3 deletions crates/wast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ pub mod kw {
custom_keyword!(import_info = "import-info");
custom_keyword!(runtime_path = "runtime-path");
custom_keyword!(thread);
custom_keyword!(thread_spawn_ref = "thread.spawn_ref");
custom_keyword!(thread_spawn_indirect = "thread.spawn_indirect");
custom_keyword!(thread_spawn_ref = "thread.spawn-ref");
custom_keyword!(thread_spawn_indirect = "thread.spawn-indirect");
custom_keyword!(thread_available_parallelism = "thread.available_parallelism");
custom_keyword!(backpressure_set = "backpressure.set");
custom_keyword!(backpressure_inc = "backpressure.inc");
Expand Down Expand Up @@ -600,7 +600,7 @@ pub mod kw {
custom_keyword!(context_get = "context.get");
custom_keyword!(context_set = "context.set");
custom_keyword!(thread_index = "thread.index");
custom_keyword!(thread_new_indirect = "thread.new_indirect");
custom_keyword!(thread_new_indirect = "thread.new-indirect");
custom_keyword!(thread_switch_to = "thread.switch-to");
custom_keyword!(thread_suspend = "thread.suspend");
custom_keyword!(thread_resume_later = "thread.resume-later");
Expand Down
8 changes: 4 additions & 4 deletions crates/wit-component/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ impl<'a> EncodingState<'a> {
let (func_ty_idx, f) = self.component.core_type(Some("thread-start"));
f.core().func_type(func_ty);

// In order for the funcref table referenced by `thread.new_indirect` to be used,
// In order for the funcref table referenced by `thread.new-indirect` to be used,
// it must have been exported by the module.
let exports = self.info.exports_for(*for_module);
let instance_index = self.instance_for(*for_module);
Expand All @@ -1459,7 +1459,7 @@ impl<'a> EncodingState<'a> {
)
}).ok_or_else(|| {
anyhow!(
"table __indirect_function_table must be an exported funcref table for thread.new_indirect"
"table __indirect_function_table must be an exported funcref table for thread.new-indirect"
)
})?;

Expand Down Expand Up @@ -2324,7 +2324,7 @@ enum ShimKind<'a> {
/// The string encoding to use when lowering the debug message.
encoding: StringEncoding,
},
/// A shim used for the `thread.new_indirect` built-in function, which
/// A shim used for the `thread.new-indirect` built-in function, which
/// must refer to the core module instance's indirect function table.
ThreadNewIndirect {
/// Which instance to pull the function table from.
Expand Down Expand Up @@ -2578,7 +2578,7 @@ impl<'a> Shims<'a> {
let name = self.shims.len().to_string();
self.push(Shim {
name,
debug_name: "thread.new_indirect".to_string(),
debug_name: "thread.new-indirect".to_string(),
options: RequiredOptions::empty(),
kind: ShimKind::ThreadNewIndirect {
for_module,
Expand Down
4 changes: 2 additions & 2 deletions crates/wit-component/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pub enum Import {
/// This allows the guest to get the index of the current thread.
ThreadIndex,

/// A `canon thread.new_indirect` intrinsic.
/// A `canon thread.new-indirect` intrinsic.
///
/// This allows the guest to create a new thread running a specified function.
ThreadNewIndirect,
Expand Down Expand Up @@ -1113,7 +1113,7 @@ pub enum Export {

InterfaceFuncCallback(WorldKey, String),

/// __indirect_function_table, used for `thread.new_indirect`
/// __indirect_function_table, used for `thread.new-indirect`
IndirectFunctionTable,
}

Expand Down
12 changes: 6 additions & 6 deletions crates/wit-component/tests/components/threading/component.wat
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
(table (;0;) 3 3 funcref)
(export "0" (func $task-return-foo))
(export "1" (func $"#func1 task-return-foo"))
(export "2" (func $thread.new_indirect))
(export "2" (func $thread.new-indirect))
(export "$imports" (table 0))
(func $task-return-foo (;0;) (type 0) (param i32 i32)
local.get 0
Expand All @@ -64,7 +64,7 @@
i32.const 1
call_indirect (type 0)
)
(func $thread.new_indirect (;2;) (type 1) (param i32 i32) (result i32)
(func $thread.new-indirect (;2;) (type 1) (param i32 i32) (result i32)
local.get 0
local.get 1
i32.const 2
Expand Down Expand Up @@ -100,7 +100,7 @@
(core func $"context.get 1" (;3;) (canon context.get i32 1))
(core func $"context.set 1" (;4;) (canon context.set i32 1))
(core func $thread.index (;5;) (canon thread.index))
(alias core export $wit-component-shim-instance "2" (core func $thread.new_indirect (;6;)))
(alias core export $wit-component-shim-instance "2" (core func $thread.new-indirect (;6;)))
(core func $thread.switch-to (;7;) (canon thread.switch-to))
(core func $thread.suspend (;8;) (canon thread.suspend))
(core func $thread.resume-later (;9;) (canon thread.resume-later))
Expand All @@ -109,7 +109,7 @@
(export "[context-get-1]" (func $"context.get 1"))
(export "[context-set-1]" (func $"context.set 1"))
(export "[thread-index]" (func $thread.index))
(export "[thread-new-indirect-v0]" (func $thread.new_indirect))
(export "[thread-new-indirect-v0]" (func $thread.new-indirect))
(export "[thread-switch-to]" (func $thread.switch-to))
(export "[thread-suspend]" (func $thread.suspend))
(export "[thread-resume-later]" (func $thread.resume-later))
Expand All @@ -128,12 +128,12 @@
(core func $"#core-func13 task.return" (@name "task.return") (;13;) (canon task.return (result string) (memory $memory) string-encoding=utf8))
(core type $thread-start (;0;) (func (param i32)))
(alias core export $main "__indirect_function_table" (core table $indirect-function-table (;1;)))
(core func $thread.new-indirect (;14;) (canon thread.new_indirect $thread-start (table $indirect-function-table)))
(core func $"#core-func14 thread.new-indirect" (@name "thread.new-indirect") (;14;) (canon thread.new-indirect $thread-start (table $indirect-function-table)))
(core instance $fixup-args (;5;)
(export "$imports" (table $"shim table"))
(export "0" (func $task.return))
(export "1" (func $"#core-func13 task.return"))
(export "2" (func $thread.new-indirect))
(export "2" (func $"#core-func14 thread.new-indirect"))
)
(core instance $fixup (;6;) (instantiate $wit-component-fixup
(with "" (instance $fixup-args))
Expand Down
22 changes: 11 additions & 11 deletions tests/cli/component-model/async/threading.wast
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@
)
"found: (func (param i32))")

;; thread.new_indirect
;; thread.new-indirect
(component
(core type $start (func (param $context i32)))
(core module $libc (table (export "start-table") 1 (ref null func)))
(core instance $libc (instantiate $libc))
(core func $new_indirect (canon thread.new_indirect $start (table $libc "start-table")))
(core func $new-indirect (canon thread.new-indirect $start (table $libc "start-table")))
)

(component
(core type $start (func (param $context i32)))
(core module $libc (table (export "start-table") 1 (ref null func)))
(core instance $libc (instantiate $libc))
(core func $new_indirect (canon thread.new_indirect $start (table $libc "start-table")))
(core func $new-indirect (canon thread.new-indirect $start (table $libc "start-table")))

(core module $m
(type $new_indirect_ty (func (param i32) (param i32) (result i32)))
(import "" "thread.new_indirect" (func (type $new_indirect_ty)))
(type $new-indirect-ty (func (param i32) (param i32) (result i32)))
(import "" "thread.new-indirect" (func (type $new-indirect-ty)))
)

(core instance (instantiate $m
(with "" (instance
(export "thread.new_indirect" (func $new_indirect))
(export "thread.new-indirect" (func $new-indirect))
))
))
)
Expand All @@ -79,8 +79,8 @@
(component
(core type $start (func (param i32)))
;; Refer to a non-existent table type (i.e., 0); validation
;; for `thread.new_indirect` happens first.
(core func $new_indirect (canon thread.new_indirect $start (table 0)))
;; for `thread.new-indirect` happens first.
(core func $new-indirect (canon thread.new-indirect $start (table 0)))
)
"unknown table 0: table index out of bounds"
)
Expand All @@ -90,7 +90,7 @@
(core type $start (func))
(core module $libc (table (export "start-table") 1 (ref null func)))
(core instance $libc (instantiate $libc))
(core func $new_indirect (canon thread.new_indirect $start (table $libc "start-table")))
(core func $new-indirect (canon thread.new-indirect $start (table $libc "start-table")))
)
"start function must take a single `i32` argument"
)
Expand Down Expand Up @@ -152,8 +152,8 @@
(canon context.set i32 1 (core func))

(core type $start (func (param i32)))
(core func (canon thread.new_indirect $start (table $start-table)))
(canon thread.new_indirect $start (table $start-table) (core func))
(core func (canon thread.new-indirect $start (table $start-table)))
(canon thread.new-indirect $start (table $start-table) (core func))
(core func (canon thread.switch-to))
(canon thread.switch-to (core func))
(core func (canon thread.switch-to cancellable))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
(assert_invalid
(component
;; Refer to a non-existent function type (i.e., 0); validation for
;; `thread.spawn_ref` happens first.
(core func $spawn (canon thread.spawn_ref 0))
;; `thread.spawn-ref` happens first.
(core func $spawn (canon thread.spawn-ref 0))
)
"`thread.spawn_ref` requires the shared-everything-threads proposal")
"`thread.spawn-ref` requires the shared-everything-threads proposal")

(assert_invalid
(component
;; Refer to a non-existent function and table types (i.e., 0); validation
;; for `thread.spawn_indirect` happens first.
(core func $spawn_indirect (canon thread.spawn_indirect 0 (table 0)))
;; for `thread.spawn-indirect` happens first.
(core func $spawn-indirect (canon thread.spawn-indirect 0 (table 0)))
)
"`thread.spawn_indirect` requires the shared-everything-threads proposal")
"`thread.spawn-indirect` requires the shared-everything-threads proposal")

(assert_invalid
(component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(assert_invalid
(component
(core func (canon thread.index))
(core func (canon thread.new_indirect 0 (table 0)))
(core func (canon thread.new-indirect 0 (table 0)))
(core func (canon thread.switch-to))
(core func (canon thread.suspend))
(core func (canon thread.resume-later))
Expand Down
Loading