Why doesnt JIT compiler ( Java ) save the results?

Axel Coon :

As I studied about JIT compiler from here: What does a just-in-time (JIT) compiler do? and

there's no *.exe or *.dll generated by the Java JIT for Windows. It writes the processor instructions to memory (RAM) and runs it from there. There's no need to create a separate PE file with file-headers and everything

My question is WHY doesn't JIT compiler ( Java ) save the results? Isn't it useful to store compiled code to save time for the next launch?

(My question is different from the mentioned above, because I emphasized on WHY)

Hulk :

The ouput of a JIT may be different for each run - it can optimize for the current load pattern. This sometimes allows it to optimize more agressively than what would be possible for pre-compiled code that needs to be reusable.

If the load-pattern changes and the optimization is found to be sub-optimal or even adverse, a JIT can de-optimize and possibly attempt a different optimization

(see also About the dynamic de-optimization of HotSpot)

Now, it might sometimes save some performance to keep these results of various compiled versions around and reuse them later, but it would also require a significant amount of book-keeping to be able to find out if a section of code has already been compiled with currently relevant optimizations.

I suppose that is just not considered worth the effort. Its a tradeoff between doing file-IO and usually fast compilation of small sections of code.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=77250&siteId=1