[9] RFR(S): 8179678: ArrayCopy with same src and dst can cause incorrect execution or compiler crash

Tobias Hartmann tobias.hartmann at oracle.com
Tue May 16 09:32:50 UTC 2017

Hi Roland,

On 11.05.2017 10:33, Roland Westrelin wrote:
> http://cr.openjdk.java.net/~roland/8179678/webrev.00/
> When possible:
> System.arraycopy(src, spos, dst, dpos, l);
> v = dst[i];
> is transformed to:
> System.arraycopy(src, spos, dst, dpos, l);
> v = src[i + (spos - dpos)];
> So the arraycopy has a chance to be eliminated. This breaks if src and
> dst are the same arrays and src[i + (spos - dpos)] is written to by the
> arraycopy. We need to validate that either src[i + (spos - dpos)] is not
> modified by the arraycopy or src and dst are not the same.

But in ArrayCopyNode::can_replace_dest_load_with_src_load() you return false, if src == dst. Why is that?

And in line 733, shouldn't we pass must_modify = false to detect the case we the array copy _may_ modify the source we would load?

Best regards,

More information about the hotspot-compiler-dev mailing list