Skip to content

Commit

Permalink
Extract type-intersect-location logic from VPClassType intersection
Browse files Browse the repository at this point in the history
This logic was repeated for both VPResolvedClass and VPFixedClass, and
conspicuously missing from VPUnresolvedClass.
  • Loading branch information
jdmpapin committed Oct 15, 2021
1 parent 8021d57 commit 6be9456
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 19 additions & 21 deletions compiler/optimizer/VPConstraint.cpp
Expand Up @@ -2935,8 +2935,24 @@ TR::VPClassType *TR::VPClassType::classTypesCompatible(TR::VPClassType * otherTy
}
}

TR::VPConstraint *TR::VPClassType::typeIntersectLocation(
TR::VPObjectLocation *location, OMR::ValuePropagation *vp)
{
TR_YesNoMaybe classObject = isClassObject();
if (classObject != TR_maybe)
{
auto impliedKind = classObject == TR_yes
? TR::VPObjectLocation::ClassObject
: TR::VPObjectLocation::NotClassObject;

auto impliedLocation = TR::VPObjectLocation::create(vp, impliedKind);

location = (TR::VPObjectLocation *) impliedLocation->intersect(location, vp);
if (!location) return NULL;
}

return TR::VPClass::create(vp, this, NULL, NULL, NULL, location);
}

// this routine encapsulates code that used to exist
// in VPClass::intersect
Expand Down Expand Up @@ -3424,16 +3440,7 @@ TR::VPConstraint *TR::VPResolvedClass::intersect1(TR::VPConstraint *other, OMR::
return TR::VPClass::create(vp, this, NULL, NULL, other->asArrayInfo(), NULL);
else if (other->asObjectLocation())
{
TR::VPObjectLocation *location = other->asObjectLocation();
TR_YesNoMaybe classObject = isClassObject();
if (classObject != TR_maybe)
{
location = TR::VPObjectLocation::create(vp, classObject == TR_yes ?
TR::VPObjectLocation::ClassObject : TR::VPObjectLocation::NotClassObject);
location = (TR::VPObjectLocation *) location->intersect(other->asObjectLocation(), vp);
if (!location) return NULL;
}
return TR::VPClass::create(vp, this, NULL, NULL, NULL, location);
return typeIntersectLocation(other->asObjectLocation(), vp);
}
return this;
}
Expand Down Expand Up @@ -3524,16 +3531,7 @@ TR::VPConstraint *TR::VPFixedClass::intersect1(TR::VPConstraint *other, OMR::Val
return TR::VPClass::create(vp, this, NULL, NULL, other->asArrayInfo(), NULL);
else if (other->asObjectLocation())
{
TR::VPObjectLocation *location = other->asObjectLocation();
TR_YesNoMaybe classObject = isClassObject();
if (classObject != TR_maybe)
{
location = TR::VPObjectLocation::create(vp, classObject == TR_yes ?
TR::VPObjectLocation::ClassObject : TR::VPObjectLocation::NotClassObject);
location = (TR::VPObjectLocation *) location->intersect(other->asObjectLocation(), vp);
if (!location) return NULL;
}
return TR::VPClass::create(vp, this, NULL, NULL, NULL, location);
return typeIntersectLocation(other->asObjectLocation(), vp);
}
return NULL;
}
Expand Down Expand Up @@ -3635,7 +3633,7 @@ TR::VPConstraint *TR::VPUnresolvedClass::intersect1(TR::VPConstraint *other, OMR
else if (other->asArrayInfo())
return TR::VPClass::create(vp, this, NULL, NULL, other->asArrayInfo(), NULL);
else if (other->asObjectLocation())
return TR::VPClass::create(vp, this, NULL, NULL, NULL, other->asObjectLocation()); // FIXME: unless rtresolve, should be on heap
return typeIntersectLocation(other->asObjectLocation(), vp);
return this;
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/optimizer/VPConstraint.hpp
Expand Up @@ -621,6 +621,8 @@ class VPClassType : public TR::VPConstraint
TR::VPClassType *classTypesCompatible(TR::VPClassType * otherType, OMR::ValuePropagation *vp);

protected:
TR::VPConstraint *typeIntersectLocation(TR::VPObjectLocation *location, OMR::ValuePropagation *vp);

const char *_sig;
int32_t _len;
};
Expand Down

0 comments on commit 6be9456

Please sign in to comment.