[lworld] RFR: 8330691: [lworld] C2: assert(gvn().type(n)->is_zero_type()) failed: Should have been scalarized
Christian Hagedorn
chagedorn at openjdk.org
Wed May 8 09:02:44 UTC 2024
The unique concrete subclass optimization replaces an abstract class with a unique concrete sub class (if there is one). In the test case, `abstractValueClassSingleSubclass` is a field with the abstract value class type `AbstractValueClassSingleSubclass` which has a unique (loaded) concrete value sub class `UniqueValueSubClass`.
In `do_get_xxx()`, we get the declared `ciType` of the field:
https://github.com/openjdk/valhalla/blob/3b89acb102ddb7b4f318edab5c1a6169b28757c0/src/hotspot/share/opto/parse3.cpp#L143
which is `AbstractValueClassSingleSubclass` (i.e. no unique concrete sub class optimization applied). But for the type, we call `make_from_klass()` which does apply the unique concrete sub class optimization:
https://github.com/openjdk/valhalla/blob/3b89acb102ddb7b4f318edab5c1a6169b28757c0/src/hotspot/share/opto/parse3.cpp#L173
https://github.com/openjdk/valhalla/blob/3b89acb102ddb7b4f318edab5c1a6169b28757c0/src/hotspot/share/opto/type.cpp#L3842-L3859
As a result, we create a load that has type `UniqueValueSubClass` while `field_klass` is still abstract. We do not create an `InlineTypeNode` because `is_inlinetype()` returns false for abstract classes:
https://github.com/openjdk/valhalla/blob/3b89acb102ddb7b4f318edab5c1a6169b28757c0/src/hotspot/share/opto/parse3.cpp#L191-L193
Later, we assert that we've missed a scalarization opportunity based on the concrete inline type load.
The fix is straight forward to improve the fetched declared `ciType` in `do_get_xxx()` by applying the unique concrete sub class optimization to match the improved type. We only need to apply it for abstract inline type classes. In other cases, we do not the improved field type. I've added a method to check this accordingly.
Thanks,
Christian
-------------
Commit messages:
- 8330691: [lworld] C2: assert(gvn().type(n)->is_zero_type()) failed: Should have been scalarized
Changes: https://git.openjdk.org/valhalla/pull/1099/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1099&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8330691
Stats: 47 lines in 5 files changed: 47 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/valhalla/pull/1099.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1099/head:pull/1099
PR: https://git.openjdk.org/valhalla/pull/1099
More information about the valhalla-dev
mailing list