Skip to content

Commit

Permalink
Remove Unsafe.putOrdered call duplication
Browse files Browse the repository at this point in the history
Since Unsafe.putOrdered is fully supported through acquire/release symbols, we
no longer need to duplicate the call tree to prevent incorrect optimizations.

Signed-off-by: Spencer Comin <spencer.comin@ibm.com>
  • Loading branch information
Spencer-Comin committed Nov 4, 2024
1 parent 302de12 commit 43d5d30
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 99 deletions.
12 changes: 0 additions & 12 deletions runtime/compiler/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,18 +934,6 @@ J9::CodeGenerator::lowerTreeIfNeeded(
}
}

// J9
if (node->getOpCode().isCall() &&
node->isUnsafePutOrderedCall() &&
node->isDontInlinePutOrderedCall())
{
// Remove this treetop
tt->getPrevTreeTop()->setNextTreeTop(tt->getNextTreeTop());
tt->getNextTreeTop()->setPrevTreeTop(tt->getPrevTreeTop());
tt->getNode()->recursivelyDecReferenceCount();
return;
}

// J9
if (!self()->comp()->getOption(TR_DisableUnsafe) &&
node->getOpCode().isCall() &&
Expand Down
63 changes: 0 additions & 63 deletions runtime/compiler/il/J9Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2071,62 +2071,6 @@ J9::Node::chkSpineCheckWithArrayElementChild()
return self()->getOpCode().isSpineCheck() && _flags.testAny(spineCHKWithArrayElementChild);
}

bool
J9::Node::isUnsafePutOrderedCall()
{
if (!self()->getOpCode().isCall())
return false;

if (!self()->getSymbol()->isMethod())
return false;

bool isPutOrdered = false;
TR::MethodSymbol *symbol = self()->getSymbol()->getMethodSymbol();
if (!symbol)
return false;

if ((symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putBooleanOrdered_jlObjectJZ_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putByteOrdered_jlObjectJB_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putCharOrdered_jlObjectJC_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putShortOrdered_jlObjectJS_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putIntOrdered_jlObjectJI_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putLongOrdered_jlObjectJJ_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putFloatOrdered_jlObjectJF_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putDoubleOrdered_jlObjectJD_V) ||
(symbol->getRecognizedMethod() == TR::sun_misc_Unsafe_putObjectOrdered_jlObjectJjlObject_V))
isPutOrdered = true;

return isPutOrdered;
}

bool
J9::Node::isDontInlinePutOrderedCall()
{
TR_ASSERT(self()->getOpCode().isCall(), " Can only call this routine for a call node \n");
bool isPutOrdered = self()->isUnsafePutOrderedCall();

TR_ASSERT(isPutOrdered, "attempt to set dontInlinePutOrderedCall flag and not a putOrdered call");
if (isPutOrdered)
return _flags.testAny(dontInlineUnsafePutOrderedCall);
else
return false;
}

void
J9::Node::setDontInlinePutOrderedCall(TR::Compilation *comp)
{
TR_ASSERT(self()->getOpCode().isCall(), " Can only call this routine for a call node \n");
bool isPutOrdered = self()->isUnsafePutOrderedCall();

TR_ASSERT(isPutOrdered, "attempt to set dontInlinePutOrderedCall flag and not a putOrdered call");
if (isPutOrdered)
{
if (performNodeTransformation1(comp, "O^O NODE FLAGS: Setting dontInlineUnsafePutOrderedCall flag on node %p\n", self()))
_flags.set(dontInlineUnsafePutOrderedCall);
}

}

bool
J9::Node::isUnsafeCopyMemoryIntrinsic()
{
Expand All @@ -2148,13 +2092,6 @@ J9::Node::isUnsafeCopyMemoryIntrinsic()
return false;
}

bool
J9::Node::chkDontInlineUnsafePutOrderedCall()
{
bool isPutOrdered = self()->isUnsafePutOrderedCall();
return isPutOrdered && _flags.testAny(dontInlineUnsafePutOrderedCall);
}

bool
J9::Node::isUnsafeGetPutCASCallOnNonArray()
{
Expand Down
7 changes: 0 additions & 7 deletions runtime/compiler/il/J9Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,6 @@ class OMR_EXTENSIBLE Node : public OMR::NodeConnector
void setSpineCheckWithArrayElementChild(bool v, TR::Compilation *comp);
bool chkSpineCheckWithArrayElementChild();

// Flags used by call nodes
bool isUnsafePutOrderedCall();
bool isDontInlinePutOrderedCall();
void setDontInlinePutOrderedCall(TR::Compilation *comp);
bool chkDontInlineUnsafePutOrderedCall();

/**
* Checks and return true if the callNode is JNI Call to Unsafe.copyMemory
*/
Expand Down Expand Up @@ -457,7 +451,6 @@ class OMR_EXTENSIBLE Node : public OMR::NodeConnector
spineCHKWithArrayElementChild = 0x00004000,

// Flags used by call nodes
dontInlineUnsafePutOrderedCall = 0x00000800, ///< unsafe putOrdered calls
processedByCallCloneConstrain = 0x00100000,
unsafeGetPutOnNonArray = 0x00200000,
DAAVariableSlowCall = 0x00400000, ///< Used to avoid Variable precision DAA optimization
Expand Down
17 changes: 0 additions & 17 deletions runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,15 +1469,6 @@ TR_J9InlinerPolicy::createUnsafePutWithOffset(TR::ResolvedMethodSymbol *calleeSy
TR::SymbolReference * symRef = comp()->getSymRefTab()->findOrCreateUnsafeSymbolRef(type, true, false, accessMode);
TR::Node *orderedCallNode = NULL;

if (accessMode == TR::Symbol::AcqRelAccess)
{
symRef->getSymbol()->setAcqRel();
orderedCallNode = callNodeTreeTop->getNode()->duplicateTree();
orderedCallNode->getFirstChild()->setDontInlinePutOrderedCall(comp());

debugTrace(tracer(), "\t Duplicate Tree for ordered call, orderedCallNode = %p\n", orderedCallNode);
}

static char *disableIllegalWriteReport = feGetEnv("TR_DisableIllegalWriteReport");
TR::TreeTop* reportFinalFieldModification = NULL;
if (!disableIllegalWriteReport && !comp()->getOption(TR_DisableGuardedStaticFinalFieldFolding))
Expand Down Expand Up @@ -2788,14 +2779,6 @@ TR_J9InlinerPolicy::isInlineableJNI(TR_ResolvedMethod *method,TR::Node *callNode
if (comp->getOption(TR_DisableUnsafe))
return false;

// If this put ordered call node has already been inlined, do not inline it again (JTC-JAT 71313)
if (callNode && callNode->isUnsafePutOrderedCall() && callNode->isDontInlinePutOrderedCall())
{
debugTrace(tracer(), "Unsafe Inlining: Unsafe Call %p already inlined\n", callNode);

return false;
}

if ((TR::Compiler->vm.canAnyMethodEventsBeHooked(comp) && !comp->fej9()->methodsCanBeInlinedEvenIfEventHooksEnabled(comp)) ||
(comp->fej9()->isAnyMethodTracingEnabled(method->getPersistentIdentifier()) &&
!comp->fej9()->traceableMethodsCanBeInlined()))
Expand Down

0 comments on commit 43d5d30

Please sign in to comment.