Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Update to wasm-tools 245 (#12571)

Alex Crichtond2fbd2dec87a
diff --git a/Cargo.lock b/Cargo.lock
index 689dc7e107..729375b27e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -638,7 +638,7 @@ dependencies = [
"test-programs-artifacts",
"tokio",
"wasm-compose",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime",
"wasmtime-wasi",
]
@@ -1630,7 +1630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
dependencies = [
"fallible-iterator",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"stable_deref_trait",
]
@@ -1642,7 +1642,7 @@ checksum = "0bf7f043f89559805f8c7cacc432749b2fa0d0a0a9ee46ce47164ed5ba7f126c"
dependencies = [
"fnv",
"hashbrown 0.16.1",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"stable_deref_trait",
]
@@ -1673,7 +1673,7 @@ dependencies = [
"futures-sink",
"futures-util",
"http",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"slab",
"tokio",
"tokio-util",
@@ -1709,7 +1709,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"foldhash 0.1.3",
- "serde",
]
[[package]]
@@ -1719,6 +1718,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"foldhash 0.2.0",
+ "serde",
+ "serde_core",
]
[[package]]
@@ -1975,9 +1976,9 @@ dependencies = [
[[package]]
name = "id-arena"
-version = "2.2.1"
+version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
+checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]]
name = "idna"
@@ -2026,9 +2027,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.11.4"
+version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
+checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
dependencies = [
"equivalent",
"hashbrown 0.16.1",
@@ -2177,14 +2178,14 @@ dependencies = [
[[package]]
name = "json-from-wast"
-version = "0.244.0"
+version = "0.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b06196ab44f5dd4ebb2f6ede775d5c4db4500e7978218ccd47cb9cf4d440da5b"
+checksum = "0e70808c1eac9590387b9acbd107f5412293c0b56f7e9173c9de8538ae4a876f"
dependencies = [
"anyhow",
"serde",
"serde_derive",
- "wast 244.0.0",
+ "wast 245.0.0",
]
[[package]]
@@ -2529,7 +2530,7 @@ checksum = "271638cd5fa9cca89c4c304675ca658efc4e64a66c716b7cfe1afb4b9611dbbc"
dependencies = [
"crc32fast",
"hashbrown 0.16.1",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"memchr",
]
@@ -2730,7 +2731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
dependencies = [
"fixedbitset",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
]
[[package]]
@@ -3333,7 +3334,7 @@ version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"itoa",
"ryu",
"serde",
@@ -3704,7 +3705,7 @@ dependencies = [
"wasmtime",
"wasmtime-test-util",
"wat",
- "wit-component",
+ "wit-component 0.245.0",
]
[[package]]
@@ -3873,7 +3874,7 @@ version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8"
dependencies = [
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"serde_core",
"serde_spanned",
"toml_datetime",
@@ -4169,7 +4170,7 @@ name = "verify-component-adapter"
version = "43.0.0"
dependencies = [
"anyhow",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wat",
]
@@ -4271,7 +4272,7 @@ dependencies = [
"byte-array-literals",
"object 0.38.1",
"wasip1",
- "wasm-encoder",
+ "wasm-encoder 0.245.0",
"wit-bindgen-rust-macro",
]
@@ -4347,22 +4348,22 @@ checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49"
[[package]]
name = "wasm-compose"
-version = "0.244.0"
+version = "0.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92cda9c76ca8dcac01a8b497860c2cb15cd6f216dc07060517df5abbe82512ac"
+checksum = "b5e87956946cd902ed92479d41ea3210538cb77d8bd104f0cd05b80627fcb3c6"
dependencies = [
"anyhow",
"heck 0.5.0",
"im-rc",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"log",
"petgraph",
"serde",
"serde_derive",
"serde_yaml",
"smallvec 1.15.1",
- "wasm-encoder",
- "wasmparser 0.244.0",
+ "wasm-encoder 0.245.0",
+ "wasmparser 0.245.0",
"wat",
]
@@ -4376,6 +4377,16 @@ dependencies = [
"wasmparser 0.244.0",
]
+[[package]]
+name = "wasm-encoder"
+version = "0.245.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95d568e113f706ee7a7df9b33547bb80721f55abffc79b3dc4d09c368690e662"
+dependencies = [
+ "leb128fmt",
+ "wasmparser 0.245.0",
+]
+
[[package]]
name = "wasm-metadata"
version = "0.244.0"
@@ -4383,37 +4394,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
dependencies = [
"anyhow",
- "indexmap 2.11.4",
- "wasm-encoder",
+ "indexmap 2.13.0",
+ "wasm-encoder 0.244.0",
"wasmparser 0.244.0",
]
+[[package]]
+name = "wasm-metadata"
+version = "0.245.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce52b194ec202d029751081d735c1ae49c1bacbdc2634c821a86211e3751300c"
+dependencies = [
+ "anyhow",
+ "indexmap 2.13.0",
+ "wasm-encoder 0.245.0",
+ "wasmparser 0.245.0",
+]
+
[[package]]
name = "wasm-mutate"
-version = "0.244.0"
+version = "0.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a518c14c99f3230d5b2abd06519f3867d64c64744b13fde29ac68d42d1ec20c"
+checksum = "0ce4cdc599ae42969c70593976632214edb70805ed1007b52cf90fc52294f4e7"
dependencies = [
"egg",
"log",
"rand 0.9.2",
"thiserror 2.0.17",
- "wasm-encoder",
- "wasmparser 0.244.0",
+ "wasm-encoder 0.245.0",
+ "wasmparser 0.245.0",
]
[[package]]
name = "wasm-smith"
-version = "0.244.0"
+version = "0.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c8f72462e1ee97c48da6f599c7e47064dbab12bfee7b4fad278de4973ba72fd8"
+checksum = "4b379db01f578cea54de8cce4a6906a4c70c814cc886179e885dc186311127a2"
dependencies = [
"anyhow",
"arbitrary",
"flagset",
"serde",
"serde_derive",
- "wasm-encoder",
+ "wasm-encoder 0.245.0",
"wat",
]
@@ -4427,13 +4450,13 @@ dependencies = [
[[package]]
name = "wasm-wave"
-version = "0.244.0"
+version = "0.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d1c34a4c10a1b9260f8131929d680e36edf00836bb8e76524d3004522bd6f287"
+checksum = "80a3011a773f51c3c66612c66807d882fbfc206304c705fe146f535898acd4fb"
dependencies = [
"logos",
"thiserror 2.0.17",
- "wit-parser",
+ "wit-parser 0.245.0",
]
[[package]]
@@ -4483,7 +4506,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4abf1132c1fdf747d56bbc1bb52152400c70f336870f968b85e89ea422198ae3"
dependencies = [
"bitflags 2.9.4",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
]
[[package]]
@@ -4494,20 +4517,32 @@ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
"bitflags 2.9.4",
"hashbrown 0.15.2",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
+ "semver",
+]
+
+[[package]]
+name = "wasmparser"
+version = "0.245.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48a767a48974f0c8b66f211b96e01aa77feed58b8ccce4e7f0cff0ae55b174d4"
+dependencies = [
+ "bitflags 2.9.4",
+ "hashbrown 0.16.1",
+ "indexmap 2.13.0",
"semver",
"serde",
]
[[package]]
name = "wasmprinter"
-version = "0.244.0"
+version = "0.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09390d7b2bd7b938e563e4bff10aa345ef2e27a3bc99135697514ef54495e68f"
+checksum = "6b79e39af628dc03572ecd42fab1265480d943db5858dab748142a5ce0644bb5"
dependencies = [
"anyhow",
"termcolor",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
]
[[package]]
@@ -4550,9 +4585,9 @@ dependencies = [
"tempfile",
"tokio",
"wasm-compose",
- "wasm-encoder",
+ "wasm-encoder 0.245.0",
"wasm-wave",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime-environ",
"wasmtime-internal-cache",
"wasmtime-internal-component-macro",
@@ -4661,8 +4696,8 @@ dependencies = [
"tracing",
"walkdir",
"wasi-common",
- "wasm-encoder",
- "wasmparser 0.244.0",
+ "wasm-encoder 0.245.0",
+ "wasmparser 0.245.0",
"wasmtime",
"wasmtime-cli-flags",
"wasmtime-environ",
@@ -4682,10 +4717,10 @@ dependencies = [
"wasmtime-wasi-tls",
"wasmtime-wast",
"wasmtime-wizer",
- "wast 244.0.0",
+ "wast 245.0.0",
"wat",
"windows-sys 0.61.2",
- "wit-component",
+ "wit-component 0.245.0",
]
[[package]]
@@ -4716,7 +4751,7 @@ dependencies = [
"env_logger 0.11.5",
"gimli 0.33.0",
"hashbrown 0.16.1",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"log",
"object 0.38.1",
"postcard",
@@ -4726,8 +4761,8 @@ dependencies = [
"serde_derive",
"smallvec 1.15.1",
"target-lexicon",
- "wasm-encoder",
- "wasmparser 0.244.0",
+ "wasm-encoder 0.245.0",
+ "wasmparser 0.245.0",
"wasmprinter",
"wasmtime-internal-component-util",
"wasmtime-internal-core",
@@ -4741,7 +4776,7 @@ dependencies = [
"arbitrary",
"env_logger 0.11.5",
"libfuzzer-sys",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmprinter",
"wasmtime-environ",
"wasmtime-test-util",
@@ -4774,7 +4809,7 @@ dependencies = [
"rand 0.9.2",
"smallvec 1.15.1",
"target-lexicon",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime",
"wasmtime-fuzzing",
"wasmtime-test-util",
@@ -4789,7 +4824,7 @@ dependencies = [
"cranelift-bitset",
"env_logger 0.11.5",
"futures",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"log",
"mutatis",
"rand 0.8.5",
@@ -4802,12 +4837,12 @@ dependencies = [
"test-programs-artifacts",
"v8",
"wasm-compose",
- "wasm-encoder",
+ "wasm-encoder 0.245.0",
"wasm-mutate",
"wasm-smith",
"wasm-spec-interpreter",
"wasmi",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmprinter",
"wasmtime",
"wasmtime-cli-flags",
@@ -4865,7 +4900,7 @@ dependencies = [
"wasmtime",
"wasmtime-internal-component-util",
"wasmtime-internal-wit-bindgen",
- "wit-parser",
+ "wit-parser 0.245.0",
]
[[package]]
@@ -4900,7 +4935,7 @@ dependencies = [
"smallvec 1.15.1",
"target-lexicon",
"thiserror 2.0.17",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime-environ",
"wasmtime-internal-core",
"wasmtime-internal-unwinder",
@@ -4994,7 +5029,7 @@ dependencies = [
"log",
"object 0.38.1",
"target-lexicon",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime-environ",
"wasmtime-internal-cranelift",
"winch-codegen",
@@ -5007,8 +5042,8 @@ dependencies = [
"anyhow",
"bitflags 2.9.4",
"heck 0.5.0",
- "indexmap 2.11.4",
- "wit-parser",
+ "indexmap 2.13.0",
+ "wit-parser 0.245.0",
]
[[package]]
@@ -5033,7 +5068,7 @@ dependencies = [
"arbitrary",
"arbtest",
"env_logger 0.11.5",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"proc-macro2",
"quote",
"rand 0.9.2",
@@ -5041,7 +5076,7 @@ dependencies = [
"serde_derive",
"target-lexicon",
"toml",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmprinter",
"wasmtime",
"wasmtime-environ",
@@ -5229,9 +5264,9 @@ dependencies = [
"object 0.38.1",
"serde_json",
"tokio",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime",
- "wast 244.0.0",
+ "wast 245.0.0",
]
[[package]]
@@ -5244,8 +5279,8 @@ dependencies = [
"log",
"rayon",
"tokio",
- "wasm-encoder",
- "wasmparser 0.244.0",
+ "wasm-encoder 0.245.0",
+ "wasmparser 0.245.0",
"wasmprinter",
"wasmtime",
"wasmtime-wasi",
@@ -5263,25 +5298,25 @@ dependencies = [
[[package]]
name = "wast"
-version = "244.0.0"
+version = "245.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2e7b9f9e23311275920e3d6b56d64137c160cf8af4f84a7283b36cfecbf4acb"
+checksum = "75ffc7471e16a6f3c7a3c3a230314915b5dcd158e5ef13ccda2f43358a9df00c"
dependencies = [
"bumpalo",
"gimli 0.31.1",
"leb128fmt",
"memchr",
"unicode-width 0.2.0",
- "wasm-encoder",
+ "wasm-encoder 0.245.0",
]
[[package]]
name = "wat"
-version = "1.244.0"
+version = "1.245.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbf35b87ed352f9ab6cd0732abde5a67dd6153dfd02c493e61459218b19456fa"
+checksum = "d6bcac6f915e2a84a4c0d9df9d41ad7518d99cda13f3bb83e3b8c22bf8726ab6"
dependencies = [
- "wast 244.0.0",
+ "wast 245.0.0",
]
[[package]]
@@ -5408,7 +5443,7 @@ dependencies = [
"smallvec 1.15.1",
"target-lexicon",
"thiserror 2.0.17",
- "wasmparser 0.244.0",
+ "wasmparser 0.245.0",
"wasmtime-environ",
"wasmtime-internal-core",
"wasmtime-internal-cranelift",
@@ -5669,7 +5704,7 @@ checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
dependencies = [
"anyhow",
"heck 0.5.0",
- "wit-parser",
+ "wit-parser 0.244.0",
]
[[package]]
@@ -5689,12 +5724,12 @@ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
dependencies = [
"anyhow",
"heck 0.5.0",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"prettyplease",
"syn 2.0.106",
- "wasm-metadata",
+ "wasm-metadata 0.244.0",
"wit-bindgen-core",
- "wit-component",
+ "wit-component 0.244.0",
]
[[package]]
@@ -5720,15 +5755,34 @@ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
"anyhow",
"bitflags 2.9.4",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"log",
"serde",
"serde_derive",
"serde_json",
- "wasm-encoder",
- "wasm-metadata",
+ "wasm-encoder 0.244.0",
+ "wasm-metadata 0.244.0",
"wasmparser 0.244.0",
- "wit-parser",
+ "wit-parser 0.244.0",
+]
+
+[[package]]
+name = "wit-component"
+version = "0.245.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "896efcb3d68ea1cb555d2d1df185b4071b39d91cf850456809bb0c90a0e4e66e"
+dependencies = [
+ "anyhow",
+ "bitflags 2.9.4",
+ "indexmap 2.13.0",
+ "log",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "wasm-encoder 0.245.0",
+ "wasm-metadata 0.245.0",
+ "wasmparser 0.245.0",
+ "wit-parser 0.245.0",
]
[[package]]
@@ -5739,7 +5793,7 @@ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
dependencies = [
"anyhow",
"id-arena",
- "indexmap 2.11.4",
+ "indexmap 2.13.0",
"log",
"semver",
"serde",
@@ -5749,6 +5803,25 @@ dependencies = [
"wasmparser 0.244.0",
]
+[[package]]
+name = "wit-parser"
+version = "0.245.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5cda4f69fdc5a8d54f7032262217dd89410a933e3f86fdad854f5833caf3ccb"
+dependencies = [
+ "anyhow",
+ "hashbrown 0.16.1",
+ "id-arena",
+ "indexmap 2.13.0",
+ "log",
+ "semver",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "unicode-xid",
+ "wasmparser 0.245.0",
+]
+
[[package]]
name = "witx"
version = "0.9.1"
diff --git a/Cargo.toml b/Cargo.toml
index 3973418b6a..b59924d9ca 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -343,18 +343,18 @@ wit-bindgen = { version = "0.51.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.51.0", default-features = false }
# wasm-tools family:
-wasmparser = { version = "0.244.0", default-features = false, features = ['simd'] }
-wat = "1.244.0"
-wast = "244.0.0"
-wasmprinter = "0.244.0"
-wasm-encoder = "0.244.0"
-wasm-smith = "0.244.0"
-wasm-mutate = "0.244.0"
-wit-parser = "0.244.0"
-wit-component = "0.244.0"
-wasm-wave = "0.244.0"
-wasm-compose = "0.244.0"
-json-from-wast = "0.244.0"
+wasmparser = { version = "0.245.0", default-features = false, features = ['simd'] }
+wat = "1.245.0"
+wast = "245.0.0"
+wasmprinter = "0.245.0"
+wasm-encoder = "0.245.0"
+wasm-smith = "0.245.0"
+wasm-mutate = "0.245.0"
+wit-parser = "0.245.0"
+wit-component = "0.245.0"
+wasm-wave = "0.245.0"
+wasm-compose = "0.245.0"
+json-from-wast = "0.245.0"
# Non-Bytecode Alliance maintained dependencies:
# --------------------------
diff --git a/crates/cranelift/src/compiler/component.rs b/crates/cranelift/src/compiler/component.rs
index 9b0d7a3798..066b5f4c2b 100644
--- a/crates/cranelift/src/compiler/component.rs
+++ b/crates/cranelift/src/compiler/component.rs
@@ -767,12 +767,30 @@ impl<'a> TrampolineCompiler<'a> {
},
);
}
- Trampoline::ThreadSwitchTo {
+ Trampoline::ThreadSuspendToSuspended {
instance,
cancellable,
} => {
self.translate_libcall(
- host::thread_switch_to,
+ host::thread_suspend_to_suspended,
+ TrapSentinel::NegativeOne,
+ WasmArgs::InRegisters,
+ |me, params| {
+ params.push(me.index_value(*instance));
+ params.push(
+ me.builder
+ .ins()
+ .iconst(ir::types::I8, i64::from(*cancellable)),
+ );
+ },
+ );
+ }
+ Trampoline::ThreadSuspendTo {
+ instance,
+ cancellable,
+ } => {
+ self.translate_libcall(
+ host::thread_suspend_to,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|me, params| {
@@ -803,9 +821,9 @@ impl<'a> TrampolineCompiler<'a> {
},
);
}
- Trampoline::ThreadResumeLater { instance } => {
+ Trampoline::ThreadUnsuspend { instance } => {
self.translate_libcall(
- host::thread_resume_later,
+ host::thread_unsuspend,
TrapSentinel::Falsy,
WasmArgs::InRegisters,
|me, params| {
@@ -813,12 +831,12 @@ impl<'a> TrampolineCompiler<'a> {
},
);
}
- Trampoline::ThreadYieldTo {
+ Trampoline::ThreadYieldToSuspended {
instance,
cancellable,
} => {
self.translate_libcall(
- host::thread_yield_to,
+ host::thread_yield_to_suspended,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|me, params| {
@@ -1472,11 +1490,12 @@ impl<'a> TrampolineCompiler<'a> {
| Trampoline::WaitableSetDrop { instance }
| Trampoline::WaitableJoin { instance }
| Trampoline::ThreadYield { instance, .. }
- | Trampoline::ThreadSwitchTo { instance, .. }
| Trampoline::ThreadNewIndirect { instance, .. }
| Trampoline::ThreadSuspend { instance, .. }
- | Trampoline::ThreadResumeLater { instance }
- | Trampoline::ThreadYieldTo { instance, .. }
+ | Trampoline::ThreadSuspendToSuspended { instance, .. }
+ | Trampoline::ThreadSuspendTo { instance, .. }
+ | Trampoline::ThreadUnsuspend { instance, .. }
+ | Trampoline::ThreadYieldToSuspended { instance, .. }
| Trampoline::SubtaskDrop { instance }
| Trampoline::SubtaskCancel { instance, .. }
| Trampoline::ErrorContextNew { instance, .. }
diff --git a/crates/environ/src/component.rs b/crates/environ/src/component.rs
index 2e3a826585..d60b7a2507 100644
--- a/crates/environ/src/component.rs
+++ b/crates/environ/src/component.rs
@@ -194,13 +194,15 @@ macro_rules! foreach_builtin_component_function {
#[cfg(feature = "component-model-async")]
thread_new_indirect(vmctx: vmctx, caller_instance: u32, func_ty_id: u32, func_table_idx: u32, func_idx: u32, context: u32) -> u64;
#[cfg(feature = "component-model-async")]
- thread_switch_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
+ thread_suspend_to_suspended(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
+ #[cfg(feature = "component-model-async")]
+ thread_suspend_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
#[cfg(feature = "component-model-async")]
thread_suspend(vmctx: vmctx, caller_instance: u32, cancellable: u8) -> u32;
#[cfg(feature = "component-model-async")]
- thread_resume_later(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> bool;
+ thread_unsuspend(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> bool;
#[cfg(feature = "component-model-async")]
- thread_yield_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
+ thread_yield_to_suspended(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
trap(vmctx: vmctx, code: u32) -> bool;
diff --git a/crates/environ/src/component/dfg.rs b/crates/environ/src/component/dfg.rs
index 4a76153a85..17915e028e 100644
--- a/crates/environ/src/component/dfg.rs
+++ b/crates/environ/src/component/dfg.rs
@@ -490,7 +490,7 @@ pub enum Trampoline {
start_func_ty_idx: ComponentTypeIndex,
start_func_table_id: TableId,
},
- ThreadSwitchTo {
+ ThreadSuspendToSuspended {
instance: RuntimeComponentInstanceIndex,
cancellable: bool,
},
@@ -498,10 +498,14 @@ pub enum Trampoline {
instance: RuntimeComponentInstanceIndex,
cancellable: bool,
},
- ThreadResumeLater {
+ ThreadSuspendTo {
+ instance: RuntimeComponentInstanceIndex,
+ cancellable: bool,
+ },
+ ThreadUnsuspend {
instance: RuntimeComponentInstanceIndex,
},
- ThreadYieldTo {
+ ThreadYieldToSuspended {
instance: RuntimeComponentInstanceIndex,
cancellable: bool,
},
@@ -1181,10 +1185,17 @@ impl LinearizeDfg<'_> {
start_func_ty_idx: *start_func_ty_idx,
start_func_table_idx: self.runtime_table(*start_func_table_id),
},
- Trampoline::ThreadSwitchTo {
+ Trampoline::ThreadSuspendToSuspended {
+ instance,
+ cancellable,
+ } => info::Trampoline::ThreadSuspendToSuspended {
+ instance: *instance,
+ cancellable: *cancellable,
+ },
+ Trampoline::ThreadSuspendTo {
instance,
cancellable,
- } => info::Trampoline::ThreadSwitchTo {
+ } => info::Trampoline::ThreadSuspendTo {
instance: *instance,
cancellable: *cancellable,
},
@@ -1195,13 +1206,13 @@ impl LinearizeDfg<'_> {
instance: *instance,
cancellable: *cancellable,
},
- Trampoline::ThreadResumeLater { instance } => info::Trampoline::ThreadResumeLater {
+ Trampoline::ThreadUnsuspend { instance } => info::Trampoline::ThreadUnsuspend {
instance: *instance,
},
- Trampoline::ThreadYieldTo {
+ Trampoline::ThreadYieldToSuspended {
instance,
cancellable,
- } => info::Trampoline::ThreadYieldTo {
+ } => info::Trampoline::ThreadYieldToSuspended {
instance: *instance,
cancellable: *cancellable,
},
diff --git a/crates/environ/src/component/info.rs b/crates/environ/src/component/info.rs
index 9f49acd1f5..40feaa1c88 100644
--- a/crates/environ/src/component/info.rs
+++ b/crates/environ/src/component/info.rs
@@ -1144,8 +1144,17 @@ pub enum Trampoline {
start_func_table_idx: RuntimeTableIndex,
},
- /// Intrinsic used to implement the `thread.switch-to` component model builtin.
- ThreadSwitchTo {
+ /// Intrinsic used to implement the `thread.suspend-to-suspended` component model builtin.
+ ThreadSuspendToSuspended {
+ /// The specific component instance which is calling the intrinsic.
+ instance: RuntimeComponentInstanceIndex,
+ /// If `true`, indicates the caller instance may receive notification
+ /// of task cancellation.
+ cancellable: bool,
+ },
+
+ /// Intrinsic used to implement the `thread.suspend-to` component model builtin.
+ ThreadSuspendTo {
/// The specific component instance which is calling the intrinsic.
instance: RuntimeComponentInstanceIndex,
/// If `true`, indicates the caller instance may receive notification
@@ -1162,14 +1171,14 @@ pub enum Trampoline {
cancellable: bool,
},
- /// Intrinsic used to implement the `thread.resume-later` component model builtin.
- ThreadResumeLater {
+ /// Intrinsic used to implement the `thread.unsuspend` component model builtin.
+ ThreadUnsuspend {
/// The specific component instance which is calling the intrinsic.
instance: RuntimeComponentInstanceIndex,
},
- /// Intrinsic used to implement the `thread.yield-to` component model builtin.
- ThreadYieldTo {
+ /// Intrinsic used to implement the `thread.yield-to-suspended` component model builtin.
+ ThreadYieldToSuspended {
/// The specific component instance which is calling the intrinsic.
instance: RuntimeComponentInstanceIndex,
/// If `true`, indicates the caller instance may receive notification
@@ -1242,10 +1251,11 @@ impl Trampoline {
ContextSet { .. } => format!("context-set"),
ThreadIndex => format!("thread-index"),
ThreadNewIndirect { .. } => format!("thread-new-indirect"),
- ThreadSwitchTo { .. } => format!("thread-switch-to"),
+ ThreadSuspendToSuspended { .. } => format!("thread-suspend-to-suspended"),
+ ThreadSuspendTo { .. } => format!("thread-suspend-to"),
ThreadSuspend { .. } => format!("thread-suspend"),
- ThreadResumeLater { .. } => format!("thread-resume-later"),
- ThreadYieldTo { .. } => format!("thread-yield-to"),
+ ThreadUnsuspend { .. } => format!("thread-unsuspend"),
+ ThreadYieldToSuspended { .. } => format!("thread-yield-to-suspended"),
}
}
}
diff --git a/crates/environ/src/component/translate.rs b/crates/environ/src/component/translate.rs
index 78bdb0307e..8855a848a6 100644
--- a/crates/environ/src/component/translate.rs
+++ b/crates/environ/src/component/translate.rs
@@ -319,7 +319,7 @@ enum LocalInitializer<'data> {
start_func_ty: ComponentTypeIndex,
start_func_table_index: TableIndex,
},
- ThreadSwitchTo {
+ ThreadSuspendToSuspended {
func: ModuleInternedTypeIndex,
cancellable: bool,
},
@@ -327,10 +327,14 @@ enum LocalInitializer<'data> {
func: ModuleInternedTypeIndex,
cancellable: bool,
},
- ThreadResumeLater {
+ ThreadSuspendTo {
+ func: ModuleInternedTypeIndex,
+ cancellable: bool,
+ },
+ ThreadUnsuspend {
func: ModuleInternedTypeIndex,
},
- ThreadYieldTo {
+ ThreadYieldToSuspended {
func: ModuleInternedTypeIndex,
cancellable: bool,
},
@@ -1150,25 +1154,30 @@ impl<'a, 'data> Translator<'a, 'data> {
start_func_table_index: TableIndex::from_u32(table_index),
}
}
- wasmparser::CanonicalFunction::ThreadSwitchTo { cancellable } => {
+ wasmparser::CanonicalFunction::ThreadSuspendToSuspended { cancellable } => {
let func = self.core_func_signature(core_func_index)?;
core_func_index += 1;
- LocalInitializer::ThreadSwitchTo { func, cancellable }
+ LocalInitializer::ThreadSuspendToSuspended { func, cancellable }
}
wasmparser::CanonicalFunction::ThreadSuspend { cancellable } => {
let func = self.core_func_signature(core_func_index)?;
core_func_index += 1;
LocalInitializer::ThreadSuspend { func, cancellable }
}
- wasmparser::CanonicalFunction::ThreadResumeLater => {
+ wasmparser::CanonicalFunction::ThreadSuspendTo { cancellable } => {
+ let func = self.core_func_signature(core_func_index)?;
+ core_func_index += 1;
+ LocalInitializer::ThreadSuspendTo { func, cancellable }
+ }
+ wasmparser::CanonicalFunction::ThreadUnsuspend => {
let func = self.core_func_signature(core_func_index)?;
core_func_index += 1;
- LocalInitializer::ThreadResumeLater { func }
+ LocalInitializer::ThreadUnsuspend { func }
}
- wasmparser::CanonicalFunction::ThreadYieldTo { cancellable } => {
+ wasmparser::CanonicalFunction::ThreadYieldToSuspended { cancellable } => {
let func = self.core_func_signature(core_func_index)?;
core_func_index += 1;
- LocalInitializer::ThreadYieldTo { func, cancellable }
+ LocalInitializer::ThreadYieldToSuspended { func, cancellable }
}
};
self.result.initializers.push(init);
diff --git a/crates/environ/src/component/translate/inline.rs b/crates/environ/src/component/translate/inline.rs
index 8492b9e04a..94ba5b1723 100644
--- a/crates/environ/src/component/translate/inline.rs
+++ b/crates/environ/src/component/translate/inline.rs
@@ -1123,10 +1123,20 @@ impl<'a> Inliner<'a> {
));
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
}
- ThreadSwitchTo { func, cancellable } => {
+ ThreadSuspendToSuspended { func, cancellable } => {
let index = self.result.trampolines.push((
*func,
- dfg::Trampoline::ThreadSwitchTo {
+ dfg::Trampoline::ThreadSuspendToSuspended {
+ instance: frame.instance,
+ cancellable: *cancellable,
+ },
+ ));
+ frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
+ }
+ ThreadSuspendTo { func, cancellable } => {
+ let index = self.result.trampolines.push((
+ *func,
+ dfg::Trampoline::ThreadSuspendTo {
instance: frame.instance,
cancellable: *cancellable,
},
@@ -1143,19 +1153,19 @@ impl<'a> Inliner<'a> {
));
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
}
- ThreadResumeLater { func } => {
+ ThreadUnsuspend { func } => {
let index = self.result.trampolines.push((
*func,
- dfg::Trampoline::ThreadResumeLater {
+ dfg::Trampoline::ThreadUnsuspend {
instance: frame.instance,
},
));
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
}
- ThreadYieldTo { func, cancellable } => {
+ ThreadYieldToSuspended { func, cancellable } => {
let index = self.result.trampolines.push((
*func,
- dfg::Trampoline::ThreadYieldTo {
+ dfg::Trampoline::ThreadYieldToSuspended {
instance: frame.instance,
cancellable: *cancellable,
},
diff --git a/crates/environ/src/component/types_builder.rs b/crates/environ/src/component/types_builder.rs
index ddfe291b08..f680d28494 100644
--- a/crates/environ/src/component/types_builder.rs
+++ b/crates/environ/src/component/types_builder.rs
@@ -458,7 +458,7 @@ impl ComponentTypesBuilder {
ComponentDefinedType::Stream(ty) => {
InterfaceType::Stream(self.stream_table_type(types, ty)?)
}
- ComponentDefinedType::FixedSizeList(ty, size) => {
+ ComponentDefinedType::FixedLengthList(ty, size) => {
InterfaceType::FixedLengthList(self.fixed_length_list_type(types, ty, *size)?)
}
ComponentDefinedType::Map(..) => {
@@ -536,11 +536,6 @@ impl ComponentTypesBuilder {
.cases
.iter()
.map(|(name, case)| {
- // FIXME: need to implement `refines`, not sure what that
- // is at this time.
- if case.refines.is_some() {
- bail!("refines is not supported at this time");
- }
Ok((
name.to_string(),
match &case.ty.as_ref() {
diff --git a/crates/test-util/src/wast.rs b/crates/test-util/src/wast.rs
index cd72725aa3..4fdda8111b 100644
--- a/crates/test-util/src/wast.rs
+++ b/crates/test-util/src/wast.rs
@@ -441,6 +441,17 @@ impl WastTest {
return true;
}
+ // These tests in the `component-model` submodule have not yet been
+ // updated to account for the recent threading-related intrinsic
+ // changes
+ let unsupported = [
+ "test/async/same-component-stream-future.wast",
+ "test/async/trap-if-block-and-sync.wast",
+ ];
+ if unsupported.iter().any(|part| self.path.ends_with(part)) {
+ return true;
+ }
+
// Some tests are known to fail with the pooling allocator
if config.pooling {
let unsupported = [
diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs
index 2f0109f4f4..175037b123 100644
--- a/crates/wasmtime/src/config.rs
+++ b/crates/wasmtime/src/config.rs
@@ -1237,7 +1237,7 @@ impl Config {
/// incomplete.
#[cfg(feature = "component-model")]
pub fn wasm_component_model_fixed_length_lists(&mut self, enable: bool) -> &mut Self {
- self.wasm_features(WasmFeatures::CM_FIXED_SIZE_LIST, enable);
+ self.wasm_features(WasmFeatures::CM_FIXED_LENGTH_LISTS, enable);
self
}
@@ -2210,7 +2210,7 @@ impl Config {
| WasmFeatures::CM_THREADING
| WasmFeatures::CM_ERROR_CONTEXT
| WasmFeatures::CM_GC
- | WasmFeatures::CM_FIXED_SIZE_LIST;
+ | WasmFeatures::CM_FIXED_LENGTH_LISTS;
#[allow(unused_mut, reason = "easier to avoid #[cfg]")]
let mut unsupported = !features_known_to_wasmtime;
diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rs
index 4cb543014d..3120e91573 100644
--- a/crates/wasmtime/src/runtime/component/concurrent.rs
+++ b/crates/wasmtime/src/runtime/component/concurrent.rs
@@ -632,6 +632,23 @@ impl fmt::Debug for GuestCallKind {
}
}
+/// The target of a suspension intrinsic.
+#[derive(Copy, Clone, Debug)]
+pub enum SuspensionTarget {
+ SomeSuspended(u32),
+ Some(u32),
+ None,
+}
+
+impl SuspensionTarget {
+ fn is_none(&self) -> bool {
+ matches!(self, SuspensionTarget::None)
+ }
+ fn is_some(&self) -> bool {
+ !self.is_none()
+ }
+}
+
/// Represents a pending call into guest code for a given guest thread.
#[derive(Debug)]
struct GuestCall {
@@ -683,8 +700,10 @@ enum WorkItem {
PushFuture(AlwaysMut<HostTaskFuture>),
/// A fiber to resume.
ResumeFiber(StoreFiber<'static>),
+ /// A thread to resume.
+ ResumeThread(RuntimeComponentInstanceIndex, QualifiedThreadId),
/// A pending call into guest code for a given guest task.
- GuestCall(GuestCall),
+ GuestCall(RuntimeComponentInstanceIndex, GuestCall),
/// A job to run on a worker fiber.
WorkerFunction(AlwaysMut<Box<dyn FnOnce(&mut dyn VMStore) -> Result<()> + Send>>),
}
@@ -694,7 +713,16 @@ impl fmt::Debug for WorkItem {
match self {
Self::PushFuture(_) => f.debug_tuple("PushFuture").finish(),
Self::ResumeFiber(_) => f.debug_tuple("ResumeFiber").finish(),
- Self::GuestCall(call) => f.debug_tuple("GuestCall").field(call).finish(),
+ Self::ResumeThread(instance, thread) => f
+ .debug_tuple("ResumeThread")
+ .field(instance)
+ .field(thread)
+ .finish(),
+ Self::GuestCall(instance, call) => f
+ .debug_tuple("GuestCall")
+ .field(instance)
+ .field(call)
+ .finish(),
Self::WorkerFunction(_) => f.debug_tuple("WorkerFunction").finish(),
}
}
@@ -1307,7 +1335,17 @@ impl<T> StoreContextMut<'_, T> {
WorkItem::ResumeFiber(fiber) => {
self.0.resume_fiber(fiber).await?;
}
- WorkItem::GuestCall(call) => {
+ WorkItem::ResumeThread(_, thread) => {
+ if let GuestThreadState::Ready(fiber) = mem::replace(
+ &mut self.0.concurrent_state_mut().get_mut(thread.thread)?.state,
+ GuestThreadState::Running,
+ ) {
+ self.0.resume_fiber(fiber).await?;
+ } else {
+ bail!("cannot resume non-pending thread {thread:?}");
+ }
+ }
+ WorkItem::GuestCall(_, call) => {
if call.is_ready(self.0)? {
self.run_on_worker(WorkerItem::GuestCall(call)).await?;
} else {
@@ -1663,7 +1701,7 @@ impl StoreOpaque {
let call = GuestCall { thread, kind };
if call.is_ready(self)? {
self.concurrent_state_mut()
- .push_high_priority(WorkItem::GuestCall(call));
+ .push_high_priority(WorkItem::GuestCall(instance.index, call));
} else {
self.instance_state(instance)
.concurrent_state()
@@ -1724,8 +1762,9 @@ impl StoreOpaque {
}
}
SuspendReason::Yielding { thread, .. } => {
- state.get_mut(thread.thread)?.state = GuestThreadState::Pending;
- state.push_low_priority(WorkItem::ResumeFiber(fiber));
+ state.get_mut(thread.thread)?.state = GuestThreadState::Ready(fiber);
+ let instance = state.get_mut(thread.task)?.instance.index;
+ state.push_low_priority(WorkItem::ResumeThread(instance, thread));
}
SuspendReason::ExplicitlySuspending { thread, .. } => {
state.get_mut(thread.thread)?.state = GuestThreadState::Suspended(fiber);
@@ -1948,7 +1987,7 @@ impl Instance {
if state.may_block(guest_thread.task) {
// Push this thread onto the "low priority" queue so it runs
// after any other threads have had a chance to run.
- state.push_low_priority(WorkItem::GuestCall(call));
+ state.push_low_priority(WorkItem::GuestCall(runtime_instance, call));
None
} else {
// Yielding in a non-blocking context is defined as a no-op
@@ -1969,13 +2008,16 @@ impl Instance {
|| !state.get_mut(set)?.ready.is_empty()
{
// An event is immediately available; deliver it ASAP.
- state.push_high_priority(WorkItem::GuestCall(GuestCall {
- thread: guest_thread,
- kind: GuestCallKind::DeliverEvent {
- instance: self,
- set: Some(set),
+ state.push_high_priority(WorkItem::GuestCall(
+ runtime_instance,
+ GuestCall {
+ thread: guest_thread,
+ kind: GuestCallKind::DeliverEvent {
+ instance: self,
+ set: Some(set),
+ },
},
- }));
+ ));
} else {
// No event is immediately available.
//
@@ -2266,10 +2308,13 @@ impl Instance {
store
.0
.concurrent_state_mut()
- .push_high_priority(WorkItem::GuestCall(GuestCall {
- thread: guest_thread,
- kind: GuestCallKind::StartImplicit(fun),
- }));
+ .push_high_priority(WorkItem::GuestCall(
+ callee_instance.index,
+ GuestCall {
+ thread: guest_thread,
+ kind: GuestCallKind::StartImplicit(fun),
+ },
+ ));
Ok(())
}
@@ -3216,12 +3261,13 @@ impl Instance {
self.add_guest_thread_to_instance_table(thread_id, store.0, runtime_instance)
}
- pub(crate) fn resume_suspended_thread(
+ pub(crate) fn resume_thread(
self,
store: &mut StoreOpaque,
runtime_instance: RuntimeComponentInstanceIndex,
thread_idx: u32,
high_priority: bool,
+ allow_ready: bool,
) -> Result<()> {
let thread_id =
GuestThread::from_instance(self.id().get_mut(store), runtime_instance, thread_idx)?;
@@ -3232,12 +3278,15 @@ impl Instance {
match mem::replace(&mut thread.state, GuestThreadState::Running) {
GuestThreadState::NotStartedExplicit(start_func) => {
log::trace!("starting thread {guest_thread:?}");
- let guest_call = WorkItem::GuestCall(GuestCall {
- thread: guest_thread,
- kind: GuestCallKind::StartExplicit(Box::new(move |store| {
- start_func(store, guest_thread)
- })),
- });
+ let guest_call = WorkItem::GuestCall(
+ runtime_instance,
+ GuestCall {
+ thread: guest_thread,
+ kind: GuestCallKind::StartExplicit(Box::new(move |store| {
+ start_func(store, guest_thread)
+ })),
+ },
+ );
store
.concurrent_state_mut()
.push_work_item(guest_call, high_priority);
@@ -3248,7 +3297,15 @@ impl Instance {
.concurrent_state_mut()
.push_work_item(WorkItem::ResumeFiber(fiber), high_priority);
}
- _ => {
+ GuestThreadState::Ready(fiber) if allow_ready => {
+ log::trace!("resuming thread {thread_id:?} that was ready");
+ thread.state = GuestThreadState::Ready(fiber);
+ store
+ .concurrent_state_mut()
+ .promote_thread_work_item(guest_thread);
+ }
+ other => {
+ thread.state = other;
bail!("cannot resume thread which is not suspended");
}
}
@@ -3275,15 +3332,15 @@ impl Instance {
Ok(guest_id)
}
- /// Helper function for the `thread.yield`, `thread.yield-to`, `thread.suspend`,
- /// and `thread.switch-to` intrinsics.
+ /// Helper function for the `thread.yield`, `thread.yield-to-suspended`, `thread.suspend`,
+ /// `thread.suspend-to`, and `thread.suspend-to-suspended` intrinsics.
pub(crate) fn suspension_intrinsic(
self,
store: &mut StoreOpaque,
caller: RuntimeComponentInstanceIndex,
cancellable: bool,
yielding: bool,
- to_thread: Option<u32>,
+ to_thread: SuspensionTarget,
) -> Result<WaitResult> {
let guest_thread = store.concurrent_state_mut().unwrap_current_guest_thread();
if to_thread.is_none() {
@@ -3291,10 +3348,12 @@ impl Instance {
if yielding {
// This is a `thread.yield` call
if !state.may_block(guest_thread.task) {
- // The spec defines `thread.yield` to be a no-op in a
- // non-blocking context, so we return immediately without giving
- // any other thread a chance to run.
- return Ok(WaitResult::Completed);
+ // In a non-blocking context, a `thread.yield` may trigger
+ // other threads in the same component instance to run.
+ if !state.promote_instance_local_thread_work_item(caller) {
+ // No other threads are runnable, so just return
+ return Ok(WaitResult::Completed);
+ }
}
} else {
// The caller may only call `thread.suspend` from an async task
@@ -3309,15 +3368,21 @@ impl Instance {
return Ok(WaitResult::Cancelled);
}
- if let Some(thread) = to_thread {
- self.resume_suspended_thread(store, caller, thread, true)?;
+ match to_thread {
+ SuspensionTarget::SomeSuspended(thread) => {
+ self.resume_thread(store, caller, thread, true, false)?
+ }
+ SuspensionTarget::Some(thread) => {
+ self.resume_thread(store, caller, thread, true, true)?
+ }
+ SuspensionTarget::None => { /* nothing to do */ }
}
let reason = if yielding {
SuspendReason::Yielding {
thread: guest_thread,
// Tell `StoreOpaque::suspend` it's okay to suspend here since
- // we're handling a `thread.yield-to` call; otherwise it would
+ // we're handling a `thread.yield-to-suspended` call; otherwise it would
// panic if we called it in a non-blocking context.
skip_may_block_check: to_thread.is_some(),
}
@@ -3325,7 +3390,7 @@ impl Instance {
SuspendReason::ExplicitlySuspending {
thread: guest_thread,
// Tell `StoreOpaque::suspend` it's okay to suspend here since
- // we're handling a `thread.switch-to` call; otherwise it would
+ // we're handling a `thread.suspend-to(-suspended)` call; otherwise it would
// panic if we called it in a non-blocking context.
skip_may_block_check: to_thread.is_some(),
}
@@ -3515,6 +3580,7 @@ impl Instance {
// `Event::Cancelled` if it was already cancelled), but that's
// okay -- this should supersede the previous state.
task.event = Some(Event::Cancelled);
+ let runtime_instance = task.instance.index;
for thread in task.threads.clone() {
let thread = QualifiedThreadId {
task: guest_task,
@@ -3533,13 +3599,16 @@ impl Instance {
.unwrap()
{
WaitMode::Fiber(fiber) => WorkItem::ResumeFiber(fiber),
- WaitMode::Callback(instance) => WorkItem::GuestCall(GuestCall {
- thread,
- kind: GuestCallKind::DeliverEvent {
- instance,
- set: None,
+ WaitMode::Callback(instance) => WorkItem::GuestCall(
+ runtime_instance,
+ GuestCall {
+ thread,
+ kind: GuestCallKind::DeliverEvent {
+ instance,
+ set: None,
+ },
},
- }),
+ ),
};
concurrent_state.push_high_priority(item);
@@ -4183,7 +4252,7 @@ enum GuestThreadState {
),
Running,
Suspended(StoreFiber<'static>),
- Pending,
+ Ready(StoreFiber<'static>),
Completed,
}
pub struct GuestThread {
@@ -4604,13 +4673,16 @@ impl Waitable {
let item = match mode {
WaitMode::Fiber(fiber) => WorkItem::ResumeFiber(fiber),
- WaitMode::Callback(instance) => WorkItem::GuestCall(GuestCall {
- thread,
- kind: GuestCallKind::DeliverEvent {
- instance,
- set: Some(set),
+ WaitMode::Callback(instance) => WorkItem::GuestCall(
+ state.get_mut(thread.task)?.instance.index,
+ GuestCall {
+ thread,
+ kind: GuestCallKind::DeliverEvent {
+ instance,
+ set: Some(set),
+ },
},
- }),
+ ),
};
state.push_high_priority(item);
}
@@ -4827,7 +4899,7 @@ impl ConcurrentState {
}
}
} else if let Some(thread) = entry.downcast_mut::<GuestThread>() {
- if let GuestThreadState::Suspended(fiber) =
+ if let GuestThreadState::Suspended(fiber) | GuestThreadState::Ready(fiber) =
mem::replace(&mut thread.state, GuestThreadState::Completed)
{
fibers.push(fiber);
@@ -4941,6 +5013,48 @@ impl ConcurrentState {
}
}
+ fn promote_instance_local_thread_work_item(
+ &mut self,
+ current_instance: RuntimeComponentInstanceIndex,
+ ) -> bool {
+ self.promote_work_items_matching(|item: &WorkItem| match item {
+ WorkItem::ResumeThread(instance, _) | WorkItem::GuestCall(instance, _) => {
+ *instance == current_instance
+ }
+ _ => false,
+ })
+ }
+
+ fn promote_thread_work_item(&mut self, thread: QualifiedThreadId) -> bool {
+ self.promote_work_items_matching(|item: &WorkItem| match item {
+ WorkItem::ResumeThread(_, t) | WorkItem::GuestCall(_, GuestCall { thread: t, .. }) => {
+ *t == thread
+ }
+ _ => false,
+ })
+ }
+
+ fn promote_work_items_matching<F>(&mut self, mut predicate: F) -> bool
+ where
+ F: FnMut(&WorkItem) -> bool,
+ {
+ // If there's a high-priority work item to resume the current guest thread,
+ // we don't need to promote anything, but we return true to indicate that
+ // work is pending for the current instance.
+ if self.high_priority.iter().any(&mut predicate) {
+ true
+ }
+ // Otherwise, look for a low-priority work item that matches the current
+ // instance and promote it to high-priority.
+ else if let Some(idx) = self.low_priority.iter().position(&mut predicate) {
+ let item = self.low_priority.remove(idx).unwrap();
+ self.push_high_priority(item);
+ true
+ } else {
+ false
+ }
+ }
+
/// Implements the `context.get` intrinsic.
pub(crate) fn context_get(&mut self, slot: u32) -> Result<u32> {
let thread = self.unwrap_current_guest_thread();
diff --git a/crates/wasmtime/src/runtime/vm/component/libcalls.rs b/crates/wasmtime/src/runtime/vm/component/libcalls.rs
index 655524af81..33b5d615ca 100644
--- a/crates/wasmtime/src/runtime/vm/component/libcalls.rs
+++ b/crates/wasmtime/src/runtime/vm/component/libcalls.rs
@@ -6,7 +6,7 @@ use crate::component::concurrent::WaitResult;
use crate::prelude::*;
use crate::runtime::component::RuntimeInstance;
#[cfg(feature = "component-model-async")]
-use crate::runtime::component::concurrent::ResourcePair;
+use crate::runtime::component::concurrent::{ResourcePair, SuspensionTarget};
use crate::runtime::vm::component::{ComponentInstance, VMComponentContext};
use crate::runtime::vm::{HostResultHasUnwindSentinel, VMStore, VmSafe};
use core::cell::Cell;
@@ -809,7 +809,7 @@ fn thread_yield(
RuntimeComponentInstanceIndex::from_u32(caller_instance),
cancellable != 0,
true,
- None,
+ SuspensionTarget::None,
)
.map(|r| r == WaitResult::Cancelled)
}
@@ -1356,7 +1356,7 @@ fn thread_new_indirect(
}
#[cfg(feature = "component-model-async")]
-fn thread_switch_to(
+fn thread_suspend_to_suspended(
store: &mut dyn VMStore,
instance: Instance,
caller: u32,
@@ -1369,7 +1369,26 @@ fn thread_switch_to(
RuntimeComponentInstanceIndex::from_u32(caller),
cancellable != 0,
false,
- Some(thread_idx),
+ SuspensionTarget::SomeSuspended(thread_idx),
+ )
+ .map(|r| r == WaitResult::Cancelled)
+}
+
+#[cfg(feature = "component-model-async")]
+fn thread_suspend_to(
+ store: &mut dyn VMStore,
+ instance: Instance,
+ caller: u32,
+ cancellable: u8,
+ thread_idx: u32,
+) -> Result<bool> {
+ instance
+ .suspension_intrinsic(
+ store,
+ RuntimeComponentInstanceIndex::from_u32(caller),
+ cancellable != 0,
+ false,
+ SuspensionTarget::Some(thread_idx),
)
.map(|r| r == WaitResult::Cancelled)
}
@@ -1387,28 +1406,29 @@ fn thread_suspend(
RuntimeComponentInstanceIndex::from_u32(caller),
cancellable != 0,
false,
- None,
+ SuspensionTarget::None,
)
.map(|r| r == WaitResult::Cancelled)
}
#[cfg(feature = "component-model-async")]
-fn thread_resume_later(
+fn thread_unsuspend(
store: &mut dyn VMStore,
instance: Instance,
caller_instance: u32,
thread_idx: u32,
) -> Result<()> {
- instance.resume_suspended_thread(
+ instance.resume_thread(
store,
RuntimeComponentInstanceIndex::from_u32(caller_instance),
thread_idx,
false,
+ false,
)
}
#[cfg(feature = "component-model-async")]
-fn thread_yield_to(
+fn thread_yield_to_suspended(
store: &mut dyn VMStore,
instance: Instance,
caller_instance: u32,
@@ -1421,7 +1441,7 @@ fn thread_yield_to(
RuntimeComponentInstanceIndex::from_u32(caller_instance),
cancellable != 0,
true,
- Some(thread_idx),
+ SuspensionTarget::SomeSuspended(thread_idx),
)
.map(|r| r == WaitResult::Cancelled)
}
diff --git a/crates/wit-bindgen/Cargo.toml b/crates/wit-bindgen/Cargo.toml
index a2ab791ea3..f876ff462c 100644
--- a/crates/wit-bindgen/Cargo.toml
+++ b/crates/wit-bindgen/Cargo.toml
@@ -16,7 +16,7 @@ workspace = true
anyhow = { workspace = true }
heck = { workspace = true }
wit-parser = { workspace = true }
-indexmap = { workspace = true }
+indexmap = { workspace = true, features = ['std'] }
bitflags = { workspace = true }
[features]
diff --git a/crates/wit-bindgen/src/lib.rs b/crates/wit-bindgen/src/lib.rs
index 47550d804a..f55d9a860d 100644
--- a/crates/wit-bindgen/src/lib.rs
+++ b/crates/wit-bindgen/src/lib.rs
@@ -235,7 +235,7 @@ impl Wasmtime {
o.add_interface(resolve, id);
self.interface_link_options.insert(*id, o);
}
- WorldItem::Function(_) | WorldItem::Type(_) => {}
+ WorldItem::Function(_) | WorldItem::Type { .. } => {}
}
}
}
@@ -478,12 +478,12 @@ impl Wasmtime {
self.interface_link_options[id]
.write_impl_from_world(&mut self.src, &interface_path);
}
- WorldItem::Type(ty) => {
+ WorldItem::Type { id, .. } => {
let name = match name {
WorldKey::Name(name) => name,
WorldKey::Interface(_) => unreachable!(),
};
- generator.define_type(name, *ty);
+ generator.define_type(name, *id);
let body = mem::take(&mut generator.src);
self.src.push_str(&body);
}
@@ -530,7 +530,7 @@ impl Wasmtime {
func.name
);
}
- WorldItem::Type(_) => unreachable!(),
+ WorldItem::Type { .. } => unreachable!(),
WorldItem::Interface { id, .. } => {
generator
.generator
@@ -1488,7 +1488,7 @@ impl Wasmtime {
.imports
.iter()
.filter_map(|(_, i)| match i {
- WorldItem::Interface { id, stability } if *id == interface_id => {
+ WorldItem::Interface { id, stability, .. } if *id == interface_id => {
Some(stability.clone())
}
_ => None,
@@ -1628,7 +1628,7 @@ impl<'a> InterfaceGenerator<'a> {
TypeDefKind::Handle(handle) => self.type_handle(id, name, handle, &ty.docs),
TypeDefKind::Resource => self.type_resource(id, name, ty, &ty.docs),
TypeDefKind::Unknown => unreachable!(),
- TypeDefKind::FixedSizeList(..) => todo!(),
+ TypeDefKind::FixedLengthList(..) => todo!(),
TypeDefKind::Map(..) => todo!(),
}
}
@@ -2434,10 +2434,10 @@ impl<'a> InterfaceGenerator<'a> {
}
self.src.push_str(") : (");
- for (_, ty) in func.params.iter() {
+ for param in func.params.iter() {
// Lift is required to be implied for this type, so we can't use
// a borrowed type:
- self.print_ty(ty, TypeMode::Owned);
+ self.print_ty(&param.ty, TypeMode::Owned);
self.src.push_str(", ");
}
self.src.push_str(")| {\n");
@@ -2493,9 +2493,9 @@ impl<'a> InterfaceGenerator<'a> {
.params
.iter()
.enumerate()
- .map(|(i, (name, ty))| {
- let name = to_rust_ident(&name);
- formatting_for_arg(&name, i, *ty, &self.resolve, flags)
+ .map(|(i, param)| {
+ let name = to_rust_ident(&param.name);
+ formatting_for_arg(&name, i, param.ty, &self.resolve, flags)
})
.collect::<Vec<String>>();
event_fields.push(format!("\"call\""));
@@ -2660,11 +2660,11 @@ impl<'a> InterfaceGenerator<'a> {
}
fn generate_function_params(&mut self, func: &Function) {
- for (name, param) in func.params.iter() {
- let name = to_rust_ident(name);
+ for param in func.params.iter() {
+ let name = to_rust_ident(&param.name);
self.push_str(&name);
self.push_str(": ");
- self.print_ty(param, TypeMode::Owned);
+ self.print_ty(&param.ty, TypeMode::Owned);
self.push_str(",");
}
}
@@ -2753,7 +2753,7 @@ impl<'a> InterfaceGenerator<'a> {
for (i, param) in func.params.iter().enumerate() {
uwrite!(self.src, "arg{}: ", i);
- self.print_ty(&param.1, param_mode);
+ self.print_ty(&param.ty, param_mode);
self.push_str(",");
}
@@ -3094,8 +3094,8 @@ fn convert_{snake}(&mut self, err: {root}{custom_name}) ->
"{trait_name}::{}(*self,",
rust_function_name(func)
);
- for (name, _) in func.params.iter() {
- uwrite!(self.src, "{},", to_rust_ident(name));
+ for param in func.params.iter() {
+ uwrite!(self.src, "{},", to_rust_ident(&param.name));
}
uwrite!(self.src, ")");
if flags.contains(FunctionFlags::ASYNC) {
@@ -3234,15 +3234,15 @@ impl LinkOptionsBuilder {
for (_, import) in world.imports.iter() {
match import {
- WorldItem::Interface { id, stability } => {
+ WorldItem::Interface { id, stability, .. } => {
self.add_stability(stability);
self.add_interface(resolve, id);
}
WorldItem::Function(f) => {
self.add_stability(&f.stability);
}
- WorldItem::Type(t) => {
- self.add_type(resolve, t);
+ WorldItem::Type { id, .. } => {
+ self.add_type(resolve, id);
}
}
}
@@ -3436,7 +3436,7 @@ fn type_contains_lists(ty: Type, resolve: &Resolve) -> bool {
.any(|case| option_type_contains_lists(case.ty, resolve)),
TypeDefKind::Type(ty) => type_contains_lists(*ty, resolve),
TypeDefKind::List(_) => true,
- TypeDefKind::FixedSizeList(..) => todo!(),
+ TypeDefKind::FixedLengthList(..) => todo!(),
TypeDefKind::Map(..) => todo!(),
},
@@ -3545,7 +3545,7 @@ fn get_world_resources<'a>(
.imports
.iter()
.filter_map(move |(name, item)| match item {
- WorldItem::Type(id) => match resolve.types[*id].kind {
+ WorldItem::Type { id, .. } => match resolve.types[*id].kind {
TypeDefKind::Resource => Some(match name {
WorldKey::Name(s) => (*id, s.as_str()),
WorldKey::Interface(_) => unreachable!(),
diff --git a/crates/wit-bindgen/src/rust.rs b/crates/wit-bindgen/src/rust.rs
index bc9e39fc67..2ba39559ed 100644
--- a/crates/wit-bindgen/src/rust.rs
+++ b/crates/wit-bindgen/src/rust.rs
@@ -132,7 +132,7 @@ pub trait RustGenerator<'a> {
TypeDefKind::Type(Type::String) => true,
TypeDefKind::Type(_) => false,
TypeDefKind::Unknown => unreachable!(),
- TypeDefKind::FixedSizeList(..) => todo!(),
+ TypeDefKind::FixedLengthList(..) => todo!(),
TypeDefKind::Map(..) => todo!(),
}
}
@@ -189,7 +189,7 @@ pub trait RustGenerator<'a> {
TypeDefKind::Type(t) => self.ty(t, mode),
TypeDefKind::Unknown => unreachable!(),
- TypeDefKind::FixedSizeList(..) => todo!(),
+ TypeDefKind::FixedLengthList(..) => todo!(),
TypeDefKind::Map(..) => todo!(),
}
}
@@ -398,8 +398,8 @@ pub trait RustGenerator<'a> {
fn typedfunc_sig(&self, func: &Function, param_mode: TypeMode) -> String {
let mut out = "(".to_string();
- for (_, ty) in func.params.iter() {
- out.push_str(&self.ty(ty, param_mode));
+ for param in func.params.iter() {
+ out.push_str(&self.ty(&param.ty, param_mode));
out.push_str(", ");
}
out.push_str("), (");
diff --git a/crates/wit-bindgen/src/types.rs b/crates/wit-bindgen/src/types.rs
index 484c525a75..b06c2950f7 100644
--- a/crates/wit-bindgen/src/types.rs
+++ b/crates/wit-bindgen/src/types.rs
@@ -67,7 +67,7 @@ impl Types {
self.type_info_func(resolve, f, import);
}
}
- WorldItem::Type(id) => {
+ WorldItem::Type { id, .. } => {
self.type_id_info(resolve, *id);
}
}
@@ -76,9 +76,9 @@ impl Types {
fn type_info_func(&mut self, resolve: &Resolve, func: &Function, import: bool) {
let mut live = LiveTypes::default();
- for (_, ty) in func.params.iter() {
- self.type_info(resolve, ty);
- live.add_type(resolve, ty);
+ for param in func.params.iter() {
+ self.type_info(resolve, &param.ty);
+ live.add_type(resolve, &param.ty);
}
for id in live.iter() {
if resolve.types[id].name.is_some() {
@@ -157,7 +157,7 @@ impl Types {
TypeDefKind::Handle(_) => info.has_handle = true,
TypeDefKind::Resource => {}
TypeDefKind::Unknown => unreachable!(),
- TypeDefKind::FixedSizeList(..) => todo!(),
+ TypeDefKind::FixedLengthList(..) => todo!(),
TypeDefKind::Map(..) => todo!(),
}
self.type_info.insert(ty, info);
diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml
index 10a397e2fc..d9087f400d 100644
--- a/supply-chain/audits.toml
+++ b/supply-chain/audits.toml
@@ -620,6 +620,14 @@ start = "2024-02-15"
end = "2026-08-21"
notes = "The Bytecode Alliance is the author of this crate."
+[[wildcard-audits.wasm-metadata]]
+who = "Alex Crichton <[email protected]>"
+criteria = "safe-to-deploy"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
+start = "2026-02-10"
+end = "2027-01-08"
+notes = "The Bytecode Alliance is the author of this crate"
+
[[wildcard-audits.wasm-mutate]]
who = "Alex Crichton <[email protected]>"
criteria = "safe-to-deploy"
@@ -6810,6 +6818,12 @@ user-id = 359 # Sean McArthur (seanmonstar)
start = "2019-03-01"
end = "2026-10-10"
+[[trusted.id-arena]]
+criteria = "safe-to-deploy"
+user-id = 696 # Nick Fitzgerald (fitzgen)
+start = "2026-01-14"
+end = "2027-02-11"
+
[[trusted.indexmap]]
criteria = "safe-to-deploy"
user-id = 539 # Josh Stone (cuviper)
diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock
index eeb3e3db45..57ec71ee56 100644
--- a/supply-chain/imports.lock
+++ b/supply-chain/imports.lock
@@ -958,9 +958,16 @@ user-id = 359
user-login = "seanmonstar"
user-name = "Sean McArthur"
+[[publisher.id-arena]]
+version = "2.3.0"
+when = "2026-01-14"
+user-id = 696
+user-login = "fitzgen"
+user-name = "Nick Fitzgerald"
+
[[publisher.indexmap]]
-version = "2.11.4"
-when = "2025-09-18"
+version = "2.13.0"
+when = "2026-01-07"
user-id = 539
user-login = "cuviper"
user-name = "Josh Stone"
@@ -1015,10 +1022,9 @@ user-login = "alexcrichton"
user-name = "Alex Crichton"
[[publisher.json-from-wast]]
-version = "0.236.0"
-when = "2025-07-28"
-user-id = 73222
-user-login = "wasmtime-publish"
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
[[publisher.libc]]
version = "0.2.177"
@@ -1475,10 +1481,9 @@ user-login = "alexcrichton"
user-name = "Alex Crichton"
[[publisher.wasm-compose]]
-version = "0.236.0"
-when = "2025-07-28"
-user-id = 73222
-user-login = "wasmtime-publish"
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
[[publisher.wasm-encoder]]
version = "0.236.0"
@@ -1486,17 +1491,26 @@ when = "2025-07-28"
user-id = 73222
user-login = "wasmtime-publish"
+[[publisher.wasm-encoder]]
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
+
[[publisher.wasm-metadata]]
version = "0.236.0"
when = "2025-07-28"
user-id = 73222
user-login = "wasmtime-publish"
+[[publisher.wasm-metadata]]
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
+
[[publisher.wasm-wave]]
-version = "0.236.0"
-when = "2025-07-28"
-user-id = 73222
-user-login = "wasmtime-publish"
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
[[publisher.wasmparser]]
version = "0.236.0"
@@ -1504,11 +1518,15 @@ when = "2025-07-28"
user-id = 73222
user-login = "wasmtime-publish"
+[[publisher.wasmparser]]
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
+
[[publisher.wasmprinter]]
-version = "0.236.0"
-when = "2025-07-28"
-user-id = 73222
-user-login = "wasmtime-publish"
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
[[publisher.wasmtime]]
version = "41.0.3"
@@ -1661,16 +1679,14 @@ when = "2026-02-04"
trusted-publisher = "github:bytecodealliance/wasmtime"
[[publisher.wast]]
-version = "236.0.0"
-when = "2025-07-28"
-user-id = 73222
-user-login = "wasmtime-publish"
+version = "245.0.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
[[publisher.wat]]
-version = "1.236.0"
-when = "2025-07-28"
-user-id = 73222
-user-login = "wasmtime-publish"
+version = "1.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
[[publisher.wiggle]]
version = "41.0.3"
@@ -1933,12 +1949,22 @@ when = "2025-07-28"
user-id = 73222
user-login = "wasmtime-publish"
+[[publisher.wit-component]]
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
+
[[publisher.wit-parser]]
version = "0.236.0"
when = "2025-07-28"
user-id = 73222
user-login = "wasmtime-publish"
+[[publisher.wit-parser]]
+version = "0.245.0"
+when = "2026-02-10"
+trusted-publisher = "github:bytecodealliance/wasm-tools"
+
[[publisher.witx]]
version = "0.9.1"
when = "2021-06-22"
diff --git a/tests/all/component_model/async.rs b/tests/all/component_model/async.rs
index 396079cab3..765c5720fb 100644
--- a/tests/all/component_model/async.rs
+++ b/tests/all/component_model/async.rs
@@ -340,14 +340,14 @@ async fn task_deletion() -> Result<()> {
(import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
(import "" "thread.suspend" (func $thread-suspend (result i32)))
(import "" "thread.suspend-cancellable" (func $thread-suspend-cancellable (result i32)))
- (import "" "thread.yield-to" (func $thread-yield-to (param i32) (result i32)))
- (import "" "thread.yield-to-cancellable" (func $thread-yield-to-cancellable (param i32) (result i32)))
- (import "" "thread.switch-to" (func $thread-switch-to (param i32) (result i32)))
- (import "" "thread.switch-to-cancellable" (func $thread-switch-to-cancellable (param i32) (result i32)))
+ (import "" "thread.yield-to-suspended" (func $thread-yield-to-suspended (param i32) (result i32)))
+ (import "" "thread.yield-to-suspended-cancellable" (func $thread-yield-to-suspended-cancellable (param i32) (result i32)))
+ (import "" "thread.suspend-to" (func $thread-suspend-to (param i32) (result i32)))
+ (import "" "thread.suspend-to-cancellable" (func $thread-suspend-to-cancellable (param i32) (result i32)))
(import "" "thread.yield" (func $thread-yield (result i32)))
(import "" "thread.yield-cancellable" (func $thread-yield-cancellable (result i32)))
(import "" "thread.index" (func $thread-index (result i32)))
- (import "" "thread.resume-later" (func $thread-resume-later (param i32)))
+ (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
(import "" "waitable.join" (func $waitable.join (param i32 i32)))
(import "" "waitable-set.new" (func $waitable-set.new (result i32)))
(import "" "waitable-set.wait" (func $waitable-set.wait (param i32 i32) (result i32)))
@@ -370,11 +370,11 @@ async fn task_deletion() -> Result<()> {
(br $top)))
(func (export "explicit-thread-calls-return-stackful")
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $call-return-ftbl-idx) (i32.const 42))))
(func (export "explicit-thread-calls-return-stackless") (result i32)
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $call-return-ftbl-idx) (i32.const 42)))
(i32.const 0 (; EXIT ;)))
@@ -382,33 +382,33 @@ async fn task_deletion() -> Result<()> {
(unreachable))
(func (export "explicit-thread-suspends-sync") (result i32)
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $suspend-ftbl-idx) (i32.const 42)))
(i32.const 42))
(func (export "explicit-thread-suspends-stackful")
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $suspend-ftbl-idx) (i32.const 42)))
(call $task-return (i32.const 42)))
(func (export "explicit-thread-suspends-stackless") (result i32)
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $suspend-ftbl-idx) (i32.const 42)))
(call $task-return (i32.const 42))
(i32.const 0))
(func (export "explicit-thread-yield-loops-sync") (result i32)
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $yield-loop-ftbl-idx) (i32.const 42)))
(i32.const 42))
(func (export "explicit-thread-yield-loops-stackful")
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $yield-loop-ftbl-idx) (i32.const 42)))
(call $task-return (i32.const 42)))
(func (export "explicit-thread-yield-loops-stackless") (result i32)
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $suspend-ftbl-idx) (i32.const 42)))
(call $task-return (i32.const 42))
(i32.const 0 (; EXIT ;)))
@@ -432,11 +432,11 @@ async fn task_deletion() -> Result<()> {
(core func $thread-yield (canon thread.yield))
(core func $thread-yield-cancellable (canon thread.yield cancellable))
(core func $thread-index (canon thread.index))
- (core func $thread-yield-to (canon thread.yield-to))
- (core func $thread-yield-to-cancellable (canon thread.yield-to cancellable))
- (core func $thread-resume-later (canon thread.resume-later))
- (core func $thread-switch-to (canon thread.switch-to))
- (core func $thread-switch-to-cancellable (canon thread.switch-to cancellable))
+ (core func $thread-yield-to-suspended (canon thread.yield-to-suspended))
+ (core func $thread-yield-to-suspended-cancellable (canon thread.yield-to-suspended cancellable))
+ (core func $thread-unsuspend (canon thread.unsuspend))
+ (core func $thread-suspend-to (canon thread.suspend-to))
+ (core func $thread-suspend-to-cancellable (canon thread.suspend-to cancellable))
(core func $thread-suspend (canon thread.suspend))
(core func $thread-suspend-cancellable (canon thread.suspend cancellable))
(core func $waitable-set.new (canon waitable-set.new))
@@ -452,15 +452,15 @@ async fn task_deletion() -> Result<()> {
(export "task.cancel" (func $task-cancel))
(export "thread.new-indirect" (func $thread-new-indirect))
(export "thread.index" (func $thread-index))
- (export "thread.yield-to" (func $thread-yield-to))
- (export "thread.yield-to-cancellable" (func $thread-yield-to-cancellable))
+ (export "thread.yield-to-suspended" (func $thread-yield-to-suspended))
+ (export "thread.yield-to-suspended-cancellable" (func $thread-yield-to-suspended-cancellable))
(export "thread.yield" (func $thread-yield))
(export "thread.yield-cancellable" (func $thread-yield-cancellable))
- (export "thread.switch-to" (func $thread-switch-to))
- (export "thread.switch-to-cancellable" (func $thread-switch-to-cancellable))
+ (export "thread.suspend-to" (func $thread-suspend-to))
+ (export "thread.suspend-to-cancellable" (func $thread-suspend-to-cancellable))
(export "thread.suspend" (func $thread-suspend))
(export "thread.suspend-cancellable" (func $thread-suspend-cancellable))
- (export "thread.resume-later" (func $thread-resume-later))
+ (export "thread.unsuspend" (func $thread-unsuspend))
(export "waitable.join" (func $waitable.join))
(export "waitable-set.wait" (func $waitable-set.wait))
(export "waitable-set.new" (func $waitable-set.new))))
diff --git a/tests/all/component_model/func.rs b/tests/all/component_model/func.rs
index fd13a8b218..6595421368 100644
--- a/tests/all/component_model/func.rs
+++ b/tests/all/component_model/func.rs
@@ -959,12 +959,12 @@ async fn missing_task_return_call_stackless_explicit_thread() -> Result<()> {
(core module $m
(import "" "task.return" (func $task-return))
(import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
- (import "" "thread.resume-later" (func $thread-resume-later (param i32)))
+ (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
(import "libc" "__indirect_function_table" (table $indirect-function-table 1 funcref))
(func $thread-start (param i32) (; empty ;))
(elem (table $indirect-function-table) (i32.const 0) func $thread-start)
(func (export "foo") (result i32)
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (i32.const 0) (i32.const 0)))
i32.const 0
)
@@ -975,12 +975,12 @@ async fn missing_task_return_call_stackless_explicit_thread() -> Result<()> {
(alias core export $libc "__indirect_function_table" (core table $indirect-function-table))
(core func $thread-new-indirect
(canon thread.new-indirect $start-func-ty (table $indirect-function-table)))
- (core func $thread-resume-later (canon thread.resume-later))
+ (core func $thread-unsuspend (canon thread.unsuspend))
(core func $task-return (canon task.return))
(core instance $i (instantiate $m
(with "" (instance
(export "thread.new-indirect" (func $thread-new-indirect))
- (export "thread.resume-later" (func $thread-resume-later))
+ (export "thread.unsuspend" (func $thread-unsuspend))
(export "task.return" (func $task-return))
))
(with "libc" (instance $libc))
@@ -1001,12 +1001,12 @@ async fn missing_task_return_call_stackful_explicit_thread() -> Result<()> {
(core module $m
(import "" "task.return" (func $task-return))
(import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
- (import "" "thread.resume-later" (func $thread-resume-later (param i32)))
+ (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
(import "libc" "__indirect_function_table" (table $indirect-function-table 1 funcref))
(func $thread-start (param i32) (; empty ;))
(elem (table $indirect-function-table) (i32.const 0) func $thread-start)
(func (export "foo")
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (i32.const 0) (i32.const 0)))
)
)
@@ -1015,12 +1015,12 @@ async fn missing_task_return_call_stackful_explicit_thread() -> Result<()> {
(alias core export $libc "__indirect_function_table" (core table $indirect-function-table))
(core func $thread-new-indirect
(canon thread.new-indirect $start-func-ty (table $indirect-function-table)))
- (core func $thread-resume-later (canon thread.resume-later))
+ (core func $thread-unsuspend (canon thread.unsuspend))
(core func $task-return (canon task.return))
(core instance $i (instantiate $m
(with "" (instance
(export "thread.new-indirect" (func $thread-new-indirect))
- (export "thread.resume-later" (func $thread-resume-later))
+ (export "thread.unsuspend" (func $thread-unsuspend))
(export "task.return" (func $task-return))
))
(with "libc" (instance $libc))
diff --git a/tests/misc_testsuite/component-model-threading/many-threads-indexed.wast b/tests/misc_testsuite/component-model-threading/many-threads-indexed.wast
index 62cb8a9f3f..09258c2d65 100644
--- a/tests/misc_testsuite/component-model-threading/many-threads-indexed.wast
+++ b/tests/misc_testsuite/component-model-threading/many-threads-indexed.wast
@@ -32,11 +32,11 @@
;; Import the threading builtins and the table from libc
(import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
(import "" "thread.suspend" (func $thread-suspend (result i32)))
- (import "" "thread.yield-to" (func $thread-yield-to (param i32) (result i32)))
- (import "" "thread.switch-to" (func $thread-switch-to (param i32) (result i32)))
+ (import "" "thread.yield-to-suspended" (func $thread-yield-to-suspended (param i32) (result i32)))
+ (import "" "thread.suspend-to-suspended" (func $thread-suspend-to-suspended (param i32) (result i32)))
(import "" "thread.yield" (func $thread-yield (result i32)))
(import "" "thread.index" (func $thread-index (result i32)))
- (import "" "thread.resume-later" (func $thread-resume-later (param i32)))
+ (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
(import "libc" "__indirect_function_table" (table $indirect-function-table 1 funcref))
;; A memory block that threads will write their thread indexes and assigned values into
@@ -63,7 +63,7 @@
(func $new-thread (param i32)
(drop
- (call $thread-yield-to
+ (call $thread-yield-to-suspended
(call $thread-new-indirect (i32.const 0) (local.get 0)))))
;; The main entry point
@@ -76,11 +76,11 @@
(call $new-thread (i32.const 8))
;; Yield to all threads in ascending order of assigned number
- (drop (call $thread-yield-to (i32.load (i32.const 0))))
- (drop (call $thread-yield-to (i32.load (i32.const 4))))
- (drop (call $thread-yield-to (i32.load (i32.const 8))))
- (drop (call $thread-yield-to (i32.load (i32.const 12))))
- (drop (call $thread-yield-to (i32.load (i32.const 16))))
+ (drop (call $thread-yield-to-suspended (i32.load (i32.const 0))))
+ (drop (call $thread-yield-to-suspended (i32.load (i32.const 4))))
+ (drop (call $thread-yield-to-suspended (i32.load (i32.const 8))))
+ (drop (call $thread-yield-to-suspended (i32.load (i32.const 12))))
+ (drop (call $thread-yield-to-suspended (i32.load (i32.const 16))))
;; Ensure all assigned numbers have been written to the buffer in order
(if (i32.ne (i32.load (i32.const 20)) (i32.const 0)) (then unreachable))
@@ -102,9 +102,9 @@
(canon thread.new-indirect $start-func-ty (table $indirect-function-table)))
(core func $thread-yield (canon thread.yield))
(core func $thread-index (canon thread.index))
- (core func $thread-yield-to (canon thread.yield-to))
- (core func $thread-resume-later (canon thread.resume-later))
- (core func $thread-switch-to (canon thread.switch-to))
+ (core func $thread-yield-to-suspended (canon thread.yield-to-suspended))
+ (core func $thread-unsuspend (canon thread.unsuspend))
+ (core func $thread-suspend-to-suspended (canon thread.suspend-to-suspended))
(core func $thread-suspend (canon thread.suspend))
;; Instantiate the main module
@@ -113,11 +113,11 @@
(with "" (instance
(export "thread.new-indirect" (func $thread-new-indirect))
(export "thread.index" (func $thread-index))
- (export "thread.yield-to" (func $thread-yield-to))
+ (export "thread.yield-to-suspended" (func $thread-yield-to-suspended))
(export "thread.yield" (func $thread-yield))
- (export "thread.switch-to" (func $thread-switch-to))
+ (export "thread.suspend-to-suspended" (func $thread-suspend-to-suspended))
(export "thread.suspend" (func $thread-suspend))
- (export "thread.resume-later" (func $thread-resume-later))))
+ (export "thread.unsuspend" (func $thread-unsuspend))))
(with "libc" (instance $libc))))
;; Export the main entry point
diff --git a/tests/misc_testsuite/component-model-threading/stackful-cancellation.wast b/tests/misc_testsuite/component-model-threading/stackful-cancellation.wast
index 5e87a86a35..25758f436a 100644
--- a/tests/misc_testsuite/component-model-threading/stackful-cancellation.wast
+++ b/tests/misc_testsuite/component-model-threading/stackful-cancellation.wast
@@ -14,7 +14,7 @@
;; The caller cancels the subtask during the first yield, and ensures that the cancellation only takes effect
;; on the second yield.
-;; `run-yield-to`: Yields twice to a spawned thread, first with an uncancellable yield, then with a cancellable yield.
+;; `run-yield-to-suspended`: Yields twice to a spawned thread, first with an uncancellable yield, then with a cancellable yield.
;; A complication is that we can't guarantee that if the spawned thread yields, the supertask will be scheduled to
;; cancel the subtask before the subtask's implicit thread is rescheduled. To handle this, the subtask's implicit
;; thread first waits on a future to be written by the supertask, then yields to the spawned thread.
@@ -26,7 +26,7 @@
;; The caller cancels the subtask during the first suspend, writes to the future to make the spawned thread
;; resume the implicit thread, and ensures that the cancellation only takes effect on the second suspend.
-;; `run-switch-to`: Similar to `run-suspend`, but uses `thread.switch-to` instead of `thread.suspend`.
+;; `run-suspend-to-suspended`: Similar to `run-suspend`, but uses `thread.suspend-to-suspended` instead of `thread.suspend`.
;; -- Component D --
@@ -49,14 +49,14 @@
(import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
(import "" "thread.suspend" (func $thread-suspend (result i32)))
(import "" "thread.suspend-cancellable" (func $thread-suspend-cancellable (result i32)))
- (import "" "thread.yield-to" (func $thread-yield-to (param i32) (result i32)))
- (import "" "thread.yield-to-cancellable" (func $thread-yield-to-cancellable (param i32) (result i32)))
- (import "" "thread.switch-to" (func $thread-switch-to (param i32) (result i32)))
- (import "" "thread.switch-to-cancellable" (func $thread-switch-to-cancellable (param i32) (result i32)))
+ (import "" "thread.yield-to-suspended" (func $thread-yield-to-suspended (param i32) (result i32)))
+ (import "" "thread.yield-to-suspended-cancellable" (func $thread-yield-to-suspended-cancellable (param i32) (result i32)))
+ (import "" "thread.suspend-to-suspended" (func $thread-suspend-to-suspended (param i32) (result i32)))
+ (import "" "thread.suspend-to-suspended-cancellable" (func $thread-suspend-to-suspended-cancellable (param i32) (result i32)))
(import "" "thread.yield" (func $thread-yield (result i32)))
(import "" "thread.yield-cancellable" (func $thread-yield-cancellable (result i32)))
(import "" "thread.index" (func $thread-index (result i32)))
- (import "" "thread.resume-later" (func $thread-resume-later (param i32)))
+ (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
(import "" "future.read" (func $future.read (param i32 i32) (result i32)))
(import "" "waitable.join" (func $waitable.join (param i32 i32)))
(import "" "waitable-set.new" (func $waitable-set.new (result i32)))
@@ -93,7 +93,7 @@
;; Wait for the supertask to signal us to wake up suspended thread.
(call $wait-for-future-write (local.get $future))
;; Resume the main thread, which is suspended in an uncancellable suspend
- (call $thread-resume-later (local.get $thread-index))
+ (call $thread-unsuspend (local.get $thread-index))
)
(func $just-yield (param $explicit-thread-idx i32)
@@ -106,7 +106,7 @@
(elem (table $indirect-function-table) (i32.const 0 (; wake-from-suspend-ftbl-idx ;)) func $wake-from-suspend)
(elem (table $indirect-function-table) (i32.const 1 (; just-yield-ftbl-idx ;)) func $just-yield)
- (func (export "run-yield-to") (param $futr i32)
+ (func (export "run-yield-to-suspended") (param $futr i32)
(local $thread-index i32)
;; Spawn a new thread that will wake us up from our uncancellable suspend; we'll switch to it next
(local.set $thread-index
@@ -121,9 +121,9 @@
;; Yield to the spawned thread uncancellably. We should eventually be rescheduled without being notified
;; of the pending cancellation.
- (if (i32.ne (call $thread-yield-to (local.get $thread-index)) (i32.const 0)) (then unreachable))
+ (if (i32.ne (call $thread-yield-to-suspended (local.get $thread-index)) (i32.const 0)) (then unreachable))
;; Yield to the spawned thread again. This time we should see the cancellation immediately.
- (if (i32.ne (call $thread-yield-to-cancellable (local.get $thread-index)) (i32.const 1)) (then unreachable))
+ (if (i32.ne (call $thread-yield-to-suspended-cancellable (local.get $thread-index)) (i32.const 1)) (then unreachable))
(call $task-cancel)
)
@@ -138,7 +138,7 @@
;; Spawn a new thread that will wake us up from our uncancellable suspend and schedule
;; it to resume after we suspend.
- (call $thread-resume-later
+ (call $thread-unsuspend
(call $thread-new-indirect (global.get $wake-from-suspend-ftbl-idx) (local.get $wake-from-suspend-argp)))
;; Request suspension. We will not be woken up by cancellation, because this is an uncancellable
@@ -150,7 +150,7 @@
(call $task-cancel)
)
- (func (export "run-switch-to") (param $futr i32)
+ (func (export "run-suspend-to-suspended") (param $futr i32)
(local $thread-index i32)
;; Set up the arguments for the wake-for-suspend thread start function.
;; It expects a pointer to a structure containing the thread index to resume
@@ -168,9 +168,9 @@
;; We will not be woken up by cancellation, because this is an uncancellable suspend.
;; We will be woken up by the other thread we spawned above, which will be resumed after
;; the supertask cancels our subtask.
- (if (i32.ne (call $thread-switch-to (local.get $thread-index)) (i32.const 0)) (then unreachable))
+ (if (i32.ne (call $thread-suspend-to-suspended (local.get $thread-index)) (i32.const 0)) (then unreachable))
;; Request suspension again. This time we should see the cancellation immediately.
- (if (i32.ne (call $thread-switch-to-cancellable (local.get $thread-index)) (i32.const 1)) (then unreachable))
+ (if (i32.ne (call $thread-suspend-to-suspended-cancellable (local.get $thread-index)) (i32.const 1)) (then unreachable))
(call $task-cancel)
)
)
@@ -187,11 +187,11 @@
(core func $thread-yield (canon thread.yield))
(core func $thread-yield-cancellable (canon thread.yield cancellable))
(core func $thread-index (canon thread.index))
- (core func $thread-yield-to (canon thread.yield-to))
- (core func $thread-yield-to-cancellable (canon thread.yield-to cancellable))
- (core func $thread-resume-later (canon thread.resume-later))
- (core func $thread-switch-to (canon thread.switch-to))
- (core func $thread-switch-to-cancellable (canon thread.switch-to cancellable))
+ (core func $thread-yield-to-suspended (canon thread.yield-to-suspended))
+ (core func $thread-yield-to-suspended-cancellable (canon thread.yield-to-suspended cancellable))
+ (core func $thread-unsuspend (canon thread.unsuspend))
+ (core func $thread-suspend-to-suspended (canon thread.suspend-to-suspended))
+ (core func $thread-suspend-to-suspended-cancellable (canon thread.suspend-to-suspended cancellable))
(core func $thread-suspend (canon thread.suspend))
(core func $thread-suspend-cancellable (canon thread.suspend cancellable))
(core func $future.read (canon future.read $FT (memory $memory "mem")))
@@ -207,15 +207,15 @@
(export "task.cancel" (func $task-cancel))
(export "thread.new-indirect" (func $thread-new-indirect))
(export "thread.index" (func $thread-index))
- (export "thread.yield-to" (func $thread-yield-to))
- (export "thread.yield-to-cancellable" (func $thread-yield-to-cancellable))
+ (export "thread.yield-to-suspended" (func $thread-yield-to-suspended))
+ (export "thread.yield-to-suspended-cancellable" (func $thread-yield-to-suspended-cancellable))
(export "thread.yield" (func $thread-yield))
(export "thread.yield-cancellable" (func $thread-yield-cancellable))
- (export "thread.switch-to" (func $thread-switch-to))
- (export "thread.switch-to-cancellable" (func $thread-switch-to-cancellable))
+ (export "thread.suspend-to-suspended" (func $thread-suspend-to-suspended))
+ (export "thread.suspend-to-suspended-cancellable" (func $thread-suspend-to-suspended-cancellable))
(export "thread.suspend" (func $thread-suspend))
(export "thread.suspend-cancellable" (func $thread-suspend-cancellable))
- (export "thread.resume-later" (func $thread-resume-later))
+ (export "thread.unsuspend" (func $thread-unsuspend))
(export "future.read" (func $future.read))
(export "waitable.join" (func $waitable.join))
(export "waitable-set.wait" (func $waitable-set.wait))
@@ -223,17 +223,17 @@
(with "libc" (instance $libc))))
(func (export "run-yield") async (result u32) (canon lift (core func $cm "run-yield") async))
- (func (export "run-yield-to") async (param "fut" $FT) (result u32) (canon lift (core func $cm "run-yield-to") async))
+ (func (export "run-yield-to-suspended") async (param "fut" $FT) (result u32) (canon lift (core func $cm "run-yield-to-suspended") async))
(func (export "run-suspend") async (param "fut" $FT) (result u32) (canon lift (core func $cm "run-suspend") async))
- (func (export "run-switch-to") async (param "fut" $FT) (result u32) (canon lift (core func $cm "run-switch-to") async))
+ (func (export "run-suspend-to-suspended") async (param "fut" $FT) (result u32) (canon lift (core func $cm "run-suspend-to-suspended") async))
)
(component $D
(type $FT (future))
(import "run-yield" (func $run-yield async (result u32)))
- (import "run-yield-to" (func $run-yield-to async (param "fut" $FT) (result u32)))
+ (import "run-yield-to-suspended" (func $run-yield-to-suspended async (param "fut" $FT) (result u32)))
(import "run-suspend" (func $run-suspend async (param "fut" $FT) (result u32)))
- (import "run-switch-to" (func $run-switch-to async (param "fut" $FT) (result u32)))
+ (import "run-suspend-to-suspended" (func $run-suspend-to-suspended async (param "fut" $FT) (result u32)))
(core module $Memory (memory (export "mem") 1))
(core instance $memory (instantiate $Memory))
@@ -241,9 +241,9 @@
(import "" "mem" (memory 1))
(import "" "subtask.cancel" (func $subtask.cancel (param i32) (result i32)))
(import "" "run-yield" (func $run-yield (param i32) (result i32)))
- (import "" "run-yield-to" (func $run-yield-to (param i32 i32) (result i32)))
+ (import "" "run-yield-to-suspended" (func $run-yield-to-suspended (param i32 i32) (result i32)))
(import "" "run-suspend" (func $run-suspend (param i32 i32) (result i32)))
- (import "" "run-switch-to" (func $run-switch-to (param i32 i32) (result i32)))
+ (import "" "run-suspend-to-suspended" (func $run-suspend-to-suspended (param i32 i32) (result i32)))
(import "" "waitable.join" (func $waitable.join (param i32 i32)))
(import "" "waitable-set.new" (func $waitable-set.new (result i32)))
(import "" "waitable-set.wait" (func $waitable-set.wait (param i32 i32) (result i32)))
@@ -257,7 +257,7 @@
(local $run-retp i32) (local $wait-retp i32)
(local $ret64 i64) (local $futr i32) (local $futw i32)
- ;; Set up return value storage for run-suspend/switch-to and waitable-set.wait
+ ;; Set up return value storage for run-suspend/suspend-to-suspended and waitable-set.wait
(local.set $run-retp (i32.const 4))
(local.set $wait-retp (i32.const 8))
(i32.store (local.get $run-retp) (i32.const 0xbad0bad0))
@@ -268,20 +268,20 @@
(local.set $futr (i32.wrap_i64 (local.get $ret64)))
(local.set $futw (i32.wrap_i64 (i64.shr_u (local.get $ret64) (i64.const 32))))
- ;; Calling run-suspend/switch-to will start the thread, which will suspend.
+ ;; Calling run-suspend/suspend-to-suspended will start the thread, which will suspend.
;; This is basically a switch statement:
;; 0: run-yield
- ;; 1: run-yield-to
+ ;; 1: run-yield-to-suspended
;; 2: run-suspend
- ;; 3: run-switch-to
+ ;; 3: run-suspend-to-suspended
(if (i32.eq (local.get $test-id) (i32.const 0))
(then (local.set $ret (call $run-yield (local.get $run-retp))))
(else (if (i32.eq (local.get $test-id) (i32.const 1))
- (then (local.set $ret (call $run-yield-to (local.get $futr) (local.get $run-retp))))
+ (then (local.set $ret (call $run-yield-to-suspended (local.get $futr) (local.get $run-retp))))
(else (if (i32.eq (local.get $test-id) (i32.const 2))
(then (local.set $ret (call $run-suspend (local.get $futr) (local.get $run-retp))))
(else (if (i32.eq (local.get $test-id) (i32.const 3))
- (then (local.set $ret (call $run-switch-to (local.get $futr) (local.get $run-retp))))
+ (then (local.set $ret (call $run-suspend-to-suspended (local.get $futr) (local.get $run-retp))))
(else unreachable))))))))
;; Ensure that the thread started
@@ -327,7 +327,7 @@
(if (i32.ne (call $run-test (i32.const 0)) (i32.const 42))
(then unreachable))
- ;; test-id 1: run-yield-to
+ ;; test-id 1: run-yield-to-suspended
(if (i32.ne (call $run-test (i32.const 1)) (i32.const 42))
(then unreachable))
@@ -335,7 +335,7 @@
(if (i32.ne (call $run-test (i32.const 2)) (i32.const 42))
(then unreachable))
- ;; test-id 3: run-switch-to
+ ;; test-id 3: run-suspend-to-suspended
(if (i32.ne (call $run-test (i32.const 3)) (i32.const 42))
(then unreachable))
@@ -353,14 +353,14 @@
(core func $thread.yield (canon thread.yield))
(canon lower (func $run-yield) async (memory $memory "mem") (core func $run-yield'))
(canon lower (func $run-suspend) async (memory $memory "mem") (core func $run-suspend'))
- (canon lower (func $run-switch-to) async (memory $memory "mem") (core func $run-switch-to'))
- (canon lower (func $run-yield-to) async (memory $memory "mem") (core func $run-yield-to'))
+ (canon lower (func $run-suspend-to-suspended) async (memory $memory "mem") (core func $run-suspend-to-suspended'))
+ (canon lower (func $run-yield-to-suspended) async (memory $memory "mem") (core func $run-yield-to-suspended'))
(core instance $dm (instantiate $DM (with "" (instance
(export "mem" (memory $memory "mem"))
(export "run-yield" (func $run-yield'))
(export "run-suspend" (func $run-suspend'))
- (export "run-switch-to" (func $run-switch-to'))
- (export "run-yield-to" (func $run-yield-to'))
+ (export "run-suspend-to-suspended" (func $run-suspend-to-suspended'))
+ (export "run-yield-to-suspended" (func $run-yield-to-suspended'))
(export "waitable.join" (func $waitable.join))
(export "waitable-set.new" (func $waitable-set.new))
(export "waitable-set.wait" (func $waitable-set.wait))
@@ -375,9 +375,9 @@
(instance $c (instantiate $C))
(instance $d (instantiate $D
(with "run-yield" (func $c "run-yield"))
- (with "run-yield-to" (func $c "run-yield-to"))
+ (with "run-yield-to-suspended" (func $c "run-yield-to-suspended"))
(with "run-suspend" (func $c "run-suspend"))
- (with "run-switch-to" (func $c "run-switch-to"))
+ (with "run-suspend-to-suspended" (func $c "run-suspend-to-suspended"))
))
(func (export "run") (alias export $d "run"))
)
diff --git a/tests/misc_testsuite/component-model-threading/threading-builtins.wast b/tests/misc_testsuite/component-model-threading/threading-builtins.wast
index bf10f60439..b695b14e50 100644
--- a/tests/misc_testsuite/component-model-threading/threading-builtins.wast
+++ b/tests/misc_testsuite/component-model-threading/threading-builtins.wast
@@ -13,11 +13,11 @@
;; Import the threading builtins and the table from libc
(import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
(import "" "thread.suspend" (func $thread-suspend (result i32)))
- (import "" "thread.yield-to" (func $thread-yield-to (param i32) (result i32)))
- (import "" "thread.switch-to" (func $thread-switch-to (param i32) (result i32)))
+ (import "" "thread.yield-to-suspended" (func $thread-yield-to-suspended (param i32) (result i32)))
+ (import "" "thread.suspend-to-suspended" (func $thread-suspend-to-suspended (param i32) (result i32)))
(import "" "thread.yield" (func $thread-yield (result i32)))
(import "" "thread.index" (func $thread-index (result i32)))
- (import "" "thread.resume-later" (func $thread-resume-later (param i32)))
+ (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
(import "libc" "__indirect_function_table" (table $indirect-function-table 1 funcref))
;; A global that we will set from the spawned thread
@@ -29,17 +29,17 @@
;; Set the global to the context value
(global.set $g (local.get 0))
;; The main thread switched to us, so is no longer scheduled, so we explicitly schedule it
- (call $thread-resume-later (global.get $main-thread-index))
+ (call $thread-unsuspend (global.get $main-thread-index))
;; Yield back to the main thread (since that is the only other one)
(drop (call $thread-yield)
;; Increment the global
(global.set $g (i32.add (global.get $g) (i32.const 1)))
;; The main thread will have explicitly requested suspension, so yield to it directly
- (drop (call $thread-yield-to (global.get $main-thread-index)))
+ (drop (call $thread-yield-to-suspended (global.get $main-thread-index)))
;; Increment the global again
(global.set $g (i32.add (global.get $g) (i32.const 1)))
;; Reschedule the main thread so that it runs after we exit
- (call $thread-resume-later (global.get $main-thread-index))))
+ (call $thread-unsuspend (global.get $main-thread-index))))
(export "thread-start" (func $thread-start))
;; Initialize the function table with our thread-start function; this will be
@@ -53,7 +53,7 @@
(global.set $main-thread-index (call $thread-index))
;; Create a new thread, which starts suspended, and switch to it
(drop
- (call $thread-switch-to
+ (call $thread-suspend-to-suspended
(call $thread-new-indirect (i32.const 0) (i32.const 42))))
;; After the thread yields back to us, check that the global was set to 42
(if (i32.ne (global.get $g) (i32.const 42)) (then unreachable))
@@ -78,9 +78,9 @@
(canon thread.new-indirect $start-func-ty (table $indirect-function-table)))
(core func $thread-yield (canon thread.yield))
(core func $thread-index (canon thread.index))
- (core func $thread-yield-to (canon thread.yield-to))
- (core func $thread-resume-later (canon thread.resume-later))
- (core func $thread-switch-to (canon thread.switch-to))
+ (core func $thread-yield-to-suspended (canon thread.yield-to-suspended))
+ (core func $thread-unsuspend (canon thread.unsuspend))
+ (core func $thread-suspend-to-suspended (canon thread.suspend-to-suspended))
(core func $thread-suspend (canon thread.suspend))
;; Instantiate the main module
@@ -89,11 +89,11 @@
(with "" (instance
(export "thread.new-indirect" (func $thread-new-indirect))
(export "thread.index" (func $thread-index))
- (export "thread.yield-to" (func $thread-yield-to))
+ (export "thread.yield-to-suspended" (func $thread-yield-to-suspended))
(export "thread.yield" (func $thread-yield))
- (export "thread.switch-to" (func $thread-switch-to))
+ (export "thread.suspend-to-suspended" (func $thread-suspend-to-suspended))
(export "thread.suspend" (func $thread-suspend))
- (export "thread.resume-later" (func $thread-resume-later))))
+ (export "thread.unsuspend" (func $thread-unsuspend))))
(with "libc" (instance $libc))))
;; Export the main entry point
diff --git a/tests/misc_testsuite/component-model-threading/threading-trap-in-post-return.wast b/tests/misc_testsuite/component-model-threading/threading-trap-in-post-return.wast
index c129a5cbf3..6e14ca359c 100644
--- a/tests/misc_testsuite/component-model-threading/threading-trap-in-post-return.wast
+++ b/tests/misc_testsuite/component-model-threading/threading-trap-in-post-return.wast
@@ -8,56 +8,56 @@
(core type $ft (func (param i32)))
(core func $thread.new-indirect (canon thread.new-indirect $ft (table $memory "t")))
- (core func $thread.switch-to (canon thread.switch-to))
+ (core func $thread.suspend-to-suspended (canon thread.suspend-to-suspended))
(core func $thread.suspend (canon thread.suspend))
- (core func $thread.resume-later (canon thread.resume-later))
- (core func $thread.yield-to (canon thread.yield-to))
+ (core func $thread.unsuspend (canon thread.unsuspend))
+ (core func $thread.yield-to-suspended (canon thread.yield-to-suspended))
(core module $DM
(import "" "thread.new-indirect" (func $thread.new-indirect (param i32 i32) (result i32)))
- (import "" "thread.switch-to" (func $thread.switch-to (param i32) (result i32)))
+ (import "" "thread.suspend-to-suspended" (func $thread.suspend-to-suspended (param i32) (result i32)))
(import "" "thread.suspend" (func $thread.suspend (result i32)))
- (import "" "thread.resume-later" (func $thread.resume-later (param i32)))
- (import "" "thread.yield-to" (func $thread.yield-to (param i32) (result i32)))
+ (import "" "thread.unsuspend" (func $thread.unsuspend (param i32)))
+ (import "" "thread.yield-to-suspended" (func $thread.yield-to-suspended (param i32) (result i32)))
(func (export "noop"))
(func (export "trap-calling-thread-new-indirect") (call $thread.new-indirect (i32.const 0) (i32.const 0)) drop)
- (func (export "trap-calling-thread-switch-to") (call $thread.switch-to (i32.const 0)) drop)
+ (func (export "trap-calling-thread-suspend-to-suspended") (call $thread.suspend-to-suspended (i32.const 0)) drop)
(func (export "trap-calling-thread-suspend") (call $thread.suspend) drop)
- (func (export "trap-calling-thread-resume-later") (call $thread.resume-later (i32.const 0)))
- (func (export "trap-calling-thread-yield-to") (call $thread.yield-to (i32.const 0)) drop)
+ (func (export "trap-calling-thread-unsuspend") (call $thread.unsuspend (i32.const 0)))
+ (func (export "trap-calling-thread-yield-to-suspended") (call $thread.yield-to-suspended (i32.const 0)) drop)
)
(core instance $dm (instantiate $DM (with "" (instance
(export "thread.new-indirect" (func $thread.new-indirect))
- (export "thread.switch-to" (func $thread.switch-to))
+ (export "thread.suspend-to-suspended" (func $thread.suspend-to-suspended))
(export "thread.suspend" (func $thread.suspend))
- (export "thread.resume-later" (func $thread.resume-later))
- (export "thread.yield-to" (func $thread.yield-to))
+ (export "thread.unsuspend" (func $thread.unsuspend))
+ (export "thread.yield-to-suspended" (func $thread.yield-to-suspended))
))))
(func (export "trap-calling-thread-new-indirect")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-new-indirect"))))
- (func (export "trap-calling-thread-switch-to")
+ (func (export "trap-calling-thread-suspend-to-suspended")
(canon lift (core func $dm "noop")
- (post-return (func $dm "trap-calling-thread-switch-to"))))
+ (post-return (func $dm "trap-calling-thread-suspend-to-suspended"))))
(func (export "trap-calling-thread-suspend")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-suspend"))))
- (func (export "trap-calling-thread-resume-later")
+ (func (export "trap-calling-thread-unsuspend")
(canon lift (core func $dm "noop")
- (post-return (func $dm "trap-calling-thread-resume-later"))))
- (func (export "trap-calling-thread-yield-to")
+ (post-return (func $dm "trap-calling-thread-unsuspend"))))
+ (func (export "trap-calling-thread-yield-to-suspended")
(canon lift (core func $dm "noop")
- (post-return (func $dm "trap-calling-thread-yield-to"))))
+ (post-return (func $dm "trap-calling-thread-yield-to-suspended"))))
)
(component instance $i0 $Tester)
(assert_trap (invoke "trap-calling-thread-new-indirect") "cannot leave component instance")
(component instance $i1 $Tester)
-(assert_trap (invoke "trap-calling-thread-switch-to") "cannot leave component instance")
+(assert_trap (invoke "trap-calling-thread-suspend-to-suspended") "cannot leave component instance")
(component instance $i2 $Tester)
(assert_trap (invoke "trap-calling-thread-suspend") "cannot leave component instance")
(component instance $i3 $Tester)
-(assert_trap (invoke "trap-calling-thread-resume-later") "cannot leave component instance")
+(assert_trap (invoke "trap-calling-thread-unsuspend") "cannot leave component instance")
(component instance $i4 $Tester)
-(assert_trap (invoke "trap-calling-thread-yield-to") "cannot leave component instance")
+(assert_trap (invoke "trap-calling-thread-yield-to-suspended") "cannot leave component instance")