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.
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.
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?
I don't think I'd need to change codegen, just get the information on the side
The tricky part is that import resolution isn't normally performed until instantiation time, which is after Cranelift has run.
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.
So, we could have a mode where we tell Cranelift it can assume that some APIs won't be interoposed if we needed to.
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
Those addresses aren't computed until instantiation time.
that's fine, would just want them before the code is run
Ah, ok. See resolve_imports
in crates/jit/src/imports.rs
Oh, looks like it has the address and signature there, nice!
Oh wait, these imports could be from other wasm modules, right?
Yes
I guess I could collect all the addresses and try work out the address of all wasm functions, and remove them from that set
Can you say more about your use case?
I'll PM you
Hi there, would anybody check issue#2578?
https://github.com/bytecodealliance/wasmtime/issues/2578
Is there any example of converting a fn
with &[Val]
as parameters into a Func
?
@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