Hacker News new | ask | show | jobs
by hoten 88 days ago
I used asmjit to implement JIT compilation. Highly recommend it.

Maybe you'll find the resources I link to in the documentation for my project helpful.

https://github.com/ZQuestClassic/ZQuestClassic/blob/main/doc...

Or perhaps you'd find reviewing my usage of asmjit helpful:

https://github.com/ZQuestClassic/ZQuestClassic/blob/main/src...

My main high-level advice would be to have an extensive set of behavioral tests (lots of scripts with assertions on the output). This helps ensure correctness when you flip on your JIT compilation.

You'll eventually run into hard to diagnose bugs - so be able to conditionally JIT parts of your code (per-function control - or even better, per-basic block) to help narrow down problem areas.

The other debugging trick I did was spit out the full state of the runtime after every instruction, and ensure that the same state is seen after every instruction even w/ JIT enabled.

Good luck!