Skip to content

Commit

Permalink
Update BCDCHK uncommoning for off-heap
Browse files Browse the repository at this point in the history
Update BCDCHK uncommoning for off-heap because address node of BCDCHK
can be aloadi with single child if off-heap is enabled.

Signed-off-by: Shubham Verma <[email protected]>
  • Loading branch information
VermaSh committed Oct 4, 2024
1 parent 79984d0 commit 8e4f933
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
41 changes: 34 additions & 7 deletions runtime/compiler/z/codegen/UncommonBCDCHKAddressNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,44 @@ UncommonBCDCHKAddressNode::perform()
{
TR::Node* pdOpNode = node->getFirstChild();
TR::Node* oldAddressNode = node->getSecondChild();
TR_ASSERT(pdOpNode && oldAddressNode, "Unexpected null PD opNode or address node under BCDCHK");
TR_ASSERT(oldAddressNode->getNumChildren() == 2, "Expecting 2 children under address node of BCDCHK.");
TR_ASSERT_FATAL_WITH_NODE(node, pdOpNode && oldAddressNode, "Unexpected null PD opNode or address node under BCDCHK");

TR::ILOpCodes addressOp = oldAddressNode->getOpCodeValue();
TR_ASSERT((addressOp == TR::aladd || addressOp == TR::aiadd), "Unexpected addressNode opcode");
TR_ASSERT_FATAL_WITH_NODE(node,
oldAddressNode->isDataAddrPointer() && oldAddressNode->getNumChildren() == 1
|| ((addressOp == TR::aladd || addressOp == TR::aiadd) && oldAddressNode->getNumChildren() == 2),
"Expecting either a dataAddrPointer node with 1 child or a aladd/aiadd with 2 children under address node of BCDCHK.");

TR::ILOpCodes addressOp = oldAddressNode->getOpCodeValue();
if(oldAddressNode->getReferenceCount() > 1)
{
TR::Node* newAddressNode = TR::Node::create(node, addressOp, 2,
oldAddressNode->getFirstChild(),
oldAddressNode->getSecondChild());
TR::Node* newAddressNode = NULL;
if (oldAddressNode->getOpCodeValue() == TR::aloadi)
{
/* Expected tree structure (probably just loading first array element because offset is 0)
* aloadi <contiguousArrayDataAddrFieldSymbol>
* load array_object
*/
newAddressNode = TR::TransformUtil::generateArrayElementAddressTrees(comp(), oldAddressNode->getFirstChild());
}
else
{
/* Expected tree structures
* 1. non off-heap mode
* aladd/aiadd
* load array_object
* array_element_offset
*
* 2. off-heap enabled
* aladd/aiadd
* aloadi <contiguousArrayDataAddrFieldSymbol>
* load array_object
* array_element_offset
*/
newAddressNode = TR::Node::create(node, addressOp, 2,
oldAddressNode->getFirstChild(),
oldAddressNode->getSecondChild());
}

node->setAndIncChild(1, newAddressNode);
oldAddressNode->decReferenceCount();
traceMsg(comp(), "%sReplacing node %s [%p] with [%p]\n",
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/z/codegen/UncommonBCDCHKAddressNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "env/TRMemory.hpp"
#include "il/Node.hpp"
#include "infra/List.hpp"
#include "optimizer/TransformUtil.hpp"

/**
* \brief The Uncommon BCDCHK Address Node codegen phase is designed to cope with incorrect OOL PD copy problem
Expand Down

0 comments on commit 8e4f933

Please sign in to comment.