On Thu, 16 Apr 2026 11:45:14 GMT, Quan Anh Mai <[email protected]> wrote:
>> src/hotspot/share/opto/macroArrayCopy.cpp line 1500: >> >>> 1498: // 2) src and dest do not have the same flatness. >>> 1499: // 3) src or dest is a flat abstract value class array (we don't >>> know the exact layout and cannot use the stub). >>> 1500: // 4) dest is a flat value class array with oop fields and requires >>> to emit write barriers (we don't have such a stub). >> >> This should be `src or dest` similar to other comments, because loading an >> oop may require load barrier, too. > > Besides, should it be that `src` and `dest` have the same `layout_kind`, can > we arraycopy a nullable array to a null-free array, or an atomic to a > non-atomic array? > This should be `src or dest` similar to other comments, because loading an > oop may require load barrier, too. Good catch, updated. Also refactored the code slightly and added more asserts. > Besides, should it be that src and dest have the same layout_kind, can we > arraycopy a nullable array to a null-free array, or an atomic to a non-atomic > array? That's a good point and I think you're definitely right about atomicity - this does not seem to be handled. In this patch, I only address the abstract value class case and added some comments and small clean-ups to keep the scope smaller. There is already an umbrella bug to fix the remaining issues: [JDK-8251971](https://bugs.openjdk.org/browse/JDK-8251971). For matching nullness, we handle it for the non-validated cases further down: https://github.com/openjdk/valhalla/blob/2f943e10e4cab414515b52371bec38f19eda81fe/src/hotspot/share/opto/macroArrayCopy.cpp#L1595-L1599 and for validated cases, we handle it here: https://github.com/openjdk/valhalla/blob/8f9586645baae882b8a60e3111d00c600cdf1089/src/hotspot/share/opto/library_call.cpp#L6647-L6672 So, I think nullness should be currently handled. I'm not sure if we have enough tests to cover all of this, though. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2325#discussion_r3098890395
