Commit e1f50aa
authored
Make table/memory creation async functions (#11470)
* Make core instance allocation an `async` function
This commit is a step in preparation for #11430, notably core instance
allocation, or `StoreOpaque::allocate_instance` is now an `async fn`.
This function does not actually use the `async`-ness just yet so it's a
noop from that point of view, but this propagates outwards to enough
locations that I wanted to split this off to make future changes more
digestable.
Notably some creation functions here such as making an `Instance`,
`Table`, or `Memory` are refactored internally to use this new `async`
function. Annotations of `assert_ready` or `one_poll` are used as
appropriate as well.
For reference this commit was benchmarked with our `instantiation.rs`
benchmark in the pooling allocator and shows no changes relative to the
original baseline from before-`async`-PRs.
* Make table/memory creation `async` functions
This commit is a large-ish refactor which is made possible by the many
previous refactorings to internals w.r.t. async-in-Wasmtime. The end
goal of this change is that table and memory allocation are both `async`
functions. Achieving this, however, required some refactoring to enable
it to work:
* To work with `Send` neither function can close over `dyn VMStore`.
This required changing their `Option<&mut dyn VMStore>` arugment to
`Option<&mut StoreResourceLimiter<'_>>`
* Somehow a `StoreResourceLimiter` needed to be acquired from an
`InstanceAllocationRequest`. Previously the store was stored here as
an unsafe raw pointer, but I've refactored this now so
`InstanceAllocationRequest` directly stores `&StoreOpaque` and
`Option<&mut StoreResourceLimiter>` meaning it's trivial to acquire
them. This additionally means no more `unsafe` access of the store
during instance allocation (yay!).
* Now-redundant fields of `InstanceAllocationRequest` were removed since
they can be safely inferred from `&StoreOpaque`. For example passing
around `&Tunables` is now all gone.
* Methods upwards from table/memory allocation to the
`InstanceAllocator` trait needed to be made `async`. This includes new
`#[async_trait]` methods for example.
* `StoreOpaque::ensure_gc_store` is now an `async` function. This
internally carries a new `unsafe` block carried over from before with
the raw point passed around in `InstanceAllocationRequest`. A future
PR will delete this `unsafe` block, it's just temporary.
I attempted a few times to split this PR up into separate commits but
everything is relatively intertwined here so this is the smallest
"atomic" unit I could manage to land these changes and refactorings.
* Shuffle `async-trait` dep
* Fix configured build1 parent ad8d55a commit e1f50aa
File tree
22 files changed
+313
-497
lines changed- crates/wasmtime
- src/runtime
- component
- externals
- store
- trampoline
- vm
- instance
- allocator
- pooling
- memory
- tests/all
22 files changed
+313
-497
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | 199 | | |
201 | 200 | | |
202 | 201 | | |
| |||
261 | 260 | | |
262 | 261 | | |
263 | 262 | | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
637 | | - | |
| 637 | + | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
717 | | - | |
| 717 | + | |
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
| |||
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
1000 | 1000 | | |
1001 | 1001 | | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
| 1002 | + | |
| 1003 | + | |
1015 | 1004 | | |
1016 | 1005 | | |
1017 | | - | |
| 1006 | + | |
1018 | 1007 | | |
1019 | 1008 | | |
1020 | 1009 | | |
1021 | 1010 | | |
1022 | 1011 | | |
1023 | 1012 | | |
1024 | | - | |
| 1013 | + | |
1025 | 1014 | | |
1026 | 1015 | | |
1027 | 1016 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 115 | + | |
122 | 116 | | |
123 | 117 | | |
124 | | - | |
125 | | - | |
| 118 | + | |
| 119 | + | |
126 | 120 | | |
127 | 121 | | |
128 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 246 | + | |
265 | 247 | | |
266 | 248 | | |
267 | 249 | | |
268 | 250 | | |
269 | 251 | | |
270 | 252 | | |
271 | | - | |
| 253 | + | |
272 | 254 | | |
273 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
274 | 267 | | |
275 | 268 | | |
276 | 269 | | |
277 | 270 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | 271 | | |
302 | 272 | | |
303 | 273 | | |
| |||
313 | 283 | | |
314 | 284 | | |
315 | 285 | | |
316 | | - | |
| 286 | + | |
317 | 287 | | |
318 | 288 | | |
319 | 289 | | |
| |||
325 | 295 | | |
326 | 296 | | |
327 | 297 | | |
328 | | - | |
| 298 | + | |
329 | 299 | | |
330 | 300 | | |
331 | 301 | | |
| |||
341 | 311 | | |
342 | 312 | | |
343 | 313 | | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
349 | 321 | | |
350 | 322 | | |
351 | 323 | | |
| |||
377 | 349 | | |
378 | 350 | | |
379 | 351 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 352 | + | |
398 | 353 | | |
399 | 354 | | |
400 | 355 | | |
| |||
905 | 860 | | |
906 | 861 | | |
907 | 862 | | |
908 | | - | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
909 | 867 | | |
910 | 868 | | |
911 | 869 | | |
| |||
935 | 893 | | |
936 | 894 | | |
937 | 895 | | |
938 | | - | |
| 896 | + | |
939 | 897 | | |
940 | 898 | | |
941 | 899 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
| 264 | + | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| |||
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 277 | + | |
282 | 278 | | |
283 | 279 | | |
284 | 280 | | |
285 | | - | |
286 | | - | |
| 281 | + | |
| 282 | + | |
287 | 283 | | |
288 | 284 | | |
289 | 285 | | |
| |||
1005 | 1001 | | |
1006 | 1002 | | |
1007 | 1003 | | |
1008 | | - | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
1009 | 1008 | | |
1010 | 1009 | | |
1011 | 1010 | | |
| |||
0 commit comments