Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
A crash was occuring in Unsafe.get/put() case (6) when trying to modify
the CFG to include the newly generated directAccessBlock. To avoid this,
we can simply append the directAccessTreeTop onto the previous block
(beforeCallBlock), which elimiates the need to update the CFG, since no
new blocks are added. Additionally, without this commit, these two blocks
(in addition to the one after the directAccessBlock, joinBlock), would
get merged during block simplication anyways: so this fix eliminates the
need to perform that optimization later down the line.

Signed-off-by: midronij <[email protected]>
  • Loading branch information
midronij authored and luke-li-2003 committed Sep 23, 2024
1 parent 3d2f90b commit df2ad85
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,17 +1065,8 @@ TR_J9InlinerPolicy::genCodeForUnsafeGetPut(TR::Node* unsafeAddress,
//SPECIAL CASE
if (!directAccessWithConversionTreeTop && conversionNeeded)
{
//Generating block for arrayDirectAccess (direct access with conversion)
arrayDirectAccessBlock = TR::Block::createEmptyBlock(callNodeTreeTop->getNode(), comp(),
joinBlock->getFrequency());
arrayDirectAccessBlock->append(arrayDirectAccessTreeTop);
beforeCallBlock->getExit()->insertTreeTopsAfterMe(arrayDirectAccessBlock->getEntry(), arrayDirectAccessBlock->getExit());

//add arrayDirectAccessBlock to cfg
cfg->addNode(arrayDirectAccessBlock);
cfg->addEdge(TR::CFGEdge::createEdge(beforeCallBlock, arrayDirectAccessBlock, trMemory()));
cfg->addEdge(TR::CFGEdge::createEdge(arrayDirectAccessBlock, joinBlock, trMemory()));
cfg->removeEdge(beforeCallBlock, joinBlock);
//Since no runtime tests are being performed, we can simply append the arrayDirectAccessTreeTop to beforeCallBlock
beforeCallBlock->append(arrayDirectAccessTreeTop);
}
else
{
Expand All @@ -1093,17 +1084,8 @@ TR_J9InlinerPolicy::genCodeForUnsafeGetPut(TR::Node* unsafeAddress,
}
else // CASE (6)
{
//Generating block for direct access
directAccessBlock = TR::Block::createEmptyBlock(callNodeTreeTop->getNode(), comp(),
joinBlock->getFrequency());
directAccessBlock->append(directAccessTreeTop);
beforeCallBlock->getExit()->insertTreeTopsAfterMe(directAccessBlock->getEntry(), directAccessBlock->getExit());

//add directAccessBlock to cfg
cfg->addNode(directAccessBlock);
cfg->addEdge(TR::CFGEdge::createEdge(beforeCallBlock, directAccessBlock, trMemory()));
cfg->addEdge(TR::CFGEdge::createEdge(directAccessBlock, joinBlock, trMemory()));
cfg->removeEdge(beforeCallBlock, joinBlock);
//Since no runtime tests are being performed, we can simply append the directAccessTreeTop to beforeCallBlock
beforeCallBlock->append(directAccessTreeTop);
}

if (directAccessBlock)
Expand Down

0 comments on commit df2ad85

Please sign in to comment.