Stream: git-wasmtime

Topic: wasmtime / Issue #2810 Consolidate local and imported mem...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2021 at 01:28):

rgrmrts commented on Issue #2810:

Thanks for the tip @alexcrichton, I spent a bit of time refactoring some bits and pieces but don't think I was going down the right path :) This is all new to me (rust and wasm) but I'm eager to get up and running and as such I appreciate the mentorship.

update the implementation of the existing intrinsics

Are the intrinsics defined in libcalls.rs and instance.rs?

As I'm digging through the code I had a few questions:

  1. are local and defined memories the same thing?
  2. given a memory index, can we reliably/cheaply say if it's local/defined or imported?

Using just the memory_grow as an example, the general idea I have is we take the u32 index, find the corresponding vm "instance", and grow the memory for that particular instance -- does that sound right?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2021 at 15:00):

alexcrichton commented on Issue #2810:

I think that you'll be modifying both libcalls.rs and instance.rs for a change like this. The idea was that the intrinsic (defined in libcalls.rs) would take a MemoryIndex instead of a DefinedMemoryIndex (you'll need to update func_environ.rs to have everything pass the full index, not just the defined index).

The API of the instance.rs functions can change to taking a MemoryIndex (note the lack of Defined) and the implementation of that would probably be to just inline the two intrinsic implementations that are present in libcalls.rs. We're effectively moving the "if" of whether it's imported or not from compile time to runtime (but the cost is thought to be quite small in these cases compared to the cost of the entire intrinsic).

Checking whether an index is defined or not is quite cheap, it's simply a comparison against the number of imported items.

FWIW I'm not around for a ton of mentor-ing on this, I'd recommend that you'd be prepared for code-diving yourself to figure things out. If not you may want to ask around to see if someone else is willing to help out.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2021 at 17:13):

rgrmrts commented on Issue #2810:

Sweet, okay -- jumping around the codebase I think I've got a decent idea of what's required here, and I appreciate the added info. I'll take another stab at this over the next few days.

And noted on availability, I _feel_ like your comments are already sufficient mentoring. Thanks for the tips!


Last updated: Nov 22 2024 at 17:03 UTC