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 1aabbc5 commit 87ce953
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
7 changes: 7 additions & 0 deletions runtime/compiler/z/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4194,3 +4194,10 @@ J9::Z::CodeGenerator::supportsTrapsInTMRegion()
{
return self()->comp()->target().isZOS();
}

bool J9::Z::CodeGenerator::supportsInliningOfIsAssignableFrom()
{
return false; // will be taken out once new inlined tests are added
static const bool disableInliningOfIsAssignableFrom = feGetEnv("TR_DisableInliningOfIsAssignableFrom") != NULL;
return !disableInliningOfIsAssignableFrom;
}
1 change: 1 addition & 0 deletions runtime/compiler/z/codegen/J9CodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class OMR_EXTENSIBLE CodeGenerator : public J9::CodeGenerator
int32_t getPDMulEncodedPrecision(TR::Node *pdmul);
int32_t getPDMulEncodedPrecision(TR::Node *pdmul, int32_t exponent);
bool callUsesHelperImplementation(TR::Symbol *sym);
bool supportsInliningOfIsAssignableFrom();

uint32_t getLongToPackedFixedSize() { return TR_LONG_TO_PACKED_SIZE; }
uint32_t getIntegerToPackedFixedSize() { return TR_INTEGER_TO_PACKED_SIZE; }
Expand Down
6 changes: 2 additions & 4 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 @@ static TR::Register* checkAssignableEvaluator(TR::Node *node, TR::CodeGenerator
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 All @@ -11671,7 +11670,6 @@ TR::Register *J9::Z::TreeEvaluator::directCallEvaluator(TR::Node *node, TR::Code
switch (symRef->getReferenceNumber())
{
case TR_checkAssignable:
printf("Calling evaluator\n");
return checkAssignableEvaluator(node, cg);
default:
break;
Expand Down
1 change: 0 additions & 1 deletion runtime/compiler/z/codegen/J9TreeEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class OMR_EXTENSIBLE TreeEvaluator: public J9::TreeEvaluator
static TR::Register *evaluateNULLCHKWithPossibleResolve(TR::Node *node, bool needResolution, TR::CodeGenerator *cg);
static float interpreterProfilingInstanceOfOrCheckCastTopProb(TR::CodeGenerator * cg, TR::Node * node);
static TR::Register *directCallEvaluator(TR::Node *node, TR::CodeGenerator *cg);


/**
* \brief
Expand Down
16 changes: 15 additions & 1 deletion runtime/compiler/z/codegen/S390CHelperLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ 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 +278,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 87ce953

Please sign in to comment.