考虑以下代码:
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`
}
}
foo
当 C2 OSR 编译开始时,Hotspot JVM 是否能够在堆栈上进行标量化?我想这可能是有问题的,因为堆中已经存在一个活动对象,因此可能无法将对象从堆“移动”到堆栈和寄存器。