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
andinstance.rs
?As I'm digging through the code I had a few questions:
- are
local
anddefined
memories the same thing?- given a memory index, can we reliably/cheaply say if it's
local
/defined
orimported
?Using just the
memory_grow
as an example, the general idea I have is we take theu32
index, find the corresponding vm "instance", and grow the memory for that particular instance -- does that sound right?
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 aDefinedMemoryIndex
(you'll need to updatefunc_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 aMemoryIndex
(note the lack ofDefined
) and the implementation of that would probably be to just inline the two intrinsic implementations that are present inlibcalls.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.
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