Does Hotspot JVM contain Escape analysis at compile time with stack replacement?

Consider the following code:

void methodWithOSR() {
    Foo foo = new Foo(); // this object doesn't escape
    for (int i = 0; i < 1_000_000; i++) {
        // some code that uses `foo`
    }
}

Is Hotspot JVM able to scan fooon the stack when C2 OSR compilation starts? I believe this may be problematic because a living object already exists on the heap, so it would be impossible to "move" the object from the heap to the stack and registers.

+4
source share
1 answer

It’s not clear what β€œscalaraize” means in this situation, but let me rephrase the question.

Does HotSpot JVM generate Escape analysis during OSR compilation?

Yes. Most compiler functions / optimizations are valid for compiling OSR, as well as for regular compilation.

HotSpot Escape "" ( ) Foo ?

- , Foo, .

HotSpot ?

. . - .

HotSpot Foo ?

. , , . , .

+3

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


All Articles