What is the best way to do jit in golang

66 views
Skip to first unread message

kant kodali

unread,
Jun 21, 2024, 10:17:54 AM (12 days ago) Jun 21
to golang-dev

Hi All,

What is the best way to do jit in golang? Is there anything native to go? I see golang-asm but this means I need to worry optimizations like loop unrolling, escape analysis etc. looking for some high level framework other than say LLVM. LLVM is great but I am trying to avoid making c calls from golang.

Thanks

Sent from my iPhone

Jorropo

unread,
Jun 21, 2024, 10:29:12 AM (12 days ago) Jun 21
to kant kodali, golang-dev
There isn't a good short answer beyond you can take a look at https://github.com/tetratelabs/wazero and how they do thing.

Loop unrolling, escape analysis and other things like this are solved like in any other JIT, you have some internal representation, optimize it, lower it, assemble it into memory, make the pages executable, and jump to your inmemory machinecode. There are vast amounts of details glossed over, but these would be the same problems if you wrote your JIT in C, Python or anything.
The only Go related problem is how do you actually run the machine code once it's loaded in memory. I would take a look at how wazero handles this as they must already solve this problem. You could handle this by writing assembly, spawning another OS thread, ...

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/FDB51BA1-82AE-4E4D-B4BC-F3F6174B47C5%40gmail.com.
Reply all
Reply to author
Forward
0 new messages