Skip to content

Commit

Permalink
Merge pull request #18154 from klangman/fix-missing-AF-for-StringUTF1…
Browse files Browse the repository at this point in the history
…6-toBytes-transformation

Fix a missing allocationFence in process_java_lang_StringUTF16_toBytes()
  • Loading branch information
vijaysun-omr committed Sep 25, 2023
2 parents 48ce19d + c60f998 commit fb00610
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp
Expand Up @@ -324,7 +324,14 @@ void J9::RecognizedCallTransformer::process_java_lang_StringUTF16_toBytes(TR::Tr
newCallNode->setAndIncChild(3, TR::Node::iconst(0));
newCallNode->setAndIncChild(4, lenNode);

treetop->insertAfter(TR::TreeTop::create(comp(), TR::Node::create(node, TR::treetop, 1, newCallNode)));
TR::TreeTop* newTT = treetop->insertAfter(TR::TreeTop::create(comp(), TR::Node::create(node, TR::treetop, 1, newCallNode)));
// Insert the allocationFence after the arraycopy because the array can be allocated from the non-zeroed TLH
// and therefore we need to make sure no other thread sees stale memory from the array element section.
if (cg()->getEnforceStoreOrder())
{
TR::Node *allocationFence = TR::Node::createAllocationFence(newByteArrayNode, newByteArrayNode);
newTT->insertAfter(TR::TreeTop::create(comp(), allocationFence));
}
}

void J9::RecognizedCallTransformer::process_java_lang_StrictMath_and_Math_sqrt(TR::TreeTop* treetop, TR::Node* node)
Expand Down

0 comments on commit fb00610

Please sign in to comment.