JIT编译器如何操作 [英] How JIT Compilers Operate

查看:173
本文介绍了JIT编译器如何操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据定义,JIT编译器会即时生成代码以供执行。但是,在Windows中,我们有各种保护,防止自我修改代码或从数据存储器(DEP)执行。



那么如何可能的JIT编译器

解决方案

他们要求操作系统提供一些可读,可写和可执行的内存。



例如您可以使用 mmap() PROT_READ | PROT_WRITE | PROD_EXEC (POSIX)或 VirtualAlloc() PAGE_EXECUTE_READWRITE p>

有关示例,请参见LLVM的 llvm: :sys :: Memory :: AllocateRWX Unix实现; Windows实施)。


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

这篇关于JIT编译器如何操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆