C2 doesn't hoist out flattened value array guard out of loops

Sergey Kuksenko sergey.kuksenko at oracle.com
Fri Mar 29 18:23:33 UTC 2019


Fine.

Notify me when it will be ready. Currently I am not care about flattened 
array performance, the key goal is to check that that legacy code will 
work as before.

On 3/29/19 9:21 AM, Roland Westrelin wrote:
> Hi Sergey,
>
>> The reason of that that check if arrays is flattened value array was not
>> hoisted out of the loop and checked on each iteration.
> It used to be that we didn't support loading/storing elements of a
> flattened array if we didn't know the exact type of the elements. So
> generated code at aaload/aastore of an Object[] array checked for a
> flattened array and caused a deoptimization in that case. Those guards
> were easy for c2 to hoist. Now, we support loading/storing from a
> flattened array declared as Object[]. We compile a flattened array check
> as before but now both branches of the check are expected to be
> taken. The flattened array check cannot be hoisted anymore. Instead, we
> can use that test to unswitch loop and so make 2 copies of the loop.
>
> That doesn't happen with org.openjdk.array.Array.sum currently but I
> have a small change that enables it. With that patch
> org.openjdk.array.Array.sum performs the same with or without
> EnableValhalla.
>
> That's not sufficient for org.openjdk.array.Array.copyFor and
> org.openjdk.array.Array.hash and I'm trying to figure out what can be
> done for those 2.
>
> Roland.


More information about the valhalla-dev mailing list