Skip to content

Commit

Permalink
Use baseObj for Unsafe.CAS CardMarking for OffHeap on Z
Browse files Browse the repository at this point in the history
When evaluating Unsafe.CAS while running with Balanced GC and OffHeap
enabled, if the object child is the dataAddrPointer load, pass the
baseObj to VMCardCheckEvaluator for correct card marking.

Using the VMCardCheckEvaluator ability to clobberDstReg, we use
baseObjReg instead of the temp epReg.

Signed-off-by: Abdulrahman Alattas <[email protected]>
  • Loading branch information
rmnattas committed Sep 30, 2024
1 parent 15acde9 commit 19953fd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions runtime/compiler/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12013,6 +12013,12 @@ J9::Z::TreeEvaluator::VMinlineCompareAndSwap(TR::Node *node, TR::CodeGenerator *

// Eval old and new vals
//
#if defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION)
bool isObjOffHeapDataAddr = (TR::Compiler->om.writeBarrierType() == gc_modron_wrtbar_cardmark_incremental && TR::Compiler->om.isOffHeapAllocationEnabled() && objNode->isDataAddrPointer());
TR::Register *baseObjReg = NULL;
if (isObjOffHeapDataAddr)
baseObjReg = cg->gprClobberEvaluate(objNode->getFirstChild());
#endif /* defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION) */
objReg = cg->evaluate(objNode);
oldVReg = cg->gprClobberEvaluate(oldVNode); // CS oldReg, newReg, OFF(objReg)
newVReg = cg->evaluate(newVNode); // oldReg is clobbered
Expand Down Expand Up @@ -12110,15 +12116,24 @@ J9::Z::TreeEvaluator::VMinlineCompareAndSwap(TR::Node *node, TR::CodeGenerator *
if (isObj && (doWrtBar || doCrdMrk))
{
TR::LabelSymbol *doneLabelWrtBar = generateLabelSymbol(cg);
TR::Register *epReg = cg->allocateRegister();
TR::Register *epReg;
#if defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION)
if (!isObjOffHeapDataAddr)
#endif /* defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION) */
epReg = cg->allocateRegister();
TR::Register *raReg = cg->allocateRegister();
TR::RegisterDependencyConditions* condWrtBar = new (cg->trHeapMemory()) TR::RegisterDependencyConditions(0, 5, cg);
condWrtBar->addPostCondition(objReg, TR::RealRegister::GPR1);
if (compressedValueRegister != newVReg)
condWrtBar->addPostCondition(newVReg, TR::RealRegister::AssignAny); //defect 92001
if (compressedValueRegister != objReg) // add this because I got conflicting dependencies on GPR1 and GPR2!
condWrtBar->addPostCondition(compressedValueRegister, TR::RealRegister::GPR2); //defect 92001
condWrtBar->addPostCondition(epReg, cg->getEntryPointRegister());
#if defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION)
if (isObjOffHeapDataAddr)
condWrtBar->addPostCondition(baseObjReg, cg->getEntryPointRegister());
else
#endif /* defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION) */
condWrtBar->addPostCondition(epReg, cg->getEntryPointRegister());
condWrtBar->addPostCondition(raReg, cg->getReturnAddressRegister());
// Cardmarking is not inlined for gencon. Consider doing so when perf issue arises.
if (doWrtBar)
Expand All @@ -12135,7 +12150,12 @@ J9::Z::TreeEvaluator::VMinlineCompareAndSwap(TR::Node *node, TR::CodeGenerator *

else if (doCrdMrk)
{
VMCardCheckEvaluator(node, objReg, epReg, condWrtBar, cg, false, doneLabelWrtBar, false);
#if defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION)
if (isObjOffHeapDataAddr)
VMCardCheckEvaluator(node, baseObjReg, NULL, condWrtBar, cg, true, doneLabelWrtBar, false);
else
#endif /* defined(J9VM_GC_ENABLE_SPARSE_HEAP_ALLOCATION) */
VMCardCheckEvaluator(node, objReg, epReg, condWrtBar, cg, false, doneLabelWrtBar, false);
// true #1 -> copy of objReg just happened, it's safe to clobber tempReg
// false #2 -> Don't do compile time check for heap obj
}
Expand Down

0 comments on commit 19953fd

Please sign in to comment.