Skip to content

Commit

Permalink
Merge pull request eclipse-omr#7579 from a7ehuo/valuetype-fix-vp-cons…
Browse files Browse the repository at this point in the history
…traint-for-nullRestrictedArray

Check if an array class can be trusted as a fixed class
  • Loading branch information
hzongaro authored Dec 20, 2024
2 parents a3a92be + eb64424 commit 3ddaad3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
10 changes: 10 additions & 0 deletions compiler/optimizer/OMRValuePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7247,6 +7247,16 @@ bool OMR::ValuePropagation::isUnreliableSignatureType(
return false;
}

bool OMR::ValuePropagation::canArrayClassBeTrustedAsFixedClass(TR_OpaqueClassBlock *arrayClass, TR_OpaqueClassBlock *componentClass)
{
return true;
}

bool OMR::ValuePropagation::canClassBeTrustedAsFixedClass(TR::SymbolReference *symRef, TR_OpaqueClassBlock *classObject)
{
return true;
}

void OMR::ValuePropagation::doDelayedTransformations()
{
ListIterator<TR_TreeTopNodePair> treesIt1(&_scalarizedArrayCopies);
Expand Down
19 changes: 19 additions & 0 deletions compiler/optimizer/OMRValuePropagation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,25 @@ class ValuePropagation : public TR::Optimization
virtual bool isUnreliableSignatureType(
TR_OpaqueClassBlock *klass, TR_OpaqueClassBlock *&erased);

/**
* \brief Determine whether an \p arrayClass with the \p componentClass can be trusted as a fixed class
*
* \param arrayClass The array class.
* \param componentClass The component class of the array.
*
* \return true if an array with the component class can be trusted as a fixed class, and false otherwise.
*/
virtual bool canArrayClassBeTrustedAsFixedClass(TR_OpaqueClassBlock *arrayClass, TR_OpaqueClassBlock *componentClass);
/**
* \brief Determine whether a class retrieved from signature can be trusted as a fixed class
*
* \param symRef The symbol reference of the class object.
* \param classObject The class object to be checked.
*
* \return true if a class can be trusted as a fixed class, and false otherwise.
*/
virtual bool canClassBeTrustedAsFixedClass(TR::SymbolReference *symRef, TR_OpaqueClassBlock *classObject);

struct ObjCloneInfo {
TR_ALLOC(TR_Memory::ValuePropagation)

Expand Down
4 changes: 2 additions & 2 deletions compiler/optimizer/VPConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ TR::VPResolvedClass *TR::VPResolvedClass::create(OMR::ValuePropagation *vp, TR_O
// An array class is fixed if the base class for the array is final
//
TR_OpaqueClassBlock * baseClass = vp->fe()->getLeafComponentClassFromArrayClass(klass);
if (baseClass && TR::Compiler->cls.isClassFinal(vp->comp(), baseClass))
if (baseClass && TR::Compiler->cls.isClassFinal(vp->comp(), baseClass) && vp->canArrayClassBeTrustedAsFixedClass(klass, baseClass))
return TR::VPFixedClass::create(vp, klass);
}
else
Expand Down Expand Up @@ -6078,7 +6078,7 @@ void TR::VPResolvedClass::print(TR::Compilation *comp, TR::FILE *outFile)
len = static_cast<int32_t>(strlen(sig));
}

trfprintf(outFile, "class %.*s", len, sig);
trfprintf(outFile, "class 0x%p %.*s", _class, len, sig);
if (_typeHintClass)
{
trfprintf(outFile, " (hint 0x%p", _typeHintClass);
Expand Down
5 changes: 4 additions & 1 deletion compiler/optimizer/VPHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,7 @@ TR::Node *constrainAload(OMR::ValuePropagation *vp, TR::Node *node)
{
if (classBlock != jlClass)
{
isFixed = isFixed ? vp->canClassBeTrustedAsFixedClass(NULL, classBlock) : isFixed;
constraint = TR::VPClassType::create(vp, sig, len, owningMethod, isFixed, classBlock);
if (*sig == '[' || sig[0] == 'L')
{
Expand Down Expand Up @@ -11207,9 +11208,11 @@ static void constrainClassObjectLoadaddr(
"constrainClassObjectLoadaddr: n%un loadaddr is not for a class\n",
node->getGlobalIndex());

bool isFixed = vp->canClassBeTrustedAsFixedClass(symRef, NULL);

TR::VPConstraint *constraint = TR::VPClass::create(
vp,
TR::VPClassType::create(vp, symRef, true),
TR::VPClassType::create(vp, symRef, isFixed),
TR::VPNonNullObject::create(vp),
NULL,
NULL,
Expand Down

0 comments on commit 3ddaad3

Please sign in to comment.