Skip to content
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

Ensure AOT Compilation in JIT Dump #10852

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7274,9 +7274,11 @@ TR::CompilationInfoPerThreadBase::preCompilationTasks(J9VMThread * vmThread,
else
{
// Heuristic: generate AOT only for downgraded compilations in the second run
if (!isSecondAOTRun &&
entry->_optimizationPlan->isOptLevelDowngraded())
if ((!isSecondAOTRun && entry->_optimizationPlan->isOptLevelDowngraded()) ||
entry->getMethodDetails().isJitDumpAOTMethod())
{
canDoRelocatableCompile = true;
}
}
}
}
Expand Down
24 changes: 19 additions & 5 deletions runtime/compiler/control/JitDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ static TR_CompilationErrorCode recompileMethodForLog(
J9VMThread *vmThread,
J9Method *ramMethod,
TR::CompilationInfo *compInfo,
TR_J9VMBase *frontendOfThread,
TR_Hotness optimizationLevel,
bool profilingCompile,
bool aotCompile,
void *oldStartPC,
TR::FILE *logFile
)
Expand Down Expand Up @@ -326,7 +326,7 @@ static TR_CompilationErrorCode recompileMethodForLog(
// TODO: this is indiscriminately compiling as J9::DumpMethodRequest, which is wrong;
// should be fixed by checking if the method is indeed DLT, and compiling DLT if so
{
J9::JitDumpMethodDetails details(ramMethod);
J9::JitDumpMethodDetails details(ramMethod, aotCompile);
compInfo->compileMethod(vmThread, details, oldStartPC, TR_no, &compErrCode, &successfullyQueued, plan);
}

Expand Down Expand Up @@ -586,15 +586,29 @@ runJitdump(char *label, J9RASdumpContext *context, J9RASdumpAgent *agent)
if (!(jittedMethodsOnStack[i]._method))
continue;

bool isAOTBody = false;
J9JITExceptionTable *metadata = NULL;
void *startPC = jittedMethodsOnStack[i]._oldStartPC;
if (startPC)
{
metadata = jitConfig->jitGetExceptionTableFromPC(crashedThread, (UDATA)startPC);
if (metadata)
{
TR_PersistentJittedBodyInfo *bodyInfo = (TR_PersistentJittedBodyInfo *)metadata->bodyInfo;
if (bodyInfo)
isAOTBody = bodyInfo->getIsAotedBody();
}
}

TR_CompilationErrorCode compErrCode;
compErrCode = recompileMethodForLog(
crashedThread,
jittedMethodsOnStack[i]._method,
compInfo,
frontendOfThread,
jittedMethodsOnStack[i]._optLevel,
false,
jittedMethodsOnStack[i]._oldStartPC,
isAOTBody,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should note, I don't think this will actually result in an AOT compilation; this is because the method is already in the SCC, so the control code will probably just try to do an AOT load. However, if the AOT compilation was also done in the current JVM, it would be nice to be able to log that compilation as well, though this would require keeping track of the methods that were AOT compiled by the current JVM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you add more code to bypass those AOT loads? Otherwise the current change does not achieve its intended effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured I would leave that for a future PR, since trying to do that in this PR might result in quite a big PR.

startPC,
logFile
);
} // for
Expand Down Expand Up @@ -664,9 +678,9 @@ runJitdump(char *label, J9RASdumpContext *context, J9RASdumpAgent *agent)
crashedThread,
(J9Method *)(comp->getCurrentMethod()->getPersistentIdentifier()),
compInfo,
frontendOfThread,
(TR_Hotness)comp->getOptLevel(),
comp->isProfilingCompilation(),
comp->compileRelocatableCode(),
oldStartPC,
logFile
);
Expand Down
15 changes: 11 additions & 4 deletions runtime/compiler/ilgen/IlGeneratorMethodDetails.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@ class JitDumpMethodDetails : public TR::IlGeneratorMethodDetails
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails

public:
JitDumpMethodDetails(J9Method* method) : TR::IlGeneratorMethodDetails(method) { }
JitDumpMethodDetails(const JitDumpMethodDetails& other) : TR::IlGeneratorMethodDetails(other.getMethod()) { }
JitDumpMethodDetails(J9Method* method, bool aotCompile) : TR::IlGeneratorMethodDetails(method)
{
_data._aotCompile = aotCompile;
}
JitDumpMethodDetails(const JitDumpMethodDetails& other) : TR::IlGeneratorMethodDetails(other.getMethod())
{
_data._aotCompile = other._data._aotCompile;
}

virtual const char * name() const { return "DumpMethod"; }

virtual bool isOrdinaryMethod() const { return false; }
virtual bool isJitDumpMethod() const { return true; }
virtual bool isOrdinaryMethod() const { return false; }
virtual bool isJitDumpMethod() const { return true; }
virtual bool isJitDumpAOTMethod() const { return _data._aotCompile; }


virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/ilgen/J9IlGeneratorMethodDetails.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class OMR_EXTENSIBLE IlGeneratorMethodDetails : public OMR::IlGeneratorMethodDet

virtual bool isOrdinaryMethod() const { return true; }
virtual bool isJitDumpMethod() const { return false; }
virtual bool isJitDumpAOTMethod() const { return false; }
fjeremic marked this conversation as resolved.
Show resolved Hide resolved
virtual bool isNewInstanceThunk() const { return false; }
virtual bool isMethodInProgress() const { return false; }
virtual bool isArchetypeSpecimen() const { return false; }
Expand Down Expand Up @@ -152,6 +153,7 @@ class OMR_EXTENSIBLE IlGeneratorMethodDetails : public OMR::IlGeneratorMethodDet
uintptr_t *_handleRef;
uintptr_t *_argRef;
} _methodHandleData;
bool _aotCompile;
} _data;

};
Expand Down