I'm reading the book https://www.oreilly.com/library/view/java-performance-2nd/9781492056102/ch04.html
The part that confuses me is this:
Compilation is based on two counters in the JVM: the number of times the method has been called, and the number of times any loops in the method have branched back. Branching back can effectively be thought of as the number of times a loop has completed execution, either because it reached the end of the loop itself or because it executed a branching statement like continue. When the JVM executes a Java method, it checks the sum of those two counters and decides whether the method is eligible for compilation. If it is, the method is queued for compilation (see “Compilation Threads” for more details about queuing). This kind of compilation has no official name but is often called standard compilation. Similarly, every time a loop completes an execution, the branching counter is incremented and inspected. If the branching counter has exceeded its individual threshold, the loop (and not the entire method) becomes eligible for compilation.
So if I have a method that itself is not that "hot" but it contains a loop that is "hot" then body of a loop will be compiled(if aligable for compilation) and on stack replaced during loop execution. Next time the method is called is going to use the already compiled code for loop body?
Another point is:
When the JVM executes a Java method, it checks the sum of those two counters and decides whether the method is eligible for compilation.
So is a not hot method but with a hot loop going to be compiled? first through OSR because of hot loop and than because it reached some counters?