RFR: 8327963: C2: fix construction of memory graph around Initialize node to prevent incorrect execution if allocation is removed [v12]
Roland Westrelin
roland at openjdk.org
Mon Sep 29 08:44:54 UTC 2025
On Wed, 24 Sep 2025 12:14:50 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:
>> src/hotspot/share/opto/macro.cpp line 1606:
>>
>>> 1604: // elimination. Simply add the MemBarStoreStore after object
>>> 1605: // initialization.
>>> 1606: MemBarNode* mb = MemBarNode::make(C, Op_MemBarStoreStore, Compile::AliasIdxRaw);
>>
>> Does the same argument as below apply for relaxing the scope of this memory barrier? Please clarify in a similar comment for this case (if the same argument applies, a reference to the comment below would be enough).
>
> Thanks for adding the comment. A follow-up question: the full comment below makes the argument that _re-ordering by the compiler can't happen by construction_ because _a later Store that publishes the just allocated object reference is indirectly control dependent on the Initialize node_. However, in this case, there may be no such Initialize node (`init == nullptr || init->req() < InitializeNode::RawStores`). I assume the memory barrier relaxation is still OK in this scenario because we cannot have later, publishing stores of the allocated object reference? That is, if there exists such a store then there must necessarily exist an Initialize node? Or is there any other reason I am missing? It would be good to clarify this point in the comment.
I updated the comment. Can you have a look?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24570#discussion_r2387147877
More information about the graal-dev
mailing list