> [JDK-8367785](https://bugs.openjdk.org/browse/JDK-8367785) added a barrier to 
> the beginning of `java.lang.Object::<init>` for _strict_ fields.
> 
> If the field is _strict_ **and** _final_, we will also add barriers to the 
> end of the constructors.
> C1:
> https://github.com/openjdk/valhalla/blob/274d56076260a490ed52df29373216617ddf73ef/src/hotspot/share/c1/c1_GraphBuilder.cpp#L1645-L1652
> C2:
> https://github.com/openjdk/valhalla/blob/274d56076260a490ed52df29373216617ddf73ef/src/hotspot/share/opto/parse1.cpp#L1092-L1099
> 
> In that specific case the _final_ barrier can be omitted because the object 
> can only escape after `java.lang.Object::<init>` for strict fields.
> 
> So, this change narrows the constructor exit barrier condition to non-strict 
> instance final writes only. In C2, the `do_exits()` decision now uses 
> `wrote_non_strict_final`, and that flag is set only for final stores where 
> `!field->is_strict()`. The same condition is mirrored in C1 by tracking 
> `wrote_non_strict_final` in IRScope and using it in 
> `GraphBuilder::method_return`.
> 
> ## Testing
> * added C2 IR test that checks that strict-final constructors do not get a 
> constructor exit barrier, while non-strict final constructors still do
> * added C1 test run (to `TestStrictFinalBarriers.java`) to exercise 
> constructor strict-field barrier behaviour
> * Tier 1-3+
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Damon Fenacci has updated the pull request incrementally with one additional 
commit since the last revision:

  JDK-8369166: join ifs

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

Changes:
  - all: https://git.openjdk.org/valhalla/pull/2336/files
  - new: https://git.openjdk.org/valhalla/pull/2336/files/63552279..2a91d06e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=valhalla&pr=2336&range=01
 - incr: https://webrevs.openjdk.org/?repo=valhalla&pr=2336&range=00-01

  Stats: 4 lines in 1 file changed: 0 ins; 2 del; 2 mod
  Patch: https://git.openjdk.org/valhalla/pull/2336.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2336/head:pull/2336

PR: https://git.openjdk.org/valhalla/pull/2336

Reply via email to