Stream: cranelift

Topic: Examples for structs and a heap in cranelift


view this post on Zulip Terts Diepraam (May 04 2024 at 10:38):

Hi!
I'd like to add structs and a heap-like thing to my little language that uses cranelift, but I'm a bit lost on how to represent those in cranelift. I understand that cranelift doesn't really provide that out of the box and that I need to implement that myself, but I was hoping to find some example out there somewhere. Do you know of any example languages that do anything like this?

view this post on Zulip Terts Diepraam (May 04 2024 at 13:10):

I think I found a way to do structs via StackSlots in the meantime :)

view this post on Zulip bjorn3 (May 04 2024 at 17:22):

You can call into the native malloc to allocate memory on the heap. For as long as you are not doing GC that should be enough.

view this post on Zulip Terts Diepraam (May 05 2024 at 07:00):

Interesting approach. I don't think that works for my use case specifically, but it has got me thinking about FFI to solve the issue. Thanks!


Last updated: Oct 23 2024 at 20:03 UTC