开发者

How JIT Compilers Operate

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?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜