Stream: cranelift

Topic: Generating stack maps?


view this post on Zulip osa1 (May 16 2020 at 13:01):

I can't find how to generate and use stack maps. Does anyone have any examples?

view this post on Zulip bjorn3 (May 16 2020 at 13:25):

You first need to set the enable_safepoints flag when creating the TargetIsa. To then get the stackmap you can't use cranelift-simplejit, cranelift-faerie or cranelift-object, as they don't have support for it. Instead you have manually call context.compile_and_emitand pass a StackmapSink. This does mean that you will have to do everything from allocating memory (for a jit) / writing an object file (for aot compilation) to handling all relocations. It is probably easier to add stackmap support to cranelift-simplejit, cranelift-faerie or cranelift-object.

view this post on Zulip osa1 (May 16 2020 at 15:22):

Hmm, this is unfortunate.. Is there an open issue about adding stack maps to cranelift-object? Perhaps I can help with that.

view this post on Zulip osa1 (May 16 2020 at 15:24):

Is there any other way (even if hacky) to get live variables from cranelift backend somehow?

view this post on Zulip bjorn3 (May 16 2020 at 16:31):

osa1 said:

Hmm, this is unfortunate.. Is there an open issue about adding stack maps to cranelift-object? Perhaps I can help with that.

Not that I know.

view this post on Zulip bjorn3 (May 16 2020 at 16:31):

osa1 said:

Is there any other way (even if hacky) to get live variables from cranelift backend somehow?

What do you need it for?

view this post on Zulip osa1 (May 16 2020 at 16:35):

Garbage collection

view this post on Zulip osa1 (May 16 2020 at 17:53):

Does any of the backends have stack map support currently? Which one(s)?

view this post on Zulip osa1 (May 16 2020 at 17:58):

How do wasm people do GC?

view this post on Zulip bjorn3 (May 16 2020 at 18:46):

Wasmtime doesn't use the cranelift-module interface at all. Instead it uses context.compile_and_emit. Also Wasmtime doesn't have GC support yet. The current stackmap implementation is basically only used by the (disabled by default) Cranelift based WASM backend for Spidermonkey (js engine of firefox)

view this post on Zulip osa1 (May 16 2020 at 18:47):

Thanks @bjorn3 . How hard do you think it would be to implement stackmap support to cranelift-module/cranelift-object? Also, do you think it would be merged if implemented?

view this post on Zulip osa1 (May 16 2020 at 18:48):

I'm only a user now, but I may have some time next week to work on this

view this post on Zulip bjorn3 (May 16 2020 at 18:50):

module.define_function already takes a TrapSink argument. A new StackmapSink would work, but maybe both should be bundled together into one argument to avoid having many arguments. (others may have another opinion about this) I think this will likely be merged given that TrapSink is already an argument.

view this post on Zulip osa1 (May 16 2020 at 18:51):

I have no idea what TrapSink is ... where do I start reading if I wanted to implement this?

view this post on Zulip bjorn3 (May 16 2020 at 18:54):

Both TrapSink and StackmapSink are defined in cranelift_codegen::binemit. TrapSink basically records for every instruction that can trap the position and what the trap code is.

view this post on Zulip osa1 (May 16 2020 at 19:02):

So just to make sure I get this right, currently cranlift correctly calls add_stackmap, but we don't have a StackmapSink implementation other than the null one for the object code backend?

view this post on Zulip bjorn3 (May 16 2020 at 20:40):

Yes


Last updated: Dec 23 2024 at 12:05 UTC