This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Commit 88dd50b
big Store->ComponentInstance refactor (#87)
* Enable async support in wast tests
This commit updates the `wasmtime-wast` crate to conditionally use the
`Config::async_support` mode of Wasmtime, notably executing
`instantiate_async` and `call_async`. At this time no actual concurrency
is supported and everything is immediately await'd on via `block_on` and
a local single-thread tokio runtime.
The motivation for this commit is that in the upcoming implementation of
WASIp3 async will effectively be the only way to invoke components.
Furthermore to test these components we're wanting to use async APIs as
the root of invocations for writing `*.wast` tests for testing
component-model async features.
In enabling this support this commit additionally updates the
`wast_tests` fuzzer to execute all tests both with and without async.
Effectively the async configuration is now a fuzz option, meaning that
all tests are being executed with async now as well to ensure that they
work (yay!).
The `--test wast` testing mode and `wasmtime wast` CLI command are both
updated to unconditionally use async. There should be no loss in test
coverage due to the fuzzer update, and right now knobs aren't provided
to conditionally use sync in these two modes, again because it's
currently expected that this won't be able to run component model async
tests, so the defaults are changing.
* big Store->ComponentInstance refactor
Previously, I had put a `ConcurrentState` field in `StoreInner`, not realizing
that it actually belonged in `ComponentInstance` instead. Only when Alex opened
serially) by several `ComponentInstance`s, meaning that the state I had put in
`StoreInner` was being reused by multiple instances, with chaotic results.
This moves the state to `ComponentInstance`, which required changing a _lot_ of
code that assumed it could get everything it needed from a `StoreContextMut`.
In the process of all these changes, I was able to remove a lot of type
parameters from functions which never really needed the `T` in
`StoreContextMut<T>` anyway, which means the compiler doesn't need to do as much
monomorphization anymore.
Other notable changes:
- `Linker::func_{wrap|new}_concurrent` no longer need `Sync` futures, and now
they take an `Accessor`, providing the same ergonomic advantages as
`wasmtime-wit-bindgen`-generated code offers.
- I've changed the `{Future|Stream}{Writer|Reader}::watch_{writer|reader}`
return value to make it easier to use and cancel.
- You now need a `component::Instance` to create a future or a stream. You can
get that from within host functions using `Accessor::instance` or
`Access::instance`. And in top-level embedder code, you can get it using
`{Linker|InstancePre}::instantiate_async`.
- Note that `wasmtime-wit-bindgen`-generated instantiation code tends to
hide the `component::Instance` from you, but you can still get it by
calling e.g. `Linker::instantiate_async` directly and then passing the
result to the appropriate `new` function in the generated bindings. See
the tests for examples.
Fixes #30
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>1 parent bf0d3ec commit 88dd50b
65 files changed
Lines changed: 9692 additions & 7426 deletions
File tree
- crates
- component-macro/tests/expanded
- fuzzing/src
- generators
- misc/component-async-tests
- http/src
- src
- tests/scenario
- wasi/src/p3
- cli
- filesystem
- sockets/host/types
- wasmtime/src/runtime
- component
- concurrent
- func
- store
- vm
- component
- wast
- src
- wit-bindgen/src
- fuzz/fuzz_targets
- src/commands
- tests
- all/component_model
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 54 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
| |||
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
274 | | - | |
| 275 | + | |
| 276 | + | |
275 | 277 | | |
| 278 | + | |
276 | 279 | | |
277 | 280 | | |
278 | 281 | | |
| |||
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
| 290 | + | |
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
| |||
325 | 329 | | |
326 | 330 | | |
327 | 331 | | |
328 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
329 | 336 | | |
330 | 337 | | |
331 | 338 | | |
332 | 339 | | |
333 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
334 | 345 | | |
335 | 346 | | |
336 | 347 | | |
337 | 348 | | |
338 | 349 | | |
339 | 350 | | |
340 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
341 | 358 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
348 | 368 | | |
349 | 369 | | |
350 | 370 | | |
351 | 371 | | |
352 | 372 | | |
353 | | - | |
| 373 | + | |
354 | 374 | | |
355 | 375 | | |
356 | 376 | | |
357 | 377 | | |
358 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
359 | 383 | | |
360 | 384 | | |
361 | 385 | | |
362 | 386 | | |
363 | 387 | | |
364 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
365 | 395 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
372 | 405 | | |
373 | 406 | | |
374 | 407 | | |
| |||
0 commit comments