Skip to content

Commit

Permalink
Merge pull request #9189 from harryyu1994/disableRAT
Browse files Browse the repository at this point in the history
Disable runtime assumption table on JITServer
  • Loading branch information
mpirvu committed Apr 14, 2020
2 parents 329a9db + 1f08ddf commit a429b60
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 27 deletions.
67 changes: 42 additions & 25 deletions runtime/compiler/control/HookedByTheJit.cpp
Expand Up @@ -2482,16 +2482,26 @@ void jitMethodBreakpointed(J9VMThread * vmThread, J9Method *j9method)
*/
void jitIllegalFinalFieldModification(J9VMThread *currentThread, J9Class *fieldClass)
{
J9JITConfig * jitConfig = currentThread->javaVM->jitConfig;
TR::CompilationInfo * compInfo = TR::CompilationInfo::get(jitConfig);

#if defined(J9VM_OPT_JITSERVER)
if (compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER)
{
// Don't execute this hook at the jitserver side
// This piece of code will be removed once all JIT hooks is disabled at the jitserver side
fieldClass->classFlags |= J9ClassHasIllegalFinalFieldModifications;
return;
}
#endif
// Set the bit so that VM doesn't report the modification next time
fieldClass->classFlags |= J9ClassHasIllegalFinalFieldModifications;

J9JITConfig * jitConfig = currentThread->javaVM->jitConfig;
TR_J9VMBase * fe = TR_J9VMBase::get(jitConfig, currentThread);
int32_t length;
char *className = fe->getClassNameChars((TR_OpaqueClassBlock*)fieldClass, length);
reportHook(currentThread, "jitIllegalFinalFieldModification", "class %p %.*s", fieldClass, length, className);

TR::CompilationInfo * compInfo = TR::CompilationInfo::get(jitConfig);
TR_RuntimeAssumptionTable * rat = compInfo->getPersistentInfo()->getRuntimeAssumptionTable();
if (rat)
{
Expand Down Expand Up @@ -2893,12 +2903,13 @@ static bool updateCHTable(J9VMThread * vmThread, J9Class * cl)

TR::CompilationInfo * compInfo = TR::CompilationInfo::get(jitConfig);

#if defined(J9VM_OPT_JITSERVER)
TR_ASSERT_FATAL(compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER, "updateCHTable() should not be called on JITServer!\n");
#endif

TR_PersistentCHTable * table = 0;
if (TR::Options::getCmdLineOptions()->allowRecompilation()
&& !TR::Options::getCmdLineOptions()->getOption(TR_DisableCHOpts)
#if defined(J9VM_OPT_JITSERVER)
&& compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER
#endif
)
table = compInfo->getPersistentInfo()->getPersistentCHTable();

Expand Down Expand Up @@ -3613,30 +3624,32 @@ static void jitHookClassPreinitialize(J9HookInterface * * hookInterface, UDATA e

jitAcquireClassTableMutex(vmThread);

if (TR::Options::getCmdLineOptions()->allowRecompilation()
&& !TR::Options::getCmdLineOptions()->getOption(TR_DisableCHOpts)
#if defined(J9VM_OPT_JITSERVER)
&& compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER
if (compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER)
#endif
)
{
if (!initFailed && !compInfo->getPersistentInfo()->getPersistentCHTable()->classGotInitialized(vm, compInfo->persistentMemory(), clazz))
initFailed = true;
if (TR::Options::getCmdLineOptions()->allowRecompilation()
&& !TR::Options::getCmdLineOptions()->getOption(TR_DisableCHOpts)
)
{
if (!initFailed && !compInfo->getPersistentInfo()->getPersistentCHTable()->classGotInitialized(vm, compInfo->persistentMemory(), clazz))
initFailed = true;

if (!initFailed &&
!vm->isInterfaceClass(clazz))
updateCHTable(vmThread, cl);
}
else
{
if (!initFailed && !updateCHTable(vmThread, cl))
initFailed = true;
}
if (!initFailed &&
!vm->isInterfaceClass(clazz))
updateCHTable(vmThread, cl);
}
else
{
if (!initFailed && !updateCHTable(vmThread, cl))
initFailed = true;
}

if (initFailed)
{
TR_PersistentClassInfo *info = compInfo->getPersistentInfo()->getPersistentCHTable()->findClassInfo(clazz);
compInfo->getPersistentInfo()->getPersistentCHTable()->removeClass(vm, clazz, info, false);
if (initFailed)
{
TR_PersistentClassInfo *info = compInfo->getPersistentInfo()->getPersistentCHTable()->findClassInfo(clazz);
compInfo->getPersistentInfo()->getPersistentCHTable()->removeClass(vm, clazz, info, false);
}
}

classPreinitializeEvent->failed = initFailed;
Expand Down Expand Up @@ -6550,7 +6563,11 @@ int32_t setUpHooks(J9JavaVM * javaVM, J9JITConfig * jitConfig, TR_FrontEnd * vm)
}
j9thread_monitor_exit(javaVM->vmThreadListMutex);

if (!vmj9->isAOT_DEPRECATED_DO_NOT_USE())
if (!vmj9->isAOT_DEPRECATED_DO_NOT_USE()
#if defined(J9VM_OPT_JITSERVER)
&& compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER
#endif
)
{
if ((*vmHooks)->J9HookRegisterWithCallSite(vmHooks, J9HOOK_VM_JNI_NATIVE_REGISTERED, jitHookJNINativeRegistered, OMR_GET_CALLSITE(), NULL))
{
Expand Down
10 changes: 8 additions & 2 deletions runtime/compiler/control/rossa.cpp
Expand Up @@ -1312,8 +1312,14 @@ onLoadInternal(
numCodeCachesToCreateAtStartup = 4;
#endif

if (!persistentMemory->getPersistentInfo()->getRuntimeAssumptionTable()->init())
return -1;

#if defined(J9VM_OPT_JITSERVER)
if (persistentMemory->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER)
#endif
{
if (!persistentMemory->getPersistentInfo()->getRuntimeAssumptionTable()->init())
return -1;
}

TR_PersistentClassLoaderTable *loaderTable = new (PERSISTENT_NEW) TR_PersistentClassLoaderTable(persistentMemory);
if (loaderTable == NULL)
Expand Down

0 comments on commit a429b60

Please sign in to comment.