JIT编译器如何操作

编程入门 行业动态 更新时间:2024-10-28 01:14:22
本文介绍了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编译器如何操作

本文发布于:2023-11-07 09:13:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566064.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   操作   JIT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!