RFR(L): 6912521: System.arraycopy works slower than the simple loop for little lengths

Roland Westrelin roland.westrelin at oracle.com
Wed Jan 14 21:32:25 UTC 2015

Hi Vladimir. Thanks for taking a look at this.

> The logic which choose direction of coping in ArrayCopyNode::Ideal() is strange. I would like to see more explicit checks there. Something like:
> if (is_array_copy_overlap()) {
>  array_copy_backward()
> } else {
>  array_copy_forward()
> }

I’m not following you. In the general case, the test needs to be done at runtime. Your code above seems to imply that we would always decide at compile time?

> Can you move ArraCopy class code from callnode.?pp to new arraycopynode.?pp files? the code become too large.


> Can you add comment in library_call.cpp explaining new validation/casting logic? Why you do that?

I will add comments.
To be legal, the transformation of the ArrayCopyNode to loads/stores can only happen if we’re sure the Arrays.copyOf would succeed. So we need all input arguments to the copyOf to be validated, including that the copy to the new array won’t trigger an ArrayStoreException. That’s why there’s a subtype check. That subtype check can be optimized if we know something on the type of the input array from type speculation.


> Thanks,
> Vladimir
> On 1/14/15 1:34 AM, Roland Westrelin wrote:
>> http://cr.openjdk.java.net/~roland/6912521/webrev.00/
>> Follow up to 6700100 (instance clone as series of loads/stores): convert ArrayCopyNode for small array copies (clone of arrays, System.arraycopy, Arrays.copyOf) to series of loads and stores.
>> Roland.

More information about the hotspot-compiler-dev mailing list