Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid mishandling of immutable objects that escape in cold blocks #4282

Merged
merged 1 commit into from
Feb 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 34 additions & 7 deletions runtime/compiler/optimizer/EscapeAnalysis.cpp
Expand Up @@ -4731,7 +4731,12 @@ bool TR_EscapeAnalysis::fixupNode(TR::Node *node, TR::Node *parent, TR::NodeChec

if (fieldIsPresentInObject)
{
if (candidate->escapesInColdBlock(_curBlock))
// Special case handling of non-contiguous immmutable object:
// if it escapes in a cold block, need to ensure the temporary
// that replaces it is correctly initialized
if (candidate->escapesInColdBlock(_curBlock)
&& (!isImmutableObject(candidate)
|| candidate->isContiguousAllocation()))
{
// Uh, why are we re-calculating the fieldOffset? Didn't we just do that above?
//
Expand Down Expand Up @@ -4788,6 +4793,8 @@ bool TR_EscapeAnalysis::fixupNode(TR::Node *node, TR::Node *parent, TR::NodeChec
}
}
else // if (!candidate->escapesInColdBlock(_curBlock))
// || (isImmutableObject(candidate)
// && !candidate->isContiguousAllocation()))
{
if (candidate->isContiguousAllocation())
removeThisNode |= fixupFieldAccessForContiguousAllocation(node, candidate);
Expand Down Expand Up @@ -5507,12 +5514,32 @@ bool TR_EscapeAnalysis::fixupFieldAccessForNonContiguousAllocation(TR::Node *nod
valueChild = TR::Node::create(conversionOp, 1, node->getSecondChild());
else
valueChild = node->getSecondChild();
valueChild->incReferenceCount();
node->removeAllChildren();
node->setFirst(valueChild);
node->setNumChildren(1);
TR::Node::recreate(node, newOpCode);
node->setSymbolReference(autoSymRef);

// Special case of non-contiguous immutable object that escapes in
// a cold block: need to ensure the store to the original object
// is preserved for heapification; otherwise, replace the old store
// completely
if (candidate->escapesInColdBlock(_curBlock)
&& isImmutableObject(candidate) && !candidate->isContiguousAllocation())
{
TR::Node *newStore = TR::Node::createWithSymRef(newOpCode, 1, 1, valueChild, autoSymRef);
TR::TreeTop *newTree = TR::TreeTop::create(comp(), newStore);
TR::TreeTop *prev = _curTree->getPrevTreeTop();
prev->join(newTree);
newTree->join(_curTree);

if (trace())
traceMsg(comp(), "Preserve old node [%p] for store to non-contiguous immutable object that escapes in cold block; create new tree [%p] for direct store\n", node, newTree);
}
else
{
valueChild->incReferenceCount();
node->removeAllChildren();
node->setFirst(valueChild);
node->setNumChildren(1);
TR::Node::recreate(node, newOpCode);
node->setSymbolReference(autoSymRef);
}

if (autoSymRef->getSymbol()->getDataType().isVector() &&
!node->getDataType().isVector())
Expand Down