Confusion about JVM JIT HotSpot

For example, a loop with 10,000 times in a method. When it runs 1000 times, backedge_counter starts compilation JIT. And the interpreter continues execution. When it completes the 4000 loop , compilation JITends.

My question is: how do I execute the remainder of 6000 , with an interpreter, or execute my own code? Or is native code not executed until this method is called next time? And what happens when this method is called next time?

+4
source share
2 answers

, JVM HotSpot, , .

HotSpot JVM , " ", .

http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html


"OSR". ( ) ( ). , , - ( , ) . .

JVM -XX:+PrintCompilation, OSR %:

    274   27       3       java.lang.String::lastIndexOf (52 bytes)
    275   29       3       java.lang.String::startsWith (72 bytes)
    275   28       3       java.lang.String::startsWith (7 bytes)
    275   30       3       java.util.Arrays::copyOf (19 bytes)
    276   32       4       java.lang.AbstractStringBuilder::append (29 bytes)
    276   31  s    3       java.lang.StringBuffer::append (13 bytes)
    283   33 %     3       LoopTest::myLongLoop @ 13 (43 bytes)
             ^                                    ^
            OSR                            bytecode index of OSR entry

UPDATE

OSR , .

    187   32 %     3       LoopTest::myLongLoop @ 13 (43 bytes)
    187   33       3       LoopTest::myLongLoop (43 bytes)

, , , OSR .

+8

:

Java HotSpot ?

, .

( Ahead of the Time JUMP PalmOS ). , :

  • ? - , , - . , , - JVM , , . , , .

  • ? () , , .

, HotSpot. , "". , , inlining, .

Java HotSpot ( , ) " ", .

, . HotSpot, , .

EDIT:

, .

, 10000 :

void loop() {
    for (int i=0; i<10000; i++) {
        // example loop body
        objects[i].doSomething();
    }
}

, , 4000 HotSpot . ?

: :

  • , , (, doSomething()), , . , .

  • : loop() = 4000? , .

+1

Source: https://habr.com/ru/post/1684057/


All Articles