Stream: cranelift

Topic: Are there any plans for variadic calling convention?


view this post on Zulip Adel Prokurov (Oct 09 2024 at 04:37):

Hello! Is there any plans for callconv that allows passing variable number of arguments and also receiving argument count on callee side? This is a must-have when making a Scheme implementation. At the moment I am having runstack which is stored in per-thread storage and I push/pop arguments there and store TLS in pinned reg but it seems like not the best solution

view this post on Zulip Adel Prokurov (Oct 09 2024 at 05:32):

UPD: I've tested doing return_call_indirect with 32 arguments to a function which accepts 24 arguments and it seems like it works and runs properly? The computation result does not change so stack is not broken and Rust code runs fine after function returns. How unsafe is this way of doing calls?

view this post on Zulip Chris Fallin (Oct 09 2024 at 07:00):

We don’t support variadic ABIs directly (PRs welcome) but in various places where we need a dynamic number of args eg in wasmtime at hostcall boundaries we emulate it by building an arg array in memory. I wouldn’t recommend calling a function with a statically incorrect signature — that’s undefined behavior even if it happens to work by luck in some cases


Last updated: Nov 22 2024 at 17:03 UTC