When looking at the output of -XX:+PrintCompilation JVM flag, it’s easy to spot some entries with “made not entrant” and “made zombie”. This indicates so called deoptimization. What it basically means is that the code which was previously compiled, has to be backed out.


Not entrant code

Code can be made not entrant in the following scenarios:

  • when using polymorphism
  • during Tiered Compilation



Let’s look at the example:


As you can see, the implementation of parser depends on the length of the document. If we want to parse a long document, we will use the RemoteParser, otherwise it will be the LocalParser. Let’s imagine the following situation – there is a huge amount of long documents to be parsed – JIT compiler will notice that the actual type of parser is the RemoteParser. It will inline parse method (if applicable) and perform further optimizations assuming that the type of parser is always the RemoteParser.

Now, let’s call the code above with a huge amount of short documents. The assumption about the type of parser is no longer valid, so the optimizations applied before are also invalid. That means that the compiled methods have been made not entrant. JVM will discard all those optimizations and start compiling that code with LocalParser.


Tiered Compilation

Due to the nature of Tiered Compilation, when the method is compiled using different levels of compilation, the code compiled using the previous level is made not entrant. What it basically means is that the compilation on new level is made from scratch (however it can use a profile data collected before).


Zombie code

“Zombie code” in a compilation log means that the code which was previously made not entrant, has been reclaimed. In other words – all the objects which used previous optimizations don’t exist anymore, so that the optimized code can be removed from a code cache (where compiled code is held and which is limited of course).

2 responses to “Deoptimization

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.