escape analysis issue with nested objects
Kirk Pepperdine
kirk at kodewerk.com
Thu May 25 18:40:42 UTC 2017
Hi,
No bug in Hotspot.. Bench is buggy. multi() is not inlined because it’s too big where as single() is inlined. There are 11 allocation eliminated events that inluce single() so it’s been DCE’ed.
Kind regards,
Kirk
> On May 25, 2017, at 6:16 PM, Hontvári Attila <attila at hontvari.net> wrote:
>
> When creating a non-escaping array and putting a newly created, non-escaping object in it, the EA works, there are no heap allocations.
>
> private static void single() {
> Object x = new Object();
> Object[] array = new Object[]{x};
> Object a = array[0];
> }
>
> But if we do the same with two or more objects, the array will be allocated on the heap, and not eliminated.
>
> private static void multi() {
> Object x = new Object();
> Object y = new Object();
> Object[] array = new Object[]{x, y};
> Object a = array[0];
> Object b = array[1];
> }
>
> Is there a reason why it is only working in the first case?
>
> This would be useful for example, MethodHandle::invokeWithArguments, when the primitive types are boxed, and put into a varargs array, see my older email [1].
>
> A complete test source code is in [2], if we run it with -verbose:gc, we can see there are many GCs in the second case, but there are no GCs in the first case.
>
> [1] http://mail.openjdk.java.net/pipermail/jigsaw-dev/2017-January/010933.html
>
> [2] https://gist.github.com/anonymous/bd46075ef1ebd858dae49fe6cfe39da8
>
More information about the hotspot-compiler-dev
mailing list