logoalt Hacker News

sureglymoplast Tuesday at 9:43 PM1 replyview on HN

Only tangentially related, asking out of curiosity.

If one wanted to have a JIT compiler from what I understand it would essentially need to be able to get a chunk of memory, generate instructions into it and then jmp there.

Is creating such a thing possible in just Go?


Replies

ncruceslast Tuesday at 9:53 PM

Yes. You need some syscalls and unsafe, but it's possible.

wazero does this, on amd64 and arm64: https://github.com/wazero/wazero

You can read more about the approach - from the creator - here: https://mathetake.github.io/posts/runtime-code-generation-in...

show 1 reply