[lworld] RFR: 8330691: [lworld] C2: assert(gvn().type(n)->is_zero_type()) failed: Should have been scalarized [v2]
Tobias Hartmann
thartmann at openjdk.org
Wed May 8 10:43:33 UTC 2024
On Wed, 8 May 2024 09:21:30 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> 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
>
> Christian Hagedorn has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
>
> - Merge branch 'lworld' into JDK-8330691
> - 8330691: [lworld] C2: assert(gvn().type(n)->is_zero_type()) failed: Should have been scalarized
Looks good, thanks for fixing Christian!
Please re-run testing now that the merge and the fix for [JDK-8331538](https://bugs.openjdk.org/browse/JDK-8331538) is in.
test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java line 4387:
> 4385: @Test
> 4386: public void testUniqueConcreteValueSubKlass(boolean flag) {
> 4387: // C2 should recognize that even though we do not know whether the underlying inline type of the abstract field
Comment could be made more clear, as we discussed offline.
-------------
Marked as reviewed by thartmann (Committer).
PR Review: https://git.openjdk.org/valhalla/pull/1099#pullrequestreview-2045289286
PR Review Comment: https://git.openjdk.org/valhalla/pull/1099#discussion_r1593814798
More information about the valhalla-dev
mailing list