[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). ------------- Commit messages: - JDK-8369166: failon instead of count=0 - JDK-8369166: test name - JDK-8369166: add strict/non-final and non-strict/non-final tests - JDK-8369166: make IR regex more specific - JDK-8369166: rename and add --enable-preview to test - JDK-8369166: C1 part - JDK-8369166: [lworld] Avoid final field barriers at the end of constructors for strict fields Changes: https://git.openjdk.org/valhalla/pull/2336/files Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2336&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8369166 Stats: 168 lines in 8 files changed: 154 ins; 0 del; 14 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
