Skip to content

Commit

Permalink
Merge pull request #19549 from AlexeyKhrabrov/aotcache_lambdas
Browse files Browse the repository at this point in the history
Support lambdas and other generated classes in JITServer AOT cache
  • Loading branch information
mpirvu committed Jun 21, 2024
2 parents 6036c03 + c45c588 commit 332a5d3
Show file tree
Hide file tree
Showing 28 changed files with 844 additions and 287 deletions.
9 changes: 6 additions & 3 deletions runtime/bcutil/ROMClassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ ROMClassBuilder::handleAnonClassName(J9CfrClassFile *classfile, ROMClassCreation
* When there are a large number of such classes in the shared cache, they trigger a lot of class comparisons.
* Performance can be much worse (compared to shared cache turned off).
*/
if (isLambdaFormClassName(originalStringBytes, originalStringLength)) {
if (isLambdaFormClassName(originalStringBytes, originalStringLength, NULL/*deterministicPrefixLength*/)) {
context->addFindClassFlags(J9_FINDCLASS_FLAG_DO_NOT_SHARE);
context->addFindClassFlags(J9_FINDCLASS_FLAG_LAMBDAFORM);
}
Expand Down Expand Up @@ -429,12 +429,15 @@ ROMClassBuilder::handleAnonClassName(J9CfrClassFile *classfile, ROMClassCreation
/* Mark if the class is a Lambda class. */
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
if (!context->isLambdaFormClass()
&& isLambdaClassName(reinterpret_cast<const char *>(_anonClassNameBuffer), newAnonClassNameLength - 1)
&& isLambdaClassName(reinterpret_cast<const char *>(_anonClassNameBuffer),
newAnonClassNameLength - 1, NULL/*deterministicPrefixLength*/)
) {
context->addFindClassFlags(J9_FINDCLASS_FLAG_LAMBDA);
}
#else /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
if (isLambdaClassName(reinterpret_cast<const char *>(_anonClassNameBuffer), newAnonClassNameLength - 1)) {
if (isLambdaClassName(reinterpret_cast<const char *>(_anonClassNameBuffer),
newAnonClassNameLength - 1, NULL/*deterministicPrefixLength*/)
) {
context->addFindClassFlags(J9_FINDCLASS_FLAG_LAMBDA);
}
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
Expand Down
5 changes: 5 additions & 0 deletions runtime/compiler/control/HookedByTheJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,11 @@ void jitHookClassLoadHelper(J9VMThread *vmThread,

compInfo->getPersistentInfo()->getPersistentClassLoaderTable()->associateClassLoaderWithClass(vmThread, classLoader, clazz);

#if defined(J9VM_OPT_JITSERVER)
if (auto deserializer = compInfo->getJITServerAOTDeserializer())
deserializer->onClassLoad(cl, vmThread);
#endif /* defined(J9VM_OPT_JITSERVER) */

// Update the count for the newInstance
//
TR::Options * options = TR::Options::getCmdLineOptions();
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ int32_t J9::Options::_jitserverMallocTrimInterval = 1000 * 30; // 30000ms = 30s
int32_t J9::Options::_lowCompDensityModeEnterThreshold = 4; // Maximum number of compilations per 10 min of CPU required to enter low compilation density mode. Use 0 to disable feature
int32_t J9::Options::_lowCompDensityModeExitThreshold = 15; // Minimum number of compilations per 10 min of CPU required to exit low compilation density mode
int32_t J9::Options::_lowCompDensityModeExitLPQSize = 120; // Minimum number of compilations in LPQ to take us out of low compilation density mode
bool J9::Options::_aotCacheDisableGeneratedClassSupport = false;
TR::CompilationFilters *J9::Options::_JITServerAOTCacheStoreFilters = NULL;
TR::CompilationFilters *J9::Options::_JITServerAOTCacheLoadFilters = NULL;
TR::CompilationFilters *J9::Options::_JITServerRemoteExcludeFilters = NULL;
Expand Down Expand Up @@ -850,6 +851,8 @@ TR::OptionTable OMR::Options::_feOptions[] = {
{"activeThreadsThresholdForInterpreterSampling=", "M<nnn>\tSampling does not affect invocation count beyond this threshold",
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_activeThreadsThreshold, 0, "F%d", NOT_IN_SUBSET },
#if defined(J9VM_OPT_JITSERVER)
{"aotCacheDisableGeneratedClassSupport", " \tDisable support for generated classes such as lambdas in JITServer AOT cache",
TR::Options::setStaticBool, (intptr_t)&TR::Options::_aotCacheDisableGeneratedClassSupport, 1, "F%d", NOT_IN_SUBSET },
{"aotCachePersistenceMinDeltaMethods=", "M<nnn>\tnumber of extra AOT methods that need to be added to the JITServer AOT cache before considering a save operation",
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_aotCachePersistenceMinDeltaMethods, 0, "F%d", NOT_IN_SUBSET },
{"aotCachePersistenceMinPeriodMs=", "M<nnn>\tmiminum time between two consecutive JITServer AOT cache save operations (ms)",
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/control/J9Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector
static int32_t _lowCompDensityModeEnterThreshold;
static int32_t _lowCompDensityModeExitThreshold;
static int32_t _lowCompDensityModeExitLPQSize;
static bool _aotCacheDisableGeneratedClassSupport;
static TR::CompilationFilters *_JITServerAOTCacheStoreFilters;
static TR::CompilationFilters *_JITServerAOTCacheLoadFilters;
static TR::CompilationFilters *_JITServerRemoteExcludeFilters;
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/control/JITServerCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ TR::CompilationInfoPerThreadRemote::processEntry(TR_MethodToBeCompiled &entry, J
// Get defining class chain record to use as a part of the key to lookup or store the method in AOT cache
JITServerHelpers::cacheRemoteROMClassBatch(clientSession, uncachedRAMClasses, uncachedClassInfos);
bool missingLoaderInfo = false;
_definingClassChainRecord = clientSession->getClassChainRecord(clazz, classChainOffset, ramClassChain,
stream, missingLoaderInfo);
_definingClassChainRecord = clientSession->getClassChainRecord(clazz, classChainOffset, ramClassChain, stream,
missingLoaderInfo, &scratchSegmentProvider);
if (!_definingClassChainRecord)
{
if (TR::Options::getVerboseOption(TR_VerboseJITServer))
Expand Down
Loading

0 comments on commit 332a5d3

Please sign in to comment.