-
Notifications
You must be signed in to change notification settings - Fork 729
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
Build JNI IFA switching helpers as C calls #2044
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,21 +259,17 @@ class RealRegisterManager | |
TR::CodeGenerator* _cg; | ||
}; | ||
|
||
/** \brief Build a JIT helper call. | ||
* \details | ||
* It generates sequence that prepares parameters for the JIT helper function and generate a helper call. | ||
* \param callNode The node for which you are generating a heleper call | ||
* \param deps The pre register dependency conditions that will be filled by this function to attach within ICF | ||
* \param returnReg TR::Register* allocated by consumer of this API to hold the result of the helper call, | ||
* If passed, this function uses it to store return value from helper instead of allocating new register | ||
* \return TR::Register *helperReturnResult, gets the return value of helper function and return to the evaluator. | ||
*/ | ||
TR::Register * TR::S390CHelperLinkage::buildDirectDispatch(TR::Node * callNode, TR::RegisterDependencyConditions **deps, TR::Register *returnReg) | ||
TR::Register * TR::S390CHelperLinkage::buildDirectDispatch(TR::Node * callNode, | ||
TR::RegisterDependencyConditions **deps, | ||
TR::Register *returnReg, | ||
bool forceFastPath) | ||
{ | ||
RealRegisterManager RealRegisters(cg()); | ||
bool isHelperCallWithinICF = deps != NULL; | ||
// TODO: Currently only jitInstanceOf is fast path helper. Need to modify following condition if we add support for other fast path only helpers | ||
bool isFastPathOnly = callNode->getOpCodeValue() == TR::instanceof; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we leave this TODO around? This is definitely something we still want to do once we refactor the runtime helpers into a sane table with properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO is added back |
||
// TODO: Currently only jitInstanceOf and IFA helper calls are fast path helpers. Need to modify following condition if we add support for other fast path only helpers | ||
// Having a fast path helper call also implies that there is no environment pointer setup in GPR5 | ||
bool isFastPathOnly = callNode->getOpCodeValue() == TR::instanceof || forceFastPath; | ||
|
||
traceMsg(comp(),"%s: Internal Control Flow in OOL : %s\n",callNode->getOpCode().getName(),isHelperCallWithinICF ? "true" : "false" ); | ||
for (int i = TR::RealRegister::FirstGPR; i <= TR::RealRegister::LastHPR; i++) | ||
{ | ||
|
@@ -344,6 +340,7 @@ TR::Register * TR::S390CHelperLinkage::buildDirectDispatch(TR::Node * callNode, | |
// Storing Java Stack Pointer | ||
javaStackPointerRegister = cg()->getStackPointerRealRegister(); | ||
cursor = generateRXInstruction(cg(), TR::InstOpCode::getStoreOpCode(), callNode, javaStackPointerRegister, generateS390MemoryReference(vmThreadRegister, offsetJ9SP, cg())); | ||
|
||
#if defined(J9ZOS390) | ||
padding += 2; | ||
// Loading DSAPointer Register | ||
|
@@ -364,6 +361,21 @@ TR::Register * TR::S390CHelperLinkage::buildDirectDispatch(TR::Node * callNode, | |
} | ||
TR::SymbolReference * callSymRef = callNode->getSymbolReference(); | ||
void * destAddr = callNode->getSymbolReference()->getSymbol()->castToMethodSymbol()->getMethodAddress(); | ||
|
||
#if defined(J9ZOS390) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NigelYiboYu I think my previous comment was for this section. For now we need this part for calling out helpers written in C that means we need to load environment for instanceOf as well. Is that covered? Looking through your other changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fjeremic I am thinking of moving some of the context switching code from helper Glue code to in body and see the effect. I expect a small effect on the method footprint. If the effect is not much then we can move this inlined. I believe x86 already do this. We can make our helper linkage more generic this way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @r30shah let's give it a try and see if it has any negative effects on performance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually good point @r30shah. Thinking about this again we have duplicate information here. The helper index is already stored in This information is already available through the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extra helper index is removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: Environment pointer is now only loaded if the C helper is fast-path. Non-fastPath helpers jump to glue code, which does its own environment handling. |
||
// Fast path helper calls are real C function calls, whereas non-fast-path calls jump to picBuilder glue code | ||
// glue code does its own environment handling and does not need a environment loading here. | ||
if(isFastPathOnly) | ||
{ | ||
TR_RuntimeHelper helperIndex = static_cast<TR_RuntimeHelper>(callNode->getSymbolReference()->getReferenceNumber()); | ||
TR_ASSERT_FATAL(helperIndex < TR_S390numRuntimeHelpers, "Invalid helper index in c helper node\n"); | ||
|
||
// XPLINK GPR5 is an environment register. | ||
intptrj_t environment = reinterpret_cast<intptrj_t>(TOC_UNWRAP_ENV(runtimeHelpers.getFunctionPointer(helperIndex))); | ||
genLoadAddressConstant(cg(), callNode, environment, javaStackPointerRegister); | ||
} | ||
#endif | ||
|
||
cursor = new (cg()->trHeapMemory()) TR::S390RILInstruction(TR::InstOpCode::BRASL, callNode, regRA, destAddr, callSymRef, cg()); | ||
cursor->setDependencyConditions(preDeps); | ||
if (isFastPathOnly) | ||
|
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 we'll need to modify the CMake builds as well.
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 don't see CMake lists contain these
cpp
file names. It seems to operate on directories for z codegen.