RFR: 8032218: Emit single post-constructor barrier for chain of superclass constructors [v2]

Joshua Cao duke at openjdk.org
Wed Apr 24 17:14:51 UTC 2024


> Opening this PR on top of https://github.com/openjdk/jdk/pull/18505. This PR is only valid if we agree it is sufficient to use `StoreStore` barriers at the end of constructors instead of `Release` barriers.
> 
> Currently on master, [C2 emits a Release barrier for each constructor call](https://github.com/openjdk/jdk/blob/32946e1882e9b22c983cbba3c6bda3cc7295946a/src/hotspot/share/opto/parse1.cpp#L1019) in a chain of superclass constructor calls. After https://github.com/openjdk/jdk/pull/18505 is merged, it is the same except that the barrier is a `StoreStore`. It is unnecessary. We only need to emit a single barrier for each object allocation / each pair of `Allocation/InitializeNode`. 
> 
> [Macro expansion emits a trailing StoreStore after an InitializeNode](https://github.com/openjdk/jdk/blob/32946e1882e9b22c983cbba3c6bda3cc7295946a/src/hotspot/share/opto/macro.cpp#L1610-L1628). This `StoreStore` is sufficient as the post-constructor barrier. From the [InitializeNode definition](https://github.com/openjdk/jdk/blob/32946e1882e9b22c983cbba3c6bda3cc7295946a/src/hotspot/share/opto/memnode.cpp#L3639-L3642):
> 
>> // An InitializeNode collects and isolates object initialization after
> // an AllocateNode and before the next possible safepoint.  As a
> // memory barrier (MemBarNode), it keeps critical stores from drifting
> // down past any safepoint or any publication of the allocation.
> 
> All the writes that occur in the constructor will come before the `InitializeNode/StoreStore`. This PR removes the emitting of `StoreStore` barriers in `Parse::do_exits()`. This PR subsumes https://github.com/openjdk/jdk/pull/18505.
> 
> Passes hotspot tier1 locally on x86 linux machine. New tests make sure that there is a single `StoreStore` for chained constructors.

Joshua Cao has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits:

 - 8032218: Emit single post-constructor barrier for chain of superclass constructors
 - Add riscv64 to test
 - Merge branch 'master' into storestore
 - Merge branch 'master' into storestore
 - Apply suggestions from code review
   
   some formatting suggestions from @shipilev
   
   Co-authored-by: Aleksey Shipilëv <shipilev at amazon.de>
 - Guard everything by feature flag
 - Revert "Statistics for barriers generated/eliminated"
   
   This reverts commit 33d23635048afd3a1b40ae91e6fadf577742fa4f.
 - Make flag product diagnostic and guard string concat storestore by flag
 - Statistics for barriers generated/eliminated
 - global flag to turn on storestore barrier emission and membar acquires
   IR tests
 - ... and 12 more: https://git.openjdk.org/jdk/compare/235ba9a7...717fe65b

-------------

Changes: https://git.openjdk.org/jdk/pull/18870/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18870&range=01
  Stats: 967 lines in 13 files changed: 844 ins; 116 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/18870.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18870/head:pull/18870

PR: https://git.openjdk.org/jdk/pull/18870


More information about the hotspot-compiler-dev mailing list