Stream: wasmtime

Topic: pre-generating trampolines


view this post on Zulip Alex Crichton (Mar 11 2020 at 18:47):

@Dan Gohman mind if I ping you again on https://github.com/bytecodealliance/wasmtime/pull/957? If you're busy also no worries! I can tag in someone else to review

The wasmtime crate supports calling arbitrary function signatures in wasm code, and to do this it generates "trampoline functions" which have a known ABI that then internally convert to a...

view this post on Zulip Dan Gohman (Mar 11 2020 at 18:47):

Ah, thanks for the ping! I can take a look.

view this post on Zulip Dan Gohman (Mar 11 2020 at 20:01):

https://github.com/alexcrichton/wasmtime/pull/25 is a PR for your PR ;-). I set out to just see what breaks if I removed the Arc but then happened to find a way to make it not break.

This avoids the need for storing it in an Arc.

view this post on Zulip Alex Crichton (Mar 11 2020 at 20:02):

oh nice, I'm a fan :)

view this post on Zulip Dan Gohman (Mar 11 2020 at 20:09):

/me is really dubious of as converting from a raw pointer to a smaller integer.

view this post on Zulip Dan Gohman (Mar 11 2020 at 20:30):

Do I understand correctly that with this PR, the trampolines are part of the code that is cached? So that in the cache-hit case, we don't have to generate a trampoline on the fly?

view this post on Zulip Alex Crichton (Mar 11 2020 at 20:39):

@Dan Gohman we'd generate a trampoline per-module

view this post on Zulip Alex Crichton (Mar 11 2020 at 20:39):

and per-Func::new

view this post on Zulip Alex Crichton (Mar 11 2020 at 20:39):

so there's no caching across modules

view this post on Zulip Dan Gohman (Mar 11 2020 at 20:46):

for the per-module ones though, those are cached along with their modules, right?

view this post on Zulip Alex Crichton (Mar 11 2020 at 20:59):

@Dan Gohman correct yeah, it's all part of the same CodeMemory allocation

view this post on Zulip Alex Crichton (Mar 11 2020 at 21:00):

the module's functions are all precisely known in their size, and the trampolines are a little more dynamic, but it's all allocated in one chunk before publishing

view this post on Zulip Alex Crichton (Mar 11 2020 at 21:00):

publishing being switching to W^X

view this post on Zulip Alex Crichton (Mar 11 2020 at 21:00):

er, executable

view this post on Zulip Dan Gohman (Mar 11 2020 at 21:03):

Ok. The PR looks good to me, other than the pointer issue we discussed above.

view this post on Zulip Alex Crichton (Mar 11 2020 at 21:11):

@Dan Gohman ok thanks! mind leaving a comment to that effect?

view this post on Zulip Dan Gohman (Mar 11 2020 at 21:11):

sure


Last updated: Dec 23 2024 at 13:07 UTC