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 scalarize foo
on the stack, when C2 OSR compilation kicks in? I suppose that it might be problematic, because a live object already exists in heap, so it might be not possible to "move" object from heap to stack and registers.