Skip to content

Commit

Permalink
Merge pull request #20545 from knn-k/aarch64onSpinWait
Browse files Browse the repository at this point in the history
Replace Thread.onSpinWait() with a YIELD instruction on AArch64
  • Loading branch information
0xdaryl authored Nov 13, 2024
2 parents 9e312f1 + 9432108 commit 34e3574
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion runtime/compiler/aarch64/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6813,7 +6813,8 @@ bool
J9::ARM64::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&resultReg)
{
TR::CodeGenerator *cg = self();
TR::MethodSymbol * methodSymbol = node->getSymbol()->getMethodSymbol();
TR::Compilation *comp = cg->comp();
TR::MethodSymbol *methodSymbol = node->getSymbol()->getMethodSymbol();
static const bool disableCRC32 = feGetEnv("TR_aarch64DisableCRC32") != NULL;

if (OMR::CodeGeneratorConnector::inlineDirectCall(node, resultReg))
Expand Down Expand Up @@ -6865,6 +6866,21 @@ J9::ARM64::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&result
static bool disableCAEIntrinsic = feGetEnv("TR_DisableCAEIntrinsic") != NULL;
switch (methodSymbol->getRecognizedMethod())
{
case TR::java_lang_Thread_onSpinWait:
{
static char *disableOSW = feGetEnv("TR_noYieldOnSpinWait");
if (!disableOSW)
{
generateInstruction(cg, TR::InstOpCode::yield, node);
if (comp->getOption(TR_TraceCG))
{
traceMsg(comp, "insert YIELD for onSpinWait: node=%p, %s\n", node, comp->signature());
}
return true;
}
break;
}

case TR::java_nio_Bits_keepAlive:
case TR::java_lang_ref_Reference_reachabilityFence:
{
Expand Down

0 comments on commit 34e3574

Please sign in to comment.