How to generate and run native code dynamically?

前端 未结 7 573
死守一世寂寞
死守一世寂寞 2020-12-04 08:33

I\'d like to write a very small proof-of-concept JIT compiler for a toy language processor I\'ve written (purely academic), but I\'m having some trouble in the middle-altitu

7条回答
  •  囚心锁ツ
    2020-12-04 09:21

    In addition to the techniques suggested so far, it might be worthwhile to look into the thread creation functions. If you create a new thread, with the starting address set to your generated code, you know for sure that there are no old registers that need saving or restoring, and the OS handles the setup of the relevant registers for you. I.e you eliminate steps 3, 4 and 6 of your list.

提交回复
热议问题