Skip to content

Commit f124c39

Browse files
committed
Recognize Thread.onSpinWait() on Power
Thread.onSpinWait() is a yield instruction on Power. The method is recognized and inlined into JIT code. Original behavior can be restored by setting the TR_noPauseOnSpinWait environment variable. Signed-off-by: jimmyk <[email protected]>
1 parent b10ba9d commit f124c39

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

runtime/compiler/p/codegen/J9TreeEvaluator.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -11901,8 +11901,27 @@ J9::Power::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&result
1190111901
else if (methodSymbol)
1190211902
{
1190311903
static bool disableCAEIntrinsic = feGetEnv("TR_DisableCAEIntrinsic") != NULL;
11904+
static bool disableOSW = feGetEnv("TR_noPauseOnSpinWait") != NULL;
1190411905
switch (methodSymbol->getRecognizedMethod())
1190511906
{
11907+
case TR::java_lang_Thread_onSpinWait:
11908+
{
11909+
if (!disableOSW)
11910+
{
11911+
if (comp->getOption(TR_TraceCG))
11912+
{
11913+
traceMsg(comp, "Inlining Thread.onSpinWait call node %p as yield instruction.\n", node);
11914+
}
11915+
11916+
/*
11917+
* onSpinWait() method calls VM_AtomicSupport::yieldCPU() which is a yield instruction encoded as "or r27, r27, r27".
11918+
* Check omr/include_core/AtomicSupport.hpp for the JNI implementation.
11919+
*/
11920+
generateInstruction(cg, TR::InstOpCode::yield, node);
11921+
return true;
11922+
}
11923+
break;
11924+
}
1190611925
case TR::java_util_concurrent_ConcurrentLinkedQueue_tmOffer:
1190711926
{
1190811927
if (cg->getSupportsInlineConcurrentLinkedQueue())

0 commit comments

Comments
 (0)