Skip to content

Commit

Permalink
Merge pull request #21010 from jdmpapin/dedup-invalidateMethodBody
Browse files Browse the repository at this point in the history
Deduplicate definition of J9::Recompilation::invalidateMethodBody()
  • Loading branch information
dsouzai authored Jan 27, 2025
2 parents 9a8dd2e + 7aa5918 commit 3f65c7a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 103 deletions.
18 changes: 0 additions & 18 deletions runtime/compiler/aarch64/runtime/Recomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,6 @@ void J9::Recompilation::methodCannotBeRecompiled(void *oldStartPC, TR_FrontEnd *
omrthread_jit_write_protect_enable();
}

void J9::Recompilation::invalidateMethodBody(void *startPC, TR_FrontEnd *fe)
{
// Pre-existence assumptions for this method have been violated. Make the
// method no-longer runnable and schedule it for sync recompilation
//
J9::PrivateLinkage::LinkageInfo *linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC);
TR_PersistentJittedBodyInfo* bodyInfo = getJittedBodyInfoFromPC(startPC);
bodyInfo->setIsInvalidated(); // bodyInfo must exist

// If the compilation has been attempted before then we are fine (in case of success,
// each caller is being re-directed to the new method -- in case if failure, all callers
// are being sent to the interpreter)
//
if (linkageInfo->recompilationAttempted())
return;
fixUpMethodCode(startPC);
}

// in Trampoline.cpp
extern bool arm64CodePatching(void *method, void *callSite, void *currentPC, void *currentTramp, void *newPC, void *extra);

Expand Down
19 changes: 0 additions & 19 deletions runtime/compiler/arm/runtime/Recomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,25 +333,6 @@ void J9::Recompilation::methodCannotBeRecompiled(void *oldStartPC, TR_FrontEnd *
linkageInfo->setHasFailedRecompilation();
}

void J9::Recompilation::invalidateMethodBody(void *startPC, TR_FrontEnd *fe)
{
// Pre-existence assumptions for this method have been violated. Make the
// method no-longer runnable and schedule it for sync recompilation
//
J9::PrivateLinkage::LinkageInfo *linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC);
//linkageInfo->setInvalidated();
TR_PersistentJittedBodyInfo* bodyInfo = getJittedBodyInfoFromPC(startPC);
bodyInfo->setIsInvalidated(); // bodyInfo must exist

// If the compilation has been attempted before then we are fine (in case of success,
// each caller is being re-directed to the new method -- in case if failure, all callers
// are being sent to the interpreter)
//
if (linkageInfo->recompilationAttempted())
return;
fixUpMethodCode(startPC);
}

extern bool armCodePatching(void *method, void *callSite, void *currentPC, void *currentTramp, void *newPC, void *extra);
extern "C" {
void armIndirectCallPatching_unwrapper(void **argsPtr, void **resPtr)
Expand Down
20 changes: 0 additions & 20 deletions runtime/compiler/p/runtime/Recomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,26 +266,6 @@ void J9::Recompilation::methodCannotBeRecompiled(void *oldStartPC, TR_FrontEnd *
linkageInfo->setHasFailedRecompilation();
}

void J9::Recompilation::invalidateMethodBody(void *startPC, TR_FrontEnd *fe)
{
// Pre-existence assumptions for this method have been violated. Make the
// method no-longer runnable and schedule it for sync recompilation
//
J9::PrivateLinkage::LinkageInfo *linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC);
//linkageInfo->setInvalidated();
TR_PersistentJittedBodyInfo* bodyInfo = getJittedBodyInfoFromPC(startPC);
bodyInfo->setIsInvalidated(); // bodyInfo must exist

// If the compilation has been attempted before then we are fine (in case of success,
// each caller is being re-directed to the new method -- in case if failure, all callers
// are being sent to the interpreter)
//
if (linkageInfo->recompilationAttempted())
return;
fixUpMethodCode(startPC);
}


extern bool ppcCodePatching(void *method, void *callSite, void *currentPC, void *currentTramp, void *newPC, void *extra);
extern "C" {
void ppcIndirectCallPatching_unwrapper(void **argsPtr, void **resPtr)
Expand Down
18 changes: 18 additions & 0 deletions runtime/compiler/runtime/JitRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ J9::Recompilation::sampleMethod(
}
}

void J9::Recompilation::invalidateMethodBody(void *startPC, TR_FrontEnd *fe)
{
// Pre-existence assumptions for this method have been violated. Make the
// method no-longer runnable and schedule it for sync recompilation
//
J9::PrivateLinkage::LinkageInfo *linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC);
TR_PersistentJittedBodyInfo *bodyInfo = getJittedBodyInfoFromPC(startPC);
bodyInfo->setIsInvalidated(); // bodyInfo must exist

// If the compilation has been attempted before then we are fine (in case of success,
// each caller is being re-directed to the new method -- in case if failure, all callers
// are being sent to the interpreter)
//
if (linkageInfo->recompilationAttempted())
return;

fixUpMethodCode(startPC);
}

bool
J9::Recompilation::induceRecompilation(
Expand Down
19 changes: 0 additions & 19 deletions runtime/compiler/x/runtime/Recomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,25 +349,6 @@ void J9::Recompilation::methodCannotBeRecompiled(void *oldStartPC, TR_FrontEnd *
linkageInfo->setHasFailedRecompilation();
}

void J9::Recompilation::invalidateMethodBody(void *startPC, TR_FrontEnd *fe)
{
// Preexistence assumptions for this method have been violated. Make the
// method no-longer runnable and schedule it for a sync recompilation
//
J9::PrivateLinkage::LinkageInfo *linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC);
//linkageInfo->setInvalidated();
TR_PersistentJittedBodyInfo* bodyInfo = getJittedBodyInfoFromPC(startPC);
bodyInfo->setIsInvalidated(); // bodyInfo must exist

// If the compilation has been attempted before then we are fine (in case of success,
// each caller is being re-directed to the new method -- in case if failure, all callers
// are being sent to the interpreter)
//
if (linkageInfo->recompilationAttempted())
return;
fixUpMethodCode(startPC); // schedule a sync compilation
}

#if defined(TR_HOST_X86)
void fixupMethodInfoAddressInCodeCache(void *startPC, void *bodyInfo)
{
Expand Down
27 changes: 0 additions & 27 deletions runtime/compiler/z/runtime/Recomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,30 +399,3 @@ J9::Recompilation::methodCannotBeRecompiled(void * oldStartPC, TR_FrontEnd * fe)
}
linkageInfo->setHasFailedRecompilation();
}

void
J9::Recompilation::invalidateMethodBody(void * startPC, TR_FrontEnd * fe)
{
if (debug("traceRecompilation"))
{
;//diagnostic("RC>>Invalidating %p\n", startPC);
}

// Pre-existence assumptions for this method have been violated. Make the
// method no-longer runnable and schedule it for sync recompilation
//
J9::PrivateLinkage::LinkageInfo * linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC);
//linkageInfo->setInvalidated();
TR_PersistentJittedBodyInfo* bodyInfo = getJittedBodyInfoFromPC(startPC);
bodyInfo->setIsInvalidated(); // bodyInfo must exist

// If the compilation has been attempted before then we are fine (in case of success,
// each caller is being re-directed to the new method -- in case if failure, all callers
// are being sent to the interpreter)
//
if (linkageInfo->recompilationAttempted())
{
return;
}
fixUpMethodCode(startPC);
}

0 comments on commit 3f65c7a

Please sign in to comment.