Stream: git-wasmtime

Topic: wasmtime / issue #10546 Virtaul Memory for Wiggle


view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2025 at 08:27):

Destructor17 opened issue #10546:

Wiggle's GuestMemory enum seem to be very limited.
Both Unshared and Shared cases are basically slices.
It is impossible to obtain slices to guest memory from such embedders as WebAssembly JS API or Wasmer.

I ran into this issue while making my own WebAssembly JS API based embedder.
I'd like to use Wiggle and wasi-common to implement wasip1 and wasi-threads as well as some additional apis, and share these implementations with implementation based Wasmtime.
But, since embedder's and guest's memories are different WebAssembly.Memory objects, existing GuestMemory doesn't cover my case.

Feature

It would be nice to see a third case in GuestMemory enum called Virtaul, Dynamic, or whatever.
This new case allows embedder to implementation memory operations such as reading, writing and checking memory size.
Embedder might implement memory operations using simple memcpy, invoking JavaScript code, IPC, or even network, who knows...

Benefit

I believe this improvement could allow Wiggle and wasi-common reach wider range of WebAssembly embedders.

Implementation

This improvement's implementation seem to be straightforward.
So I believe we just need to:

I already implemented this in my fork and it works just fine.

I am not sure, but adding third arm to frequently called matches may make imported function a bit slower even if this third case is not in use.

Alternatives

Since this improvement's benefits for Wasmtime itself are questionable, maybe it doesn't worth implementing at all.
Alternatively, it still can be implemented under feature flag.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2025 at 08:38):

Destructor17 commented on issue #10546:

I am willing to upstream my implementation of this feature, but I believe it worth some discussion, so I started from issue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2025 at 08:40):

Destructor17 edited issue #10546:

Wiggle's GuestMemory enum seem to be very limited.
Both Unshared and Shared cases are basically slices.
It is impossible to obtain slices to guest memory from such embedders as WebAssembly JS API or Wasmer.

I ran into this issue while making my own WebAssembly JS API based embedder.
I'd like to use Wiggle and wasi-common to implement wasip1 and wasi-threads as well as some additional apis, and share these implementations with implementation based on Wasmtime.
But, since embedder's and guest's memories are different WebAssembly.Memory objects, existing GuestMemory doesn't cover my case.

Feature

It would be nice to see a third case in GuestMemory enum called Virtaul, Dynamic, or whatever.
This new case allows embedder to implementation memory operations such as reading, writing and checking memory size.
Embedder might implement memory operations using simple memcpy, invoking JavaScript code, IPC, or even network, who knows...

Benefit

I believe this improvement could allow Wiggle and wasi-common reach wider range of WebAssembly embedders.

Implementation

This improvement's implementation seem to be straightforward.
So I believe we just need to:

I already implemented this in my fork and it works just fine.

I am not sure, but adding third arm to frequently called matches may make imported function a bit slower even if this third case is not in use.

Alternatives

Since this improvement's benefits for Wasmtime itself are questionable, maybe it doesn't worth implementing at all.
Alternatively, it still can be implemented under feature flag.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2025 at 14:42):

alexcrichton closed issue #10546:

Wiggle's GuestMemory enum seem to be very limited.
Both Unshared and Shared cases are basically slices.
It is impossible to obtain slices to guest memory from such embedders as WebAssembly JS API or Wasmer.

I ran into this issue while making my own WebAssembly JS API based embedder.
I'd like to use Wiggle and wasi-common to implement wasip1 and wasi-threads as well as some additional apis, and share these implementations with implementation based on Wasmtime.
But, since embedder's and guest's memories are different WebAssembly.Memory objects, existing GuestMemory doesn't cover my case.

Feature

It would be nice to see a third case in GuestMemory enum called Virtaul, Dynamic, or whatever.
This new case allows embedder to implementation memory operations such as reading, writing and checking memory size.
Embedder might implement memory operations using simple memcpy, invoking JavaScript code, IPC, or even network, who knows...

Benefit

I believe this improvement could allow Wiggle and wasi-common reach wider range of WebAssembly embedders.

Implementation

This improvement's implementation seem to be straightforward.
So I believe we just need to:

I already implemented this in my fork and it works just fine.

I am not sure, but adding third arm to frequently called matches may make imported function a bit slower even if this third case is not in use.

Alternatives

Since this improvement's benefits for Wasmtime itself are questionable, maybe it doesn't worth implementing at all.
Alternatively, it still can be implemented under feature flag.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2025 at 14:42):

alexcrichton commented on issue #10546:

Thanks for the report! Wiggle however is currently on "life support" in the sense that we're not seeking to develop it for broader audiences. You're welcome however to copy it out-of-tree and develop it in a fork, but we're no longer doing major development of it in-tree. It's only there for our current bindings and no more.


Last updated: Dec 06 2025 at 07:03 UTC