Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z: Accelerate inlining Thread.onSpinWait() #20714

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions runtime/compiler/z/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4043,6 +4043,14 @@ J9::Z::CodeGenerator::inlineDirectCall(
return resultReg != NULL;
}
break;
case TR::java_lang_Thread_onSpinWait:
static char *disableOSW = feGetEnv("TR_noPauseOnSpinWait");
if (!disableOSW)
{
resultReg = TR::TreeEvaluator::inlineOnSpinWait(node, cg);
return true;
}
break;

default:
break;
Expand Down
15 changes: 15 additions & 0 deletions runtime/compiler/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14665,3 +14665,18 @@ J9::Z::TreeEvaluator::inlineIntegerStringSize(TR::Node* node, TR::CodeGenerator*

return node->setRegister(lengthReg);
}

TR::Register*
J9::Z::TreeEvaluator::inlineOnSpinWait(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Instruction* cursor = new (cg->trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 2, node, cg);

TR::Compilation *comp = cg->comp();
static const bool printIt = feGetEnv("TR_showPauseOnSpinWait") != NULL;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TR_showPauseOnSpinWait would be a little misleading since "PAUSE" instruction is x86 specific but I have to use the same env variable because it was used in shared code and x86!

if (printIt && comp->getOption(TR_TraceCG))
{
traceMsg(comp, "Insert NOP for onSpinWait : node=%p, %s\n", node, comp->signature());
}

return NULL;
}
11 changes: 11 additions & 0 deletions runtime/compiler/z/codegen/J9TreeEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ class OMR_EXTENSIBLE TreeEvaluator: public J9::TreeEvaluator
static TR::Register* inlineUTF16BEEncode (TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *inlineCRC32CUpdateBytes(TR::Node *node, TR::CodeGenerator *cg, bool isDirectBuffer);

/**
* \brief
* Accelerate inlining onSpinWait() method.
*
* \param node the method call node.
* \param cg the code generator.
*
* \return NULL
*/
static TR::Register *inlineOnSpinWait(TR::Node *node, TR::CodeGenerator *cg);

static TR::Register *zdloadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *zdloadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *zdstoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
Expand Down