Skip to content

Commit

Permalink
Generate inline class equality test for Class.isAssignableFrom on Z
Browse files Browse the repository at this point in the history
adds class equality check as first check; calls C Helper in OOL section
on fail

Signed-off-by: Matthew Hall <[email protected]>
  • Loading branch information
matthewhall2 committed Dec 10, 2024
1 parent 9725406 commit 81d885e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions runtime/compiler/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11633,8 +11633,6 @@ J9::Z::TreeEvaluator::VMarrayCheckEvaluator(TR::Node *node, TR::CodeGenerator *c
return 0;
}



/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
static bool inlineIsAssignableFrom(TR::Node *node, TR::CodeGenerator *cg)
Expand Down Expand Up @@ -11789,23 +11787,24 @@ static bool inlineIsAssignableFrom(TR::Node *node, TR::CodeGenerator *cg)

TR::Register *J9::Z::TreeEvaluator::inlineCheckAssignableFromEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Register *thisClassReg = cg->evaluate(node->getFirstChild());
TR::Register *checkClassReg = cg->evaluate(node->getSecondChild());
TR::Register *fromClassReg = cg->evaluate(node->getFirstChild());
TR::Register *toClassReg = cg->evaluate(node->getSecondChild());

TR::Register *resultReg = cg->allocateRegister();
TR::LabelSymbol *helperCallLabel = generateLabelSymbol(cg);
TR::LabelSymbol *doneLabel = generateLabelSymbol(cg);
TR::LabelSymbol *successLabel = generateLabelSymbol(cg);

TR::RegisterDependencyConditions* deps = new (cg->trHeapMemory()) TR::RegisterDependencyConditions(0, 3, cg);
deps->addPostCondition(thisClassReg, TR::RealRegister::AssignAny);
deps->addPostConditionIfNotAlreadyInserted(checkClassReg, TR::RealRegister::AssignAny);
deps->addPostCondition(resultReg, TR::RealRegister::AssignAny);
TR::LabelSymbol* cFlowRegionStart = generateLabelSymbol(cg);
generateS390LabelInstruction(cg, TR::InstOpCode::label, node, cFlowRegionStart);
cFlowRegionStart->setStartInternalControlFlow();
generateS390CompareAndBranchInstruction(cg, TR::InstOpCode::getCmpRegOpCode(), node, toClassReg, fromClassReg, TR::InstOpCode::COND_BE, successLabel, false, false);

/*
* TODO: add inlined tests (classEqualityTest, SuperclassTest, etc)
* TODO: add inlined tests (SuperclassTest, cast class cache, etc)
* Inlined tests will be used when possible, or will jump to the OOL section
* and perform the tests using the CHelper when not possible
*/
*/

generateS390BranchInstruction(cg, TR::InstOpCode::BRC, TR::InstOpCode::COND_BRC, node, helperCallLabel);
TR_S390OutOfLineCodeSection *outlinedSlowPath = new (cg->trHeapMemory()) TR_S390OutOfLineCodeSection(helperCallLabel, doneLabel, cg);
Expand All @@ -11818,9 +11817,17 @@ TR::Register *J9::Z::TreeEvaluator::inlineCheckAssignableFromEvaluator(TR::Node
generateS390BranchInstruction(cg, TR::InstOpCode::BRC, TR::InstOpCode::COND_BRC, node, doneLabel); // exit OOL section
outlinedSlowPath->swapInstructionListsWithCompilation();

generateS390LabelInstruction(cg, TR::InstOpCode::label, node, successLabel, deps);
generateRIInstruction(cg, TR::InstOpCode::getLoadHalfWordImmOpCode(), node, resultReg, 1);

TR::RegisterDependencyConditions* deps = new (cg->trHeapMemory()) TR::RegisterDependencyConditions(0, 3, cg);
deps->addPostCondition(fromClassReg, TR::RealRegister::AssignAny);
deps->addPostConditionIfNotAlreadyInserted(toClassReg, TR::RealRegister::AssignAny);
deps->addPostCondition(resultReg, TR::RealRegister::AssignAny);

generateS390LabelInstruction(cg, TR::InstOpCode::label, node, doneLabel, deps);
doneLabel->setEndInternalControlFlow();
node->setRegister(resultReg);

return resultReg;
}

Expand Down

0 comments on commit 81d885e

Please sign in to comment.