C1/interpreter array-access profiling is racy and can publish the exact array klass before the flat/null-free flag is visible: https://github.com/openjdk/valhalla/blob/f87d6d1cea3b578b458075a411f7aaa5dddb2cd9/src/hotspot/share/c1/c1_LIRGenerator.cpp#L1968-L1971
C2 reads profile information lock-free and can therefore, in rare cases, observe the inconsistencies reported in the JBS issue. For example, it can observe profiling for an array load with an `array_type` that is knowingly flat but does not have the `flat_array` property set (yet). The new regression test reliably reproduces such inconsistencies for array loads and stores. Since a valid profiled flat array klass is stronger information than the flat flag, the fix is to prefer that information if available. With that fix, the asserts don't make much sense anymore, so I removed them. 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: - Whitespace fix - Remove now useless asserts - JDK-8381373 Changes: https://git.openjdk.org/valhalla/pull/2452/files Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2452&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8381373 Stats: 192 lines in 2 files changed: 176 ins; 15 del; 1 mod Patch: https://git.openjdk.org/valhalla/pull/2452.diff Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2452/head:pull/2452 PR: https://git.openjdk.org/valhalla/pull/2452
