mmcloughlin / avo

Generate x86 Assembly with Go
BSD 3-Clause "New" or "Revised" License
2.7k stars 89 forks source link

proposal: use avo to build in memory code that can be called directly (eg JIT) #66

Open ncw opened 5 years ago

ncw commented 5 years ago

I'd like to be able to use avo to generate code from a go program into memory which I can call directly from the same program. Think implementing a JIT for instance.

Could that be possible one day?

mmcloughlin commented 5 years ago

Yes avo could certainly be extended to support this use case.

At the moment the instruction database doesn't have the instruction encodings in it, but that information is present in the Opcodes database I started with. So I could augment the instruction database and then implement an assembler in avo. (See #23 for more on the instruction database.)

By the way, have you seen https://github.com/twitchyliquid64/golang-asm ? It might also be possible to pursue a similar approach in avo.

I was certainly aware of this use case (asmjit and PeachPy support it) but it wasn't my priority. It's still not something I intend to work on in the short term, but I'll keep this issue open and hopefully I'll have time one of these days :)

duncanpierce commented 3 months ago

It would be great to have a JIT option in Avo. Meanwhile, this could be a useful alternative: https://github.com/bspaans/jit-compiler