I would like to use Cranelift as baseline JIT and instead of placing VM registers on heap allocated stack I would like to use real registers and machine stack, but I can't find any information/tutorial/documentation on how to use stackmaps in cranelift, is there any information?
P.S My languge is dynamically typed and uses nan-boxing so I need to place all values to stackmap and VM Value can be stored in just I64 on both 32 bit and 64 bit machines
This topic was moved here from #general > Stackmap and GC roots by Till Schneidereit
(I moved this for more visibility to Cranelift folks)
@playX does https://github.com/bytecodealliance/wasmtime/pull/1832 help, by any chance?
@Till Schneidereit helps a litte, but there is no good explanation on how to use these stackmaps, how to get them e.g with SimpleJITBackend and Idk where and when I should use reference type vs just i32/i64
@fitzgen (he/him) might be able to answer some of this, but it seems plausible that for now using this does require digging into the code quite a bit
@playX, I recently landed a PR that improved the docs for Stackmap
a bit and cleared up questions that I had when implementing their integration into Wasmtime: https://github.com/bytecodealliance/wasmtime/pull/1824/files#diff-97dbc08ed429dd9faefe70055a6c2009
Note that Cranelift's stack map support assumes that references are pointer-sized, so using r64
on 32-bit architectures won't work right now.
@playX ^
This documentation is cool but still does not show any example code, maybe it's worth adding some examples on how to use it and how to get frame pointers etc.
to get the stack pointers, you need to use something like libunwind
to walk the stack, or your own stack walker
there is a WIP pr to add SP support to the backtrace
crate here: https://github.com/rust-lang/backtrace-rs/pull/341
@fitzgen (he/him) I'll probably go with conservative on stack GC right now because in my project roots might be located anywhere, but for JITed functions when I'll learn more about stackmaps I'll use them :)
Last updated: Nov 22 2024 at 16:03 UTC