Skip to content

Commit

Permalink
Use testIsClassArrayType to generate IL to test for array type
Browse files Browse the repository at this point in the history
The downstream OpenJ9 project defines a new method,
TR_VMBase::testIsClassArrayType, that generates IL to tests whether a
class is an array class.  Change code that generated IL that loaded
classDepthAndFlags field itself to call testIsClassArrayType instead to
hide at least some of the J9-specific details.

Also, generate a comparison of the result of the IL produced by
testIsClassArrayType with zero, rather than comparing with the array
class flag.  A comparison with zero is expected to be preferred on most
platforms.

Signed-off-by:  Henry Zongaro <[email protected]>
  • Loading branch information
hzongaro committed Jul 3, 2024
1 parent 1dd236b commit a62b60b
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions compiler/optimizer/LoopVersioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8340,19 +8340,9 @@ bool TR_LoopVersioner::depsForLoopEntryPrep(

TR::Node *vftLoad = TR::Node::createWithSymRef(TR::aloadi, 1, 1, node->getFirstChild(), comp()->getSymRefTab()->findOrCreateVftSymbolRef());
//TR::Node *componentTypeLoad = TR::Node::create(TR::aloadi, 1, vftLoad, comp()->getSymRefTab()->findOrCreateArrayComponentTypeSymbolRef());
TR::Node *classFlag = NULL;
if (comp()->target().is32Bit())
{
classFlag = TR::Node::createWithSymRef(TR::iloadi, 1, 1, vftLoad, comp()->getSymRefTab()->findOrCreateClassAndDepthFlagsSymbolRef());
}
else
{
classFlag = TR::Node::createWithSymRef(TR::lloadi, 1, 1, vftLoad, comp()->getSymRefTab()->findOrCreateClassAndDepthFlagsSymbolRef());
classFlag = TR::Node::create(TR::l2i, 1, classFlag);
}
TR::Node *andConstNode = TR::Node::create(classFlag, TR::iconst, 0, TR::Compiler->cls.flagValueForArrayCheck(comp()));
TR::Node * andNode = TR::Node::create(TR::iand, 2, classFlag, andConstNode);
TR::Node *cmp = TR::Node::createif(TR::ificmpne, andNode, andConstNode, _exitGotoTarget);
TR::Node *classFlag = comp()->fej9()->testIsClassArrayType(vftLoad);
TR::Node *zeroNode = TR::Node::iconst(classFlag, 0);
TR::Node *cmp = TR::Node::createif(TR::ificmpeq, classFlag, zeroNode, _exitGotoTarget);
if (addLoopEntryPrepDep(LoopEntryPrep::TEST, cmp, deps, visited) == NULL)
{
dumpOptDetailsFailedToCreateTest("array type", node->getFirstChild());
Expand Down

0 comments on commit a62b60b

Please sign in to comment.