When the jvm (hotspot in my case) permanently compiles certain code paths into machine code, where is that machine code being stored? in the .text segment of process memory? in the process's heap??
I am not talking about JITing. From my understandning, JIT will compile and run bytecode without ever saving the compiled code anywhere. But what about when the jvm is saving that code -- where in process space does it save it?
... as the comments and answers point out, everything I was asking for is, in fact, a part of JIT.
EDIT:
as per my comment below, the situation I'm specifically referring to is documented here as "Adaptive optimization": http://www.oracle.com/technetwork/java/whitepaper-135217.html#hotspot
Firstly, what you are describing is JIT - specifically how it works in Hotspot
To answer your question about where the code is saved at runtime - it's in the process heap and the pointers to the method code in the object's Klass file is updated to point to it. There's also something called OSR (on stack replacement) for compiling long running loops directly on the stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With