Skip to content

Avoid combining a regular type bound with a ClassObject location in VP - #6208

Merged
0xdaryl merged 3 commits into
eclipse-omr:masterfrom
jdmpapin:vp-type-intersect-location
Oct 26, 2021
Merged

0xdaryl merged 3 commits into
eclipse-omr:masterfrom
jdmpapin:vp-type-intersect-location

Conversation

@jdmpapin

Copy link
Copy Markdown
Contributor

...as the intersection of the two constraints. If the type is not already known to be a ClassObject, then bundling it into a VPClass with a ClassObject location will incorrectly change the meaning of the type constraint.

There is also one preparatory refactoring commit, and another commit making a minor improvement to the affected logic

Fixes eclipse-openj9/openj9#13167

This logic was repeated for both VPResolvedClass and VPFixedClass, and
conspicuously missing from VPUnresolvedClass.
Any value known to satisfy the VPClassType constraint is an object, so
it must be a reflective object rather than a VM-internal representation.
...as the intersection of the two constraints. If the type is not
already known to be a ClassObject, then bundling it into a VPClass with
a ClassObject location will incorrectly change the meaning of the type
constraint.
@0xdaryl

0xdaryl commented Oct 15, 2021

Copy link
Copy Markdown
Contributor

Jenkins build all

if (!location) return NULL;
}

if (location->isClassObject() == TR_yes && classObject != TR_yes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I just need to study more of the surrounding code to better understand how a case such as location->isClassObject() == TR_yes ought to be intersected with classObject == TR_no. Naively speaking, it seems like such an intersection ought to return NULL but it won't in this code. Could you please comment on why returning location is the right answer is every case here ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If classObject != TR_maybe, then location has been replaced in the intersection just above, so (if we reach this point) location->isClassObject() == classObject. In particular, when classObject == TR_no, we'll have location->isClassObject() == TR_no as well

So the only way to enter this conditional is with classObject == TR_maybe, which means that we have a pretty non-specific type bound, and location will be more specific. I can add an assertion for TR_maybe if you like. Or I could narrow the condition, but I'd prefer not to because it's currently written to make it obvious that we're catching every case where the interpretation of the type bound would change, i.e. every case where the VPClass below would be incorrect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see the logic now for returning location exactly in cases that we have more specific information

@vijaysun-omr

Copy link
Copy Markdown
Contributor

I have reviewed both the refactoring and the logical changes and they look okay to me. @0xdaryl are you okay with this change ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JDK17 jsr292_MethodHandleAPI_Test_JitCount1_0_FAILED - NullPointerException: Cannot read field "rtype" because "this" is null

3 participants