diff --git a/runtime/compiler/z/codegen/J9CodeGenerator.cpp b/runtime/compiler/z/codegen/J9CodeGenerator.cpp index ca878950dbd..45ccb78938c 100644 --- a/runtime/compiler/z/codegen/J9CodeGenerator.cpp +++ b/runtime/compiler/z/codegen/J9CodeGenerator.cpp @@ -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; diff --git a/runtime/compiler/z/codegen/J9TreeEvaluator.cpp b/runtime/compiler/z/codegen/J9TreeEvaluator.cpp index 3976af7e72c..19e0d88000b 100644 --- a/runtime/compiler/z/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/z/codegen/J9TreeEvaluator.cpp @@ -14665,3 +14665,16 @@ 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) { + // Thread.onSpinWait() on z is a simple "nop" instruction. + cg->generateNop(node); + TR::Compilation *comp = cg->comp(); + static const bool printIt = feGetEnv("TR_showPauseOnSpinWait") != NULL; + if (printIt && comp->getOption(TR_TraceCG)) + { + traceMsg(comp, "insert PAUSE for onSpinWait : node=%p, %s\n", node, comp->signature()); + } + return NULL; +} \ No newline at end of file diff --git a/runtime/compiler/z/codegen/J9TreeEvaluator.hpp b/runtime/compiler/z/codegen/J9TreeEvaluator.hpp index 7744037efb0..b079adc471f 100644 --- a/runtime/compiler/z/codegen/J9TreeEvaluator.hpp +++ b/runtime/compiler/z/codegen/J9TreeEvaluator.hpp @@ -141,6 +141,20 @@ 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. + * + * \details + * + * \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);