Skip to content

Commit

Permalink
Track methods with AOT bodies with dependencies
Browse files Browse the repository at this point in the history
When a method is initialized in jitHookInitializeSendTarget, the SCC
will be checked to see if it has a stored AOT body that was compiled
with tracked dependencies. If it does, and all of them are satisfied,
the method will be given an initial count of 0. If not all of the
dependencies are satisfied, the method will be tracked by the
TR_DependencyTable until the dependencies are satisfied, at which point
its count will be set to zero, triggering an AOT load on its next
invocation.

Signed-off-by: Christian Despres <[email protected]>
  • Loading branch information
cjjdespres committed Nov 18, 2024
1 parent cd9396a commit 9ca5d97
Show file tree
Hide file tree
Showing 7 changed files with 396 additions and 39 deletions.
6 changes: 6 additions & 0 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "env/StackMemoryRegion.hpp"
#include "env/jittypes.h"
#include "env/ClassTableCriticalSection.hpp"
#include "env/DependencyTable.hpp"
#include "env/PersistentCHTable.hpp"
#include "env/VMAccessCriticalSection.hpp"
#include "env/VerboseLog.hpp"
Expand Down Expand Up @@ -8253,6 +8254,11 @@ TR::CompilationInfoPerThreadBase::compile(J9VMThread * vmThread,
vmThread->omrVMThread->vmState = J9VMSTATE_JIT | J9VMSTATE_MINOR;
vmThread->jitMethodToBeCompiled = method;

// If method is being compiled, then the dependency table no longer needs to
// track it. Let the table know.
if (auto dependencyTable = getCompilationInfo()->getPersistentInfo()->getAOTDependencyTable())
dependencyTable->methodWillBeCompiled(method);

try
{
TR::RawAllocator rawAllocator(vmThread->javaVM);
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/control/DLLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ IDATA J9VMDllMain(J9JavaVM* vm, IDATA stage, void * reserved)
persistentInfo->setAOTDependencyTable(dependencyTable);
}
#endif /* !defined(PERSISTENT_COLLECTIONS_UNSUPPORTED) */
if (!persistentInfo->getAOTDependencyTable())
persistentInfo->setTrackAOTDependencies(false);
}
}
else
Expand Down
39 changes: 28 additions & 11 deletions runtime/compiler/control/HookedByTheJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,37 @@ static void jitHookInitializeSendTarget(J9HookInterface * * hook, UDATA eventNum
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
)
{
int32_t scount = optionsAOT->getInitialSCount();
uint16_t newScount = 0;
if (sc && sc->isHint(method, TR_HintFailedValidation, &newScount))
if (auto dependencyTable = compInfo->getPersistentInfo()->getAOTDependencyTable())
{
if ((scount == TR_QUICKSTART_INITIAL_SCOUNT) || (scount == TR_INITIAL_SCOUNT))
{ // If scount is not user specified (coarse way due to info being lost from options parsing)
// TODO: Is casting the best thing to do here?
scount= std::min(getCount(romMethod, optionsJIT, optionsAOT), static_cast<int32_t>(newScount) ); // Find what would've been normal count for this method and
// make sure new scount isn't larger than that
if (optionsAOT->getVerboseOption(TR_VerboseSCHints) || optionsJIT->getVerboseOption(TR_VerboseSCHints))
TR_VerboseLog::writeLineLocked(TR_Vlog_SCHINTS,"Found hint in sc, increase scount to: %d, wanted scount: %d", scount, newScount);
bool dependenciesSatisfied = false;
// TODO: Obey user counts if they are set for this method
//
// TODO: The initial count for unsatisfied dependencies should
// be revisited. It can likely be lower, particularly if AOT
// loads are suppressed if dependencies are unsatisfied,
// though remember that counts can decrease faster in the warm
// run due to sampling.
if (dependencyTable->trackMethod(vmThread, method, romMethod, dependenciesSatisfied))
count = dependenciesSatisfied ? 0 : TR_DEFAULT_INITIAL_COUNT;
}

if (count == -1)
{
int32_t scount = optionsAOT->getInitialSCount();
uint16_t newScount = 0;
if (sc && sc->isHint(method, TR_HintFailedValidation, &newScount))
{
if ((scount == TR_QUICKSTART_INITIAL_SCOUNT) || (scount == TR_INITIAL_SCOUNT))
{ // If scount is not user specified (coarse way due to info being lost from options parsing)
// TODO: Is casting the best thing to do here?
scount= std::min(getCount(romMethod, optionsJIT, optionsAOT), static_cast<int32_t>(newScount) ); // Find what would've been normal count for this method and
// make sure new scount isn't larger than that
if (optionsAOT->getVerboseOption(TR_VerboseSCHints) || optionsJIT->getVerboseOption(TR_VerboseSCHints))
TR_VerboseLog::writeLineLocked(TR_Vlog_SCHINTS,"Found hint in sc, increase scount to: %d, wanted scount: %d", scount, newScount);
}
}
count = scount;
}
count = scount;
compInfo->incrementNumMethodsFoundInSharedCache();
}
// AOT Body not in SCC, so scount was not set
Expand Down
Loading

0 comments on commit 9ca5d97

Please sign in to comment.