Skip to content

Commit

Permalink
Fix z selectEvaluator to ensure correct gc flags are set on result re…
Browse files Browse the repository at this point in the history
…gister

- Use `TR::Register::containsCollectedReference()` instead of
  `TR::Node::isNotCollected()` to check if the false register contains a
  collected reference. `isNotCollected` should not be used after lower trees as
  it does not handle nodes that convert between integral and address types.

- Add assert which will fail if one of the children of the select node is an
  internal pointer. Internal pointers cannot be handled since we cannot set the
  pinning array on the result register without knowing which side of the select
  will be taken.

Issue: eclipse-openj9/openj9#8397

Signed-off-by: Ryan Shukla <ryans@ibm.com>
  • Loading branch information
mayshukla committed Sep 2, 2020
1 parent c0843bb commit a2b3d90
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions compiler/z/codegen/ControlFlowEvaluator.cpp
Expand Up @@ -2549,6 +2549,24 @@ OMR::Z::TreeEvaluator::selectEvaluator(TR::Node *node, TR::CodeGenerator *cg)

TR::Register *falseReg = cg->evaluate(falseVal); //cg->gprClobberEvaluate(falseVal);

// Internal pointers cannot be handled since we cannot set the pinning array
// on the result register without knowing which side of the select will be
// taken.
TR_ASSERT_FATAL_WITH_NODE(
node,
!trueReg->containsInternalPointer() && !falseReg->containsInternalPointer(),
"Select nodes cannot have children that are internal pointers"
);
if (falseReg->containsCollectedReference())
{
if (cg->comp()->getOption(TR_TraceCG))
traceMsg(
cg->comp(),
"Setting containsCollectedReference on result of select node in register %s\n",
cg->getDebug()->getName(trueReg));
trueReg->setContainsCollectedReference();
}

if (comp->getOption(TR_TraceCG))
traceMsg(comp, "Done evaluating child %p in reg %p and %p in reg %p\n",trueVal,trueReg,falseVal,falseReg);

Expand Down Expand Up @@ -2678,9 +2696,6 @@ OMR::Z::TreeEvaluator::selectEvaluator(TR::Node *node, TR::CodeGenerator *cg)
}
}

if (!node->isNotCollected())
trueReg->setContainsCollectedReference();

if (comp->getOption(TR_TraceCG))
traceMsg(comp, "Setting node %p register to %p\n",node,trueReg);
node->setRegister(trueReg);
Expand Down

0 comments on commit a2b3d90

Please sign in to comment.