basvandijk opened issue #6636:
Feature
We're working on a Haskell binding to wasmtime called wasmtime-hs.
In our project we would like to have access to the Config::with_host_memory(...) functionality.
Could this function be provided in the C API?Benefit
At the moment this functionality is only available in the Rust library. It would be nice if other languages have access to the same functionality.
Implementation
Do you have an implementation plan, and/or ideas for data structures or
algorithms to use?Not yet, it probably has to look something like this but I haven't thought about it too much yet:
#[no_mangle] pub unsafe extern "C" fn wasmtime_config_with_host_memory( c: &mut wasm_config_t, mem_creator_callback: wasmtime_new_memory_callback_t, ) { c.config.with_host_memory(...); } pub type wasmtime_new_memory_callback_t = extern "C" fn( ty: &wasm_memorytype_t, minimum: u64, maximum_specified: bool, maximum: u64, reserved_size_in_bytes_specified: bool, reserved_size_in_bytes: u64, guard_size_in_bytes: bool, ) -> Box<dyn LinearMemory>
jameysharp labeled issue #6636:
Feature
We're working on a Haskell binding to wasmtime called wasmtime-hs.
In our project we would like to have access to the Config::with_host_memory(...) functionality.
Could this function be provided in the C API?Benefit
At the moment this functionality is only available in the Rust library. It would be nice if other languages have access to the same functionality.
Implementation
Do you have an implementation plan, and/or ideas for data structures or
algorithms to use?Not yet, it probably has to look something like this but I haven't thought about it too much yet:
#[no_mangle] pub unsafe extern "C" fn wasmtime_config_with_host_memory( c: &mut wasm_config_t, mem_creator_callback: wasmtime_new_memory_callback_t, ) { c.config.with_host_memory(...); } pub type wasmtime_new_memory_callback_t = extern "C" fn( ty: &wasm_memorytype_t, minimum: u64, maximum_specified: bool, maximum: u64, reserved_size_in_bytes_specified: bool, reserved_size_in_bytes: u64, guard_size_in_bytes: bool, ) -> Box<dyn LinearMemory>
jameysharp labeled issue #6636:
Feature
We're working on a Haskell binding to wasmtime called wasmtime-hs.
In our project we would like to have access to the Config::with_host_memory(...) functionality.
Could this function be provided in the C API?Benefit
At the moment this functionality is only available in the Rust library. It would be nice if other languages have access to the same functionality.
Implementation
Do you have an implementation plan, and/or ideas for data structures or
algorithms to use?Not yet, it probably has to look something like this but I haven't thought about it too much yet:
#[no_mangle] pub unsafe extern "C" fn wasmtime_config_with_host_memory( c: &mut wasm_config_t, mem_creator_callback: wasmtime_new_memory_callback_t, ) { c.config.with_host_memory(...); } pub type wasmtime_new_memory_callback_t = extern "C" fn( ty: &wasm_memorytype_t, minimum: u64, maximum_specified: bool, maximum: u64, reserved_size_in_bytes_specified: bool, reserved_size_in_bytes: u64, guard_size_in_bytes: bool, ) -> Box<dyn LinearMemory>
github-actions[bot] commented on issue #6636:
Label Messager: wasmtime:config
It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:
[ ] If you added a new
Config
method, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
Short, simple summary sentence.More details. These details can be multiple paragraphs. There should be
information about not just the method, but its parameters and results as
well.Is this method fallible? If so, when can it return an error?
Can this method panic? If so, when does it panic?
Example
Optional example here.
```</details>
[ ] If you added a new
Config
method, or modified an existing one, you
ensured that this configuration is exercised by the fuzz targets.<details>
For example, if you expose a new strategy for allocating the next instance
slot inside the pooling allocator, you should ensure that at least one of our
fuzz targets exercises that new strategy.Often, all that is required of you is to ensure that there is a knob for this
configuration option in [wasmtime_fuzzing::Config
][fuzzing-config] (or one
of its nestedstruct
s).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</details>
[ ] If you are enabling a configuration option by default, make sure that it
has been fuzzed for at least two weeks before turning it on by default.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
jameysharp commented on issue #6636:
This sounds reasonable to me but I'm not sure what design principles we're following for Wasmtime's C API, so I'd like to get opinions from @alexcrichton or @fitzgen on what this should look like.
Huh, maybe I shouldn't have used the
wasmtime:config
label. I wasn't expecting that particular auto-reply.
alexcrichton commented on issue #6636:
This was discussed a bit on Zulip as well and my strawman there was:
typedef wasmtime_error_t *(*wasmtime_new_memory_t)( wasm_memorytype_t *ty, size_t minimum, size_t maximum, size_t reserved_size_in_bytes, size_t guard_size_in_bytes, void **ret); typedef void *(*wasmtime_memory_get_t)( void *ptr, size_t *byte_size, size_t *maximum_byte_size); typedef wasmtime_error_t *(*wasmtime_memory_grow_t)( void *ptr, size_t new_size); typedef struct { wasmtime_new_memory_t new_memory; wasmtime_memory_get_t get_memory; wasmtime_memory_grow_t grow_memory; } wasmtime_memory_creator_t; void wasmtime_config_memory_creator_set(wasmtime_config_t *config, wasmtime_memory_creator_t *creator);
Personally I don't think the details matter too too much so long as it all works for your use case, we can always iterate over time as necessary.
Note though that in the original suggestion an
extern "C" fn
can't returnBox<dyn LinearMemory>
because that's a Rust-defined structure which C can't mirror, so you'll need to package up those callbacks in addition to thewasmtime_new_memory_callback_t
type
basvandijk commented on issue #6636:
@alexcrichton thanks, I wasn't aware of that chat by my colleague :). But your strawman looks like a great start!
alexcrichton closed issue #6636:
Feature
We're working on a Haskell binding to wasmtime called wasmtime-hs.
In our project we would like to have access to the Config::with_host_memory(...) functionality.
Could this function be provided in the C API?Benefit
At the moment this functionality is only available in the Rust library. It would be nice if other languages have access to the same functionality.
Implementation
Do you have an implementation plan, and/or ideas for data structures or
algorithms to use?Not yet, it probably has to look something like this but I haven't thought about it too much yet:
#[no_mangle] pub unsafe extern "C" fn wasmtime_config_with_host_memory( c: &mut wasm_config_t, mem_creator_callback: wasmtime_new_memory_callback_t, ) { c.config.with_host_memory(...); } pub type wasmtime_new_memory_callback_t = extern "C" fn( ty: &wasm_memorytype_t, minimum: u64, maximum_specified: bool, maximum: u64, reserved_size_in_bytes_specified: bool, reserved_size_in_bytes: u64, guard_size_in_bytes: bool, ) -> Box<dyn LinearMemory>
Last updated: Nov 22 2024 at 16:03 UTC