Skip to content

Commit

Permalink
Merge JITClientCompThread from the jitaas branch (#7215)
Browse files Browse the repository at this point in the history
Merge JITClientCompThread from the jitaas branch
  • Loading branch information
mpirvu authored Oct 8, 2019
2 parents 547720e + 339085a commit 98716d8
Show file tree
Hide file tree
Showing 9 changed files with 3,045 additions and 8 deletions.
1 change: 1 addition & 0 deletions runtime/compiler/build/files/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ JIT_PRODUCT_SOURCE_FILES+=\

ifneq ($(JITSERVER_SUPPORT),)
JIT_PRODUCT_SOURCE_FILES+=\
compiler/control/JITClientCompilationThread.cpp \
compiler/control/JITServerCompilationThread.cpp \
compiler/control/JITServerHelpers.cpp \
compiler/env/j9methodServer.cpp \
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ j9jit_files(

if(JITSERVER_SUPPORT)
j9jit_files(
control/JITClientCompilationThread.cpp
control/JITServerCompilationThread.cpp
control/JITServerHelpers.cpp
)
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/control/CompilationRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,8 @@ class CompilationInfo
uint32_t getLocalGCCounter() const { return _localGCCounter; }
void incrementLocalGCCounter() { _localGCCounter++; }

static bool canRelocateMethod(TR::Compilation * comp);

const PersistentVector<std::string> &getJITServerSslKeys() const { return _sslKeys; }
void addJITServerSslKey(const std::string &key) { _sslKeys.push_back(key); }
const PersistentVector<std::string> &getJITServerSslCerts() const { return _sslCerts; }
Expand Down
55 changes: 52 additions & 3 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ void setThreadAffinity(unsigned _int64 handle, unsigned long mask)
TR_RelocationRuntime*
TR::CompilationInfoPerThreadBase::reloRuntime()
{
#if defined(JITSERVER_SUPPORT) && defined(JITSERVER_TODO)
#if defined(JITSERVER_SUPPORT)
if (_methodBeingCompiled->isAotLoad() ||
_compInfo.getPersistentInfo()->getRemoteCompilationMode() == JITServer::NONE ||
(_compInfo.getPersistentInfo()->getRemoteCompilationMode() == JITServer::CLIENT && TR::Options::sharedClassCache())) // Enable local AOT compilations at client
return static_cast<TR_RelocationRuntime*>(&_sharedCacheReloRuntime);
return static_cast<TR_RelocationRuntime*>(&_remoteCompileReloRuntime);
#else
return static_cast<TR_RelocationRuntime*>(&_sharedCacheReloRuntime);
#endif /* defined(JITSERVER_SUPPORT) && defined(JITSERVER_TODO) */
#endif /* defined(JITSERVER_SUPPORT) */
}

void
Expand Down Expand Up @@ -870,6 +870,9 @@ TR::CompilationInfoPerThreadBase::CompilationInfoPerThreadBase(TR::CompilationIn
_compInfo(compInfo),
_jitConfig(jitConfig),
_sharedCacheReloRuntime(jitConfig),
#if defined(JITSERVER_SUPPORT)
_remoteCompileReloRuntime(jitConfig),
#endif /* defined(JITSERVER_SUPPORT) */
_compThreadId(id),
_onSeparateThread(onSeparateThread),
_vm(NULL),
Expand Down Expand Up @@ -11206,7 +11209,7 @@ TR::CompilationInfo::storeAOTInSharedCache(
disableAOTCompilations();
}
}
#endif /* defined(J9VM_INTERP_AOT_COMPILE_SUPPORT) && defined(J9VM_OPT_SHARED_CLASSES) && (defined(TR_HOST_X86) || defined(TR_HOST_POWER) || defined(TR_HOST_S390) || defined(TR_HOST_ARM)) */
#endif /* defined(J9VM_INTERP_AOT_COMPILE_SUPPORT) && defined(J9VM_OPT_SHARED_CLASSES) && (defined(TR_HOST_X86) || defined(TR_HOST_POWER) || defined(TR_HOST_S390) || defined(TR_HOST_ARM) || defined(TR_HOST_ARM64)) */

//===========================================================
TR_LowPriorityCompQueue::TR_LowPriorityCompQueue()
Expand Down Expand Up @@ -12163,6 +12166,52 @@ bool TR::CompilationInfo::canProcessJProfilingRequest()
}

#if defined(JITSERVER_SUPPORT)
bool
TR::CompilationInfo::canRelocateMethod(TR::Compilation *comp)
{
TR_Debug *debug = TR::Options::getDebug();
bool canRelocateMethod = false;
if (debug)
{
TR_FilterBST *filter = NULL;
J9UTF8 *className = ((TR_ResolvedJ9Method*)comp->getCurrentMethod())->_className;
J9UTF8 *name = ((TR_ResolvedJ9Method*)comp->getCurrentMethod())->_name;
J9UTF8 *signature = ((TR_ResolvedJ9Method*)comp->getCurrentMethod())->_signature;
char *methodSignature;
char arr[1024];
int32_t len = J9UTF8_LENGTH(className) + J9UTF8_LENGTH(name) + J9UTF8_LENGTH(signature) + 3;
if (len < 1024)
methodSignature = arr;
else
methodSignature = (char *) jitPersistentAlloc(len);

if (methodSignature)
{
sprintf(methodSignature, "%.*s.%.*s%.*s", J9UTF8_LENGTH(className), utf8Data(className), J9UTF8_LENGTH(name), utf8Data(name), J9UTF8_LENGTH(signature), utf8Data(signature));
//printf("methodSig: %s\n", methodSignature);

if (debug->methodSigCanBeRelocated(methodSignature, filter))
canRelocateMethod = true;
}
else
{
canRelocateMethod = true;
}

if (methodSignature && (len >= 1024))
jitPersistentFree(methodSignature);
}
else
{
// Prevent the relocation if specific option is given
if (!comp->getOption(TR_DisableDelayRelocationForAOTCompilations))
canRelocateMethod = false;
else
canRelocateMethod = true;
}
return canRelocateMethod;
}

void
TR::CompilationInfoPerThread::updateLastLocalGCCounter()
{
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/control/CompilationThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ class CompilationInfoPerThreadBase
TR::CompilationInfo & _compInfo;
J9JITConfig * const _jitConfig;
TR_SharedCacheRelocationRuntime _sharedCacheReloRuntime;
#if defined(JITSERVER_SUPPORT)
TR_JITServerRelocationRuntime _remoteCompileReloRuntime;
#endif /* defined(JITSERVER_SUPPORT) */
int32_t const _compThreadId; // unique number starting from 0; Only used for compilation on separate thread
bool const _onSeparateThread;

Expand Down
Loading

0 comments on commit 98716d8

Please sign in to comment.