如何JIT替代运行时优化的机器code? [英] How does JIT replace optimized machine code during runtime?

查看:187
本文介绍了如何JIT替代运行时优化的机器code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我浏览过的OpenJDK源,找不到在哪里优化code被替换的地方。

I'm browsing through OpenJDK sources and cannot find the place where optimized code is replaced.

我不知道这会在保护模式下完成,是不是某种selfmodifing code的应该是由操作系统pvented $ P $?

I wonder how this can be done in protected mode, isn't it some kind of selfmodifing code which should be prevented by the OS?

推荐答案

在说,堆或堆栈中的JITer分配空间,并插入组装code进去。不,自修改code是完全正常的。 VirtualProtect的(Windows)和MMAP(UNIX)可映射页为可执行文件。通用操作系统在默认情况下将迎来可执行的页面为已读/执行,但不会写,你仍然可以通常在运行时改变这一点。

The "JITer" allocates space in say the heap or stack and inserts assembly code into it. No, self modifying code is perfectly fine. VirtualProtect (Windows) and mmap (Unix) can map pages as executable. General purpose operating systems by default will mark executable pages as read/execute but not write, you can still typically change this at runtime.

如果没有办法修改code,就没有办法,除非它的加载到一个固定的当前虚拟地址和共享到每个进程的地址空间来加载一个dll;然后你会得到的地址空间,而不是地狱DLL地狱的。

If there was no way to modify code, there would be no way to load a dll unless it's loaded to a fixed Virutal Address and shared into each process's address space; then you'd get address space hell instead of dll hell.

我猜你听说过NX位或DEP等,这些只是保护你的执行非执行code,它有助于防止堆栈溢出和喜欢了一下。

I'm guessing you heard of the NX bit or DEP etc, those just protect you from executing non-executable code, which helps a bit against stack overflows and the likes.

这篇关于如何JIT替代运行时优化的机器code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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