Stream: cranelift

Topic: Recommended way to expose user stackmaps in AOT compiler.


view this post on Zulip Floppy (May 17 2026 at 01:28):

I'm testing out hooking up mmtk to a Cranelift generated program in a minimal example, mainly to learn how it works and figure out how I'm later gonna do it in my actual compiler.

My current understanding is that you retreive the full stackmap information at compile-time from MachBufferFinalized::user_stack_maps and then decide yourself how to re-format that data into your own data structures to be made available at runtime for then invoking the garbage collector with. However; Storing this information directly as-given (&[(CodeOffset, Span, Vec<PointerSize, SpOffset>)]) doesn't seem viable as finding the correct associated offsets from an InstBuilder::get_stack_pointer would require some sort of linear scan at runtime. Is there some "intended" way to use this information?

Here's some half-baked ideas I'm considering.

Would love some pointers on this, or some clarification on what end-result was invisioned when designing the stackmaps API.

I am planning on trying to add this to the cranelift-examples repository.

view this post on Zulip fitzgen (he/him) (May 18 2026 at 16:45):

@Floppy you can look at what Wasmtime does for inspiration:

Basically, it creates a custom object section with the stack map data in an easily index-able format that doesn't really require parsing at runtime and just does a binary search

view this post on Zulip Floppy (May 19 2026 at 02:43):

hm alright, i'll take a look thanks


Last updated: Jun 01 2026 at 09:49 UTC