Skip to content

Commit

Permalink
Fold VFTLoad from object of known fixed class
Browse files Browse the repository at this point in the history
When we are loading VFT pointer from an object whose
type is known and fixed, we can transform such indirect
load to load constant.

Signed-off-by: Rahil Shah <rahil@ca.ibm.com>
  • Loading branch information
r30shah committed Aug 9, 2021
1 parent 26b4ee8 commit 1818cb1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion compiler/optimizer/VPHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ static bool tryFoldCompileTimeLoad(
bool &isGlobal)
{
isGlobal = true;

if (!node->getOpCode().isLoad())
return false;
else if (node->getOpCode().isLoadReg())
Expand Down Expand Up @@ -447,6 +446,30 @@ static bool tryFoldCompileTimeLoad(
}
return didSomething;
}
else if (node->getSymbolReference() == vp->comp()->getSymRefTab()->findVftSymbolRef()
&& node->getFirstChild() == curNode
&& constraint->isNonNullObject()
&& constraint->getClassType()
&& constraint->getClassType()->asFixedClass()
&& constraint->getClass())
{
TR_OpaqueClassBlock *clazz = constraint->getClass();
#ifdef J9_PROJECT_SPECIFIC
TR_J9VMBase *fej9 = vp->comp()->fej9();
// Non SVM AOT can deal with transformed loadaddr of system class only while Symbol Validation Manager can handle any class.
// Skip the transformation under non SVM AOT when class is not loaded by bootstrap class loader.
if (vp->comp()->compileRelocatableCode() && !vp->comp()->getOption(TR_UseSymbolValidationManager) && fej9->getClassLoader(clazz) != fej9->getSystemClassLoader())
return false;
#endif
if (vp->trace())
traceMsg(vp->comp(), "VP Transforming VFTLoad to loadaddr: as n%dn is VFT load of known class", node->getGlobalIndex());
node->setNumChildren(0);
TR::Node::recreateWithSymRef(node, TR::loadaddr, vp->comp()->getSymRefTab()->findOrCreateClassSymbol(vp->comp()->getMethodSymbol(), -1, clazz));
node->setFlags(0);
vp->removeNode(curNode, true);
TR::DebugCounter::incStaticDebugCounter(vp->comp(), TR::DebugCounter::debugCounterName(vp->comp(), "VFTLoadKnownObject/(%s)/%s", vp->comp()->signature(), vp->comp()->getHotnessName(vp->comp()->getMethodHotness())));
return true;
}
else if (!curNode->getOpCode().isLoadIndirect())
{
if (curNode->getOpCodeValue() == TR::loadaddr
Expand Down

0 comments on commit 1818cb1

Please sign in to comment.