Skip to content

Commit

Permalink
Merge pull request #17714 from JamesKingdon/multianewarray_z
Browse files Browse the repository at this point in the history
  • Loading branch information
joransiu authored Jul 1, 2023
2 parents 6fb595e + b67e428 commit 7c0f636
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions runtime/compiler/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4664,9 +4664,9 @@ J9::Z::TreeEvaluator::anewArrayEvaluator(TR::Node * node, TR::CodeGenerator * cg

///////////////////////////////////////////////////////////////////////////////////////
// multianewArrayEvaluator: multi-dimensional new array of objects
// NB Must only be used for arrays of at least two dimensions
///////////////////////////////////////////////////////////////////////////////////////
TR::Register *
J9::Z::TreeEvaluator::multianewArrayEvaluator(TR::Node * node, TR::CodeGenerator * cg)
static TR::Register * generateMultianewArrayWithInlineAllocators(TR::Node *node, TR::CodeGenerator *cg)
{
#define iComment(str) if (compDebug) compDebug->addInstructionComment(cursor, (const_cast<char*>(str)));
TR::Compilation *comp = cg->comp();
Expand Down Expand Up @@ -4977,6 +4977,45 @@ J9::Z::TreeEvaluator::multianewArrayEvaluator(TR::Node * node, TR::CodeGenerator
#undef iComment
}


///////////////////////////////////////////////////////////////////////////////////////
// Generate code for multianewarray
// Checks the number of dimensions. For 1 dimensional arrays call the helper, for >1 call
// generateMultianewArrayWithInlineAllocators.
///////////////////////////////////////////////////////////////////////////////////////
TR::Register *
J9::Z::TreeEvaluator::multianewArrayEvaluator(TR::Node * node, TR::CodeGenerator * cg)
{
TR::Compilation *comp = cg->comp();
TR_ASSERT_FATAL(comp->target().is64Bit(), "multianewArrayEvaluator is only supported on 64-bit JVMs!");

TR::Node *secondChild = node->getSecondChild(); // Number of dimensions - this is fixed in the bytecode, so compile time constant

// The number of dimensions should always be an iconst
TR_ASSERT_FATAL(secondChild->getOpCodeValue() == TR::iconst, "dims of multianewarray must be iconst");

// Only generate inline code if nDims > 1
uint32_t nDims = secondChild->get32bitIntegralValue();
if (nDims > 1)
{
return generateMultianewArrayWithInlineAllocators(node, cg);
}
else
{
if (comp->getOption(TR_TraceCG))
{
traceMsg(comp, "Disabling inline allocations for multianewarray of dim %d\n", nDims);
}
TR::ILOpCodes opCode = node->getOpCodeValue();
TR::Node::recreate(node, TR::acall);
TR::Register *targetRegister = TR::TreeEvaluator::performCall(node, false, cg);
TR::Node::recreate(node, opCode);
return targetRegister;
}

}


TR::Register *
J9::Z::TreeEvaluator::arraylengthEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
Expand Down

0 comments on commit 7c0f636

Please sign in to comment.