scalar replacement of arrays affected by minor changes to surrounding code
Roland Westrelin
rwestrel at redhat.com
Tue Sep 24 08:38:08 UTC 2019
> I take this to mean that there's no code shape with a newly allocated
> wrapper object+array that C2 can elide allocations for.
I tried this:
@Benchmark
public void wrappedUnrolledSum2(Blackhole bh) {
int[] arr = new int[] { next(), next() };
ArrayWrapper wrapper = new ArrayWrapper();
wrapper.setArr(arr);
bh.consume(wrapper.unrolledSum());
}
The field assignment is right after the ArrayWrapper allocation. That's
not the case with the bytecodes that javac produces for
wrappedUnrolledSum. That didn't work either. C2 does try to eliminate
the field zeroing but then it fails too (because
InitializeNode::detect_init_independence() bails out because the IR is
too complicated).
Roland.
More information about the hotspot-compiler-dev
mailing list