C1 eagerly allocates a buffer when loading a flat field or array element. If the value is null and its value class is still uninitialized, this allocation incorrectly triggers class initialization, potentially with side effects via the static initializer that can be observed as incorrect result (good catch by a fuzzer generated test, credits to @lepestock). See the new regression test for more details.
I first tried to fix this with a simple compilation bailout. However, if the field / array only ever contains null, we'll stay in the interpreter forever, which could lead to a performance issue if the null load/store is on the hot path. So for atomic flat loads with an uninitialized value class, C1 now loads the complete payload and checks its null marker without allocating. If null, we just return null. If non-null, we deoptimize and re-compile once the interpreter took care of class initialization. Thanks, Tobias --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - JDK-8389089 Changes: https://git.openjdk.org/valhalla/pull/2670/files Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2670&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8389089 Stats: 172 lines in 3 files changed: 157 ins; 5 del; 10 mod Patch: https://git.openjdk.org/valhalla/pull/2670.diff Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2670/head:pull/2670 PR: https://git.openjdk.org/valhalla/pull/2670
