[lworld] RFR: 8364191: [lworld] Accesses to atomic flat fields prevent scalar replacement [v6]
Tobias Hartmann
thartmann at openjdk.org
Tue Oct 21 14:06:33 UTC 2025
On Mon, 20 Oct 2025 09:00:02 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> Hi,
>>
>> Flat accesses prevent scalar replacement because they are mismatched accesses. It is also generally not possible to look through them, because the payload may contain an oop in the form of raw bits. As a result, this PR adds `LoadFlatNode` and `StoreFlatNode`, which act as high-level abstractions for atomic accesses on flat fields. When it is determined that there is no racing access on the flat field (e.g. because the holder object does not escape), these flat access nodes can be expanded into multiple accesses to each flattened fields, otherwise, they will be expanded into a sequence of inferring a payload and accessing memory with that payload.
>>
>> I also fix an issue with deoptimization reallocation where we miss assigning the null marker of elements in a nullable flat array.
>>
>> Please take a look and leave your reviews, thanks a lot.
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove flat accesses from sfn_worklist
Great work, Quan-Anh! This looks good to me. Testing is still running but looks good so far (we had some breakage in our CI). I'll get back to you once it passed.
src/hotspot/share/opto/escape.cpp line 3392:
> 3390: }
> 3391:
> 3392: // Atomic flat accesses on non-escape objects can be optimized to non-atomic accesses
Suggestion:
// Atomic flat accesses on non-escaping objects can be optimized to non-atomic accesses
src/hotspot/share/opto/inlinetypenode.hpp line 176:
> 174: // marker if existing will be the last Proj output. This node acts as if the load happens
> 175: // atomically and will be expanded to loading the whole payload and extracting the flattened fields
> 176: // from the loaded payload. In special cases, such as when the object from which this load read
Suggestion:
// from the loaded payload. In special cases, such as when the object from which this load reads
src/hotspot/share/opto/inlinetypenode.hpp line 179:
> 177: // does not escape, this node can be expanded to multiple loads from each flattened field.
> 178: // This node allows us to replace its results with the value from a matching store because the
> 179: // payload value cannot be directly propagated if it contains oops. This effect, in turns, allows
Suggestion:
// payload value cannot be directly propagated if it contains oops. This effect, in turn, allows
src/hotspot/share/opto/inlinetypenode.hpp line 216:
> 214:
> 215: // Store an InlineTypeNode to a flat element, the store acts as if it is atomic. Similar to
> 216: // LoadFlatNode, this node is expanded to storing a payload creating from the field values of the
Suggestion:
// LoadFlatNode, this node is expanded to storing a payload created from the field values of the
-------------
Marked as reviewed by thartmann (Committer).
PR Review: https://git.openjdk.org/valhalla/pull/1518#pullrequestreview-3360961039
PR Review Comment: https://git.openjdk.org/valhalla/pull/1518#discussion_r2448463925
PR Review Comment: https://git.openjdk.org/valhalla/pull/1518#discussion_r2448453931
PR Review Comment: https://git.openjdk.org/valhalla/pull/1518#discussion_r2448455420
PR Review Comment: https://git.openjdk.org/valhalla/pull/1518#discussion_r2448457425
More information about the valhalla-dev
mailing list