Skip to content

Commit

Permalink
Enable recognized Call for Class.isAssignableFrom on Z
Browse files Browse the repository at this point in the history
- add supportsInliningOfIsAssignableFrom() to Z
- enables transformation of call to Class.isAssignableFrom to
  icall jitCheckAssignable
- note: line 4200 in J9CodeGenerator is there as a placeholder until
  inlined tests are added to the evaluator

Signed-off-by: Matthew Hall <[email protected]>
  • Loading branch information
matthewhall2 committed Nov 13, 2024
1 parent 63d0568 commit edd3d3e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion runtime/compiler/z/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,7 @@ J9::Z::CodeGenerator::inlineDirectCall(
ReduceSynchronizedFieldLoad::inlineSynchronizedFieldLoad(node, cg);
return true;
}
else if (node->getSymbolReference()->getReferenceNumber() == TR::checkAssignable)
else if (node->getSymbolReference()->getReferenceNumber() == TR_checkAssignable)
{
resultReg = TR::TreeEvaluator::inlineCheckAssignableFromEvaluator(node, cg);
return true;
Expand Down
5 changes: 2 additions & 3 deletions runtime/compiler/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11479,13 +11479,12 @@ J9::Z::TreeEvaluator::VMarrayCheckEvaluator(TR::Node *node, TR::CodeGenerator *c
/////////////////////////////////////////////////////////////////////////////////
static bool inlineIsAssignableFrom(TR::Node *node, TR::CodeGenerator *cg)
{
static char *disable = feGetEnv("TR_disableInlineIsAssignableFrom");
static char *disable = feGetEnv("TR_DisableInliningOfIsAssignableFrom");
TR::Compilation *comp = cg->comp();
TR_J9VMBase *fej9 = (TR_J9VMBase *)(comp->fe());

if (disable)
return false;

TR::Node *thisClass = node->getFirstChild();
if (thisClass->getOpCodeValue() == TR::aloadi &&
thisClass->getFirstChild()->getOpCodeValue() == TR::loadaddr)
Expand Down Expand Up @@ -11644,7 +11643,7 @@ TR::Register *J9::Z::TreeEvaluator::inlineCheckAssignableFromEvaluator(TR::Node
deps->addPostCondition(checkClassReg, TR::RealRegister::AssignAny);
}
deps->addPostCondition(resultReg, TR::RealRegister::AssignAny);

generateRIInstruction(cg, TR::InstOpCode::LHI, node, resultReg, 1); // load initial value for result
generateS390BranchInstruction(cg, TR::InstOpCode::BRC, TR::InstOpCode::COND_BRC, node, helperCallLabel); // branch to OOL section - will make more sense when inlined tests are added
TR_S390OutOfLineCodeSection *outlinedSlowPath = new (cg->trHeapMemory()) TR_S390OutOfLineCodeSection(helperCallLabel, doneLabel, cg);
Expand Down
19 changes: 18 additions & 1 deletion runtime/compiler/z/codegen/S390CHelperLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,23 @@ class RealRegisterManager
TR::CodeGenerator* _cg;
};

static bool getIsFastPathOnly(TR::Node * callNode, TR::CodeGenerator * cg)
{
auto opCode = callNode->getOpCodeValue();
if (opCode == TR::instanceof)
{
return true;
}

TR::MethodSymbol * methodSymbol = callNode->getSymbol()->getMethodSymbol();
TR::SymbolReference * ref = callNode->getSymbolReference();
if (ref == cg->comp()->getSymRefTab()->findOrCreateRuntimeHelper(TR_checkAssignable))
{
return true;
}
return false;
}

/** \brief Build a JIT helper call.
* \details
* It generates sequence that prepares parameters for the JIT helper function and generate a helper call.
Expand All @@ -264,7 +281,7 @@ TR::Register * J9::Z::CHelperLinkage::buildDirectDispatch(TR::Node * callNode, T
RealRegisterManager RealRegisters(cg());
bool isHelperCallWithinICF = deps != NULL;
// TODO: Currently only jitInstanceOf is fast path helper. Need to modify following condition if we add support for other fast path only helpers
bool isFastPathOnly = callNode->getOpCodeValue() == TR::instanceof;
bool isFastPathOnly = getIsFastPathOnly(callNode, cg());
traceMsg(comp(),"%s: Internal Control Flow in OOL : %s\n",callNode->getOpCode().getName(),isHelperCallWithinICF ? "true" : "false" );
for (int i = TR::RealRegister::FirstGPR; i < TR::RealRegister::NumRegisters; i++)
{
Expand Down

0 comments on commit edd3d3e

Please sign in to comment.