@fitzgen (he/him) filling out some Go bindings I found an issue where Func::new
will panic if it's created with externef types and the Config
doesn't have reference types enabled
I'm a bit stuck thinking about this, though, as I'm not entirely sure how best to handle this
the problem is that the trampoline generated by the wasmtime
crate is attempting to use stack maps but cranelift's stack map support is not enabled so the register allocator naturally panics (as expected)
I think we may want to avoid stack maps entirely for trampolines? I don't think they actually serve any purpose
Can we assert in Func::new
et al that reference types are enabled in the config if they're being used?
that would at least be something we could document and have good assertion messages for
hm so an assert isn't quite what would work for the bindings though
wasm_func_new
panicking brings down the process most of the time
(that's what's happening right now)
I guess we would have to duplicate the check in a wasmtime_func_new
:-/
yay for wasmtime_
prefixed functions
I think you are technically correct that the trampolines don't need stack maps, but it is fairly subtle.
we could do some nasty r64
-> i64
hacks
that's what I'm thinking yeah
make it always work basically
definitely not worth it as a perf optimization, but to work around this issue, maybe
or alternatively
we can always enable reference types in the trampolines
that feels safer to me
yeah that was my other thought
I'll see if I can do that I think
cool, let me know how it goes
maybe we could have caught this if we extended the API call fuzzer
with reference types and instructions to create funcs
I wish the API call fuzzer was easier to extend, it is a little bit of a pain with all the scope stuff
ok well that at least removes the panics
seems fine for now!
I have no idea if stack maps from trampolines even make their way into the Store
I feel like our management of trampolines is very ad-hoc
https://github.com/bytecodealliance/wasmtime/pull/2039
I think they will make their way into the store's stack map registry, I vaguely remember a common code path here
Last updated: Dec 23 2024 at 13:07 UTC