[lworld] RFR: 8367785: [lworld] Compiler adherence to new memory model rules for strict instance fields

Tobias Hartmann thartmann at openjdk.org
Mon Oct 6 07:39:12 UTC 2025


The new memory model rules for strict instance fields (see [JDK-8366372](https://bugs.openjdk.org/browse/JDK-8366372)) require a memory barrier at the beginning of `java.lang.Object::<init>`. The JITs will try to omit it if the receiver type is statically known (potentially via CHA + a dependency) and the class does not contain any strict fields.

Potentially, there's some more tricks that we can play. Most importantly, I think we can omit barriers for final fields at the end of the constructors if the field is also strict. I filed [JDK-8369166](https://bugs.openjdk.org/browse/JDK-8369166) for this.

I added a test that already caught [JDK-8369044](https://bugs.openjdk.org/browse/JDK-8369044) and will fail immediately without the JIT changes (on AArch64).

Thanks,
Tobias

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

Commit messages:
 - More tests
 - Merge branch 'lworld' into JDK-8367785
 - Another typo
 - Removed TODO
 - Typo
 - Fix allocation removal
 - First prototype

Changes: https://git.openjdk.org/valhalla/pull/1656/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1656&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8367785
  Stats: 291 lines in 4 files changed: 291 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/valhalla/pull/1656.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1656/head:pull/1656

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


More information about the valhalla-dev mailing list