When merging JDK-8242115 into Valhalla, we noticed massive failures with our IR verification tests. It turned out that (at least) folding of loads is broken. For example, with the following test (attached):
static class MyClass {
int x = 42;
}
public static int test() {
MyClass[] array = new MyClass[1];
array[0] = new MyClass();
return array[0].x;
}
Before JDK-8242115, the load from the array is constant folded to 42 and the MyClass array and object allocations are removed. This does not work anymore after the fix, leading to a significant performance regression in microbenchmarks.
To reproduce, simply run:
java -XX:+AlwaysIncrementalInline -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,Test::test -Xbatch -XX:CompileCommand=print,Test::test -XX:-TieredCompilation Test.java
and check _new_array_Java and _new_instance_Java calls in compiled code.
There might be more issues but we can check that by applying a prototype fix and re-running Valhalla tests. For now, we omitted JDK-8242115 when merging master into Valhalla.