Stream: general

Topic: host-calls


view this post on Zulip Joey Gouly (Mar 12 2020 at 10:40):

With WASI, some calls from wasm will end up running non-wasm code, right? Is it possible to know from the cranelift side, which of the calls those will be? I guess that the RelocationSink might be able to give that info? I think I'd also need to know the signature of the function too.

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:17):

While it's theoretically possible to specialize calls to known imports like WASI, right now we don't, so all calls to wasm imports look the same from Cranelift's perspective.

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:26):

Dan Gohman said:

While it's theoretically possible to specialize calls to known imports like WASI, right now we don't, so all calls to wasm imports look the same from Cranelift's perspective.

Do you know what kind of steps it would take? Would there need to be changes in cranelift? Or just in wasmtime?

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:27):

I don't think I'd need to change codegen, just get the information on the side

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:29):

The tricky part is that import resolution isn't normally performed until instantiation time, which is after Cranelift has run.

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:31):

And while the end-user side of this is still being worked on, at the engine level, imports to functions with WASI names could be interoposed by other wasm modules.

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:34):

So, we could have a mode where we tell Cranelift it can assume that some APIs won't be interoposed if we needed to.

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:34):

The goal would be a list of function addresses and signatures that are not wasm compiled code, I don't really care if it's a wasi function or not

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:35):

Those addresses aren't computed until instantiation time.

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:35):

that's fine, would just want them before the code is run

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:37):

Ah, ok. See resolve_imports in crates/jit/src/imports.rs

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:40):

Oh, looks like it has the address and signature there, nice!

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:41):

Oh wait, these imports could be from other wasm modules, right?

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:41):

Yes

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:42):

I guess I could collect all the addresses and try work out the address of all wasm functions, and remove them from that set

view this post on Zulip Dan Gohman (Mar 12 2020 at 13:44):

Can you say more about your use case?

view this post on Zulip Joey Gouly (Mar 12 2020 at 13:44):

I'll PM you

view this post on Zulip clearloop (Jan 13 2021 at 14:41):

Hi there, would anybody check issue#2578?

https://github.com/bytecodealliance/wasmtime/issues/2578

Desc Here I'm trying to define the HostFuncType<T> below as extern functions in wasmtime, but I don't know how to handle the &mut T pub type HostFuncType<T> = fn(&mut T,...

view this post on Zulip clearloop (Jan 14 2021 at 04:10):

Is there any example of converting a fn with &[Val] as parameters into a Func?

view this post on Zulip fitzgen (he/him) (Jan 19 2021 at 18:55):

@clearloop https://docs.rs/wasmtime/0.21.0/wasmtime/struct.Func.html#method.new should do the trick


Last updated: Nov 22 2024 at 16:03 UTC