-
Notifications
You must be signed in to change notification settings - Fork 734
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
Z: Accelerate inlining Thread.onSpinWait() #20714
Conversation
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; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need condition for the traceMsg? It should be done in the entry unconditionally,
@r30shah I renamed the branch and it caused the older PR to close. I opened this one with a different branch name. Please take a look. |
72e0d9d
to
a5374a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpicks, overall looks ok, please update the commit message and title (May be recognize is a better suited word than accelerate ? ) And change the reference to IBM Z from z
.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need condition for the traceMsg? It should be done in the entry unconditionally,
static const bool printIt = feGetEnv("TR_showPauseOnSpinWait") != NULL; | ||
if (printIt && comp->getOption(TR_TraceCG)) | ||
{ | ||
traceMsg(comp, "Insert NOP for onSpinWait : node=%p, %s\n", node, comp->signature()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think printing the method name in the JIT compilation log is redundant. We would see this message in the compilation log of the method we want to log. I think, a simple message saying inlining call to Thread.onSpinWait to NOP is sufficient.
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add reference / Comment to the JNI call to OnSpinWait that emits NOP for reference to explain why we are generating NOP.
e70d501
to
aba70ba
Compare
@r30shah thank you for your comments. When you have time, could you please check if the recent changes look good to you? thanks. |
TR::Instruction* cursor = new (cg->trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 2, node, cg); | ||
|
||
TR::Compilation *comp = cg->comp(); | ||
if (comp->getOption(TR_TraceCG)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this at the entry of the function - It just seems bit odd reading the code - Cosmetic change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Thread.onSpinWait() is a simple `nop` instruction on z. Added instructions to recognize that method and inline it in jit code. Enabled by default. Disable by setting the `TR_noPauseOnSpinWait` environment variable. Signed-off-by: Ehsan Kiani Far <[email protected]>
aba70ba
to
4e89f97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Jenkins test sanity zlinux jdk11,jdk21 |
Based on the tests done by @ehsankianifar internally and on PR, merging this change. |
Thread.onSpinWait() is a simple
nop
instruction on z. Enabled by default. Disable by setting theTR_noPauseOnSpinWait
environment variable.