How JIT Compilers Operate

一曲冷凌霜 提交于 2019-12-06 08:19:31

问题


JIT compilers, by definition, generate code on the fly for execution. But in, say, Windows, we have all kinds of protection that prevent self modifying code or executing from data memory (DEP).

So how is it possible for JIT compilers to generate code on the fly?


回答1:


They ask the OS for some memory which is readable, writeable and executable.

e.g. you can allocate such memory using mmap() with PROT_READ | PROT_WRITE | PROT_EXEC (POSIX), or VirtualAlloc() with PAGE_EXECUTE_READWRITE (Windows).

For a real example, see LLVM's llvm::sys::Memory::AllocateRWX (Unix implementation; Windows implementation).



来源:https://stackoverflow.com/questions/6087377/how-jit-compilers-operate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!