You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update RFC to remove InstanceAllocator from the wasmtime crate.
Remove the `InstanceAllocator` trait and the `DefaultInstanceAllocator` struct
from the `wasmtime` crate.
Add the `InstanceAllocationStrategy` enum and update the related `Config`
method.
@@ -287,12 +287,6 @@ Page faults will be handled according to where they occur in the memory managed
287
287
288
288
Implementations for other platforms, such as Windows, might be required in the future.
289
289
290
-
### The `InstanceHandle` struct
291
-
292
-
The existing `InstanceHandle` structure will be modified to notify the allocator when an instance is deallocated via `InstanceHandle::dealloc`.
293
-
294
-
This will enable the pooling allocator to "free" the instance by adding it (and its associated resources) to a free list rather than actually deallocating any memory.
295
-
296
290
### The `Instance` struct
297
291
298
292
To minimize allocations, `Instance` will be modified to use `Vec` instead of boxed slices for storing the instance's lists of memories and tables. This will allow the pooling allocator to reuse capacity from previous instance allocations as needed.
@@ -305,101 +299,73 @@ Additional changes are required to enable storing the instance's tables in the m
305
299
306
300
## Changes to the `wasmtime` crate
307
301
308
-
### The `InstanceAllocator` trait
309
-
310
-
This trait is nearly identical to the trait in the runtime, except it only uses public Wasmtime API types:
311
-
312
-
```rust
313
-
// Represents an instance allocator.
314
-
pubtraitInstanceAllocator:Send+Sync {
315
-
/// Allocates an instance for the given module.
316
-
fnallocate(
317
-
&self,
318
-
store:&Store,
319
-
module:&Module,
320
-
imports:&[Extern],
321
-
) ->Result<Instance>;
322
-
}
323
-
```
324
-
325
-
Note that here `Instance` is the public type from the `wasmtime` crate.
326
-
327
-
### The `DefaultInstanceAllocator` struct
328
-
329
-
This struct is nearly identical to the struct of the same name in the runtime, except it only uses public Wasmtime API types:
The implementation of this type will wrap the runtime's default instance allocator and perform the necessary translation from the public Wasmtime API types to the runtime types.
344
-
345
-
### The `PoolingInstanceAllocator` struct
302
+
### The `userfault` feature
346
303
347
-
This struct is nearly identical to the struct of the same name in the runtime, except it only uses public Wasmtime API types:
304
+
This feature will forward to the runtime's `userfault` feature to enable userfault handling in the runtime's pooling instance allocator.
348
305
306
+
### The `InstanceAllocationStrategy` enumeration
349
307
```rust
350
-
// Represents a pooling instance allocator.
351
-
pubstructPoolingInstanceAllocator { ... }
352
-
353
-
implPoolingInstanceAllocator {
354
-
/// Creates a new pooling instance allocator with the given strategy and limits.
Here `PoolingAllocStrategy` and `PoolingLimits` are re-exports from `wasmtime_runtime`.
362
-
363
-
The implementation of this type will wrap the runtime's pooling instance allocator and perform the necessary translation from the public Wasmtime API types to the runtime types.
364
-
365
-
### The `userfault` feature
366
-
367
-
This feature will forward to the runtime's `userfault` feature to enable userfault handling in the runtime's pooling instance allocator.
368
-
369
330
### The `Config` struct
370
331
371
-
This proposal adds the following method to `Config`:
332
+
This proposal adds the following method to `Config` for setting the instance allocation strategy to use:
All module instances created from the configuration will use the given strategy.
343
+
378
344
### The `MemoryCreator` trait
379
345
380
346
Today, users can implement the `MemoryCreator` trait to control how linear memories are allocated when Wasmtime instantiates a module or a user creates a host `Memory` object.
381
347
382
348
To enable custom host memory management, users call `with_host_memory` on the `Config` used to create an `Engine`. For backwards compatibility, this interface will not change.
383
349
384
-
However, the `with_host_memory` implementation will change to configure the "default" allocator associated with the configuration. The default allocator will be used for instance creation if `with_instance_allocator` is never called and for instantiation of any host objects (memories, globals, tables, and functions).
350
+
Only the default instance allocation strategy will use memory creator for creating linear memories for new module instances.
385
351
386
-
This allows for host `Memory` objects to use the configured memory creator and also prevents instances created internally by Wasmtime when representing host objects from counting towards any instance allocator limits.
352
+
Host `Memory` objects will continue to use the given memory creator for allocating memory.
387
353
388
354
### Re-exported types
389
355
390
356
The following types will be re-exported from `wasmtime_runtime`:
0 commit comments