Comment by kev_emu

4 years ago

I would be interested in your thoughts on using PochiVM as a means to add a dynamic re-compiling core for emulators. The emulator would identify hot code blocks, generate C like constructs (or ideally the AST) and use the 'Copy-and-Patch Compilation' algorithm to generate and execute the relevant machine code. The ability to call back to host methods, handle exception semantics and all the while being totally oblivious to the platform architecture that the machine code is produced for seems ideal for an emulator designed to run on multiple platforms.

Not sure what you mean by 'emulator', but I will assume you meant ISA for a different hardware architecture.

> The emulator would identify hot code blocks, generate C like constructs (or ideally the AST)

The idea behind copy-and-patch should be able to handle your use case of quickly translating code blocks in another ISA to native instructions.

However, I think Pochi's metaprogramming capabilities might not be too relevant here. After all, you are translating from a block of CPU instructions (in another ISA). It's probably not necessary or helpful to translate them back to C-like control flow only to compile them again.

> The ability to call back to host methods, handle exception semantics and all the while being totally oblivious to the platform

I'm not sure what you mean here. Yes Pochi supports intuitive inter-operation with the host program (call methods, handle exception etc). This is important for metaprogramming use case (e.g., generating a program that executes a SQL query), but I don't see what it has to do with emulating a program in another architecture.