Skip to content

Commit

Permalink
Call NoZeroInit anewarray helper when appropriate on x86
Browse files Browse the repository at this point in the history
If an anewarray allocation must be performed out-of-line, be sure
to call the NoZeroInit version if zero initialization can be avoided.

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed May 28, 2024
1 parent f8d36be commit c098ff4
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions runtime/compiler/x/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7718,17 +7718,44 @@ J9::X86::TreeEvaluator::VMnewEvaluator(
bool enableTLHBatchClearing = fej9->tlhHasBeenCleared();

#ifdef J9VM_GC_NON_ZERO_TLH
// If we can skip zero init, and it is not outlined new, we use the new TLH
// same logic also appears later, but we need to do this before generate the helper call
//
if (node->canSkipZeroInitialization() && (enableTLHBatchClearing || !comp->getOption(TR_DisableDualTLH)) && !realTimeGC)
if (node->canSkipZeroInitialization() &&
(enableTLHBatchClearing || !comp->getOption(TR_DisableDualTLH)) &&
!realTimeGC)
{
// For value types, it should use jitNewValue helper call which is set up before code gen
if ((node->getOpCodeValue() == TR::New)
&& (!TR::Compiler->om.areValueTypesEnabled() || (node->getSymbolReference() != comp->getSymRefTab()->findOrCreateNewValueSymbolRef(comp->getMethodSymbol()))))
node->setSymbolReference(comp->getSymRefTab()->findOrCreateNewObjectNoZeroInitSymbolRef(comp->getMethodSymbol()));
else if (node->getOpCodeValue() == TR::newarray)
node->setSymbolReference(comp->getSymRefTab()->findOrCreateNewArrayNoZeroInitSymbolRef(comp->getMethodSymbol()));
// Choose appropriate helper call if zero initialization can be skipped
//
TR::SymbolReference *noZeroInitSymRef = NULL;
TR::SymbolReferenceTable *symRefTab = comp->getSymRefTab();

switch (node->getOpCodeValue())
{
case TR::New:
// For value types, it should use the jitNewValue helper call which
// is set up before codegen
//
if (!TR::Compiler->om.areValueTypesEnabled() ||
(node->getSymbolReference() != symRefTab->findOrCreateNewValueSymbolRef(comp->getMethodSymbol())))
{
noZeroInitSymRef = symRefTab->findOrCreateNewObjectNoZeroInitSymbolRef(comp->getMethodSymbol());
}
break;

case TR::newarray:
noZeroInitSymRef = symRefTab->findOrCreateNewArrayNoZeroInitSymbolRef(comp->getMethodSymbol());
break;

case TR::anewarray:
noZeroInitSymRef = symRefTab->findOrCreateANewArrayNoZeroInitSymbolRef(comp->getMethodSymbol());
break;

default:
break;
}

if (noZeroInitSymRef)
{
node->setSymbolReference(noZeroInitSymRef);
}

if (comp->getOption(TR_TraceCG))
traceMsg(comp, "SKIPZEROINIT: for %p, change the symbol to %p ", node, node->getSymbolReference());
Expand Down

0 comments on commit c098ff4

Please sign in to comment.