How does JIT replace optimized machine code at runtime?

I am browsing OpenJDK sources and cannot find a place where the optimized code will be replaced.

I wonder how this can be done in protected mode, is it not some kind of self-modification code that should be prevented by the OS?

+2
source share
2 answers

JITer allocates space, such as a heap or a stack, and inserts assembly code into it. No, self-editing code is great. VirtualProtect (Windows) and mmap (Unix) can render pages as executable. General operating systems will by default mark executable pages as read / execute, but not write, you can still change this at runtime.

, dll, Virutal Address ; , .

, NX DEP .., , ..

+2

JIT ; - Java. , OpenJDK, , , JVM - - , , . , , Java- , , . , .

0

All Articles