Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if an array class can be trusted as a fixed class #7579

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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