I can explain how we do this in the CACAO VM (JVM JIT study). First, the machine code for the method is generated in some block of memory allocated by the heap. After compilation, the final code length is known, and a fragment of executable memory is allocated using the mmap and PROT_EXEC (the corresponding CACAO code is here ). Then the machine code is copied to the mmapped area. After this, many architectures require some mechanism to clear the machineโs cache. As an example, consider the cache clear function for PowerPC 64. It is noteworthy that there is nothing to do on the i386 and x86_64. After this step, the processor is ready to execute the newly generated code. Alternatively, already allocated memory pages can be marked as executable with mprotect . Note that mmap / mprotect are Unix objects.
Ringding
source share