@@ -190,7 +190,8 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
190
190
if ((response != MessageType::compilationCode) &&
191
191
(response != MessageType::compilationFailure) &&
192
192
(response != MessageType::AOTCache_serializedAOTMethod) &&
193
- (response != MessageType::AOTCache_storedAOTMethod))
193
+ (response != MessageType::AOTCache_storedAOTMethod) &&
194
+ (response != MessageType::AOTCache_failure))
194
195
client->writeError (JITServer::MessageType::compilationInterrupted, 0 /* placeholder */ );
195
196
196
197
if (TR::Options::isAnyVerboseOptionSet (TR_VerboseJITServer, TR_VerboseCompilationDispatch))
@@ -210,6 +211,7 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
210
211
case MessageType::compilationFailure:
211
212
case MessageType::AOTCache_storedAOTMethod:
212
213
case MessageType::AOTCache_serializedAOTMethod:
214
+ case MessageType::AOTCache_failure:
213
215
case MessageType::compilationThreadCrashed:
214
216
done = true ;
215
217
break ;
@@ -224,7 +226,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
224
226
{
225
227
uint64_t serverUID = std::get<0 >(client->getRecvData <uint64_t >());
226
228
uint64_t previousUID = compInfo->getPersistentInfo ()->getServerUID ();
229
+ bool hasEverConnectedToServer = compInfo->getPersistentInfo ()->hasEverConnectedToServer ();
227
230
compInfo->getPersistentInfo ()->setServerUID (serverUID);
231
+ compInfo->getPersistentInfo ()->setHasEverConnectedToServer ();
228
232
229
233
auto unloadedClasses = comp->getPersistentInfo ()->getUnloadedClassAddresses ();
230
234
std::vector<TR_AddressRange> ranges;
@@ -242,11 +246,18 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
242
246
compInfo->getclassesCachedAtServer ().clear ();
243
247
}
244
248
245
- auto deserializer = compInfo->getJITServerAOTDeserializer ();
246
- // Reset AOT deserializer if connected to a new server (cached serialization records are now invalid),
247
- // except if this is the first server this client has connected to.
248
- if (deserializer && (0 != previousUID) && (previousUID != serverUID))
249
- deserializer->reset (compInfoPT);
249
+ // This is a connection to a new server after a previous disconnection
250
+ if (hasEverConnectedToServer && (previousUID != serverUID))
251
+ {
252
+ // Reset AOT deserializer (cached serialization records are now invalid)
253
+ auto deserializer = compInfo->getJITServerAOTDeserializer ();
254
+ if (deserializer)
255
+ deserializer->reset (compInfoPT);
256
+
257
+ // Do not forbid AOT cache stores or loads (this server might be able to fulfill them)
258
+ compInfo->getPersistentInfo ()->setDoNotRequestJITServerAOTCacheLoad (false );
259
+ compInfo->getPersistentInfo ()->setDoNotRequestJITServerAOTCacheStore (false );
260
+ }
250
261
251
262
client->write (response, ranges, unloadedClasses->getMaxRanges (), serializedCHTable);
252
263
@@ -3123,6 +3134,7 @@ remoteCompile(J9VMThread *vmThread, TR::Compilation *compiler, TR_ResolvedMethod
3123
3134
aotCacheStore = entry->_useAOTCacheCompilation &&
3124
3135
compInfo->methodCanBeJITServerAOTCacheStored (compiler->signature (), compilee->convertToMethod ()->methodType ());
3125
3136
aotCacheLoad = persistentInfo->getJITServerUseAOTCache () &&
3137
+ !persistentInfo->doNotRequestJITServerAOTCacheLoad () &&
3126
3138
!TR::CompilationInfo::isCompiled (method) &&
3127
3139
!entry->_doNotLoadFromJITServerAOTCache &&
3128
3140
compInfo->methodCanBeJITServerAOTCacheLoaded (compiler->signature (), compilee->convertToMethod ()->methodType ());
@@ -3502,6 +3514,36 @@ remoteCompile(J9VMThread *vmThread, TR::Compilation *compiler, TR_ResolvedMethod
3502
3514
entry->_compErrCode = compilationFailure;
3503
3515
compiler->failCompilation <JITServer::ServerCompilationFailure>(" JITServer compilation thread has crashed." );
3504
3516
}
3517
+ else if (JITServer::MessageType::AOTCache_failure == response)
3518
+ {
3519
+ auto recv = client->getRecvData <bool , bool >();
3520
+ bool aotCacheUnavailable = std::get<0 >(recv);
3521
+ bool aotCacheStoreUnavailable = std::get<1 >(recv);
3522
+
3523
+ auto persistentInfo = compInfo->getPersistentInfo ();
3524
+ if (aotCacheUnavailable)
3525
+ {
3526
+ persistentInfo->setDoNotRequestJITServerAOTCacheLoad (true );
3527
+ persistentInfo->setDoNotRequestJITServerAOTCacheStore (true );
3528
+ if (TR::Options::getVerboseOption (TR_VerboseJITServer))
3529
+ TR_VerboseLog::writeLineLocked (TR_Vlog_JITServer,
3530
+ " Server AOT cache unavailable (serverUID=%llu). Disabling future AOT cache requests for this server." ,
3531
+ (unsigned long long )persistentInfo->getServerUID ());
3532
+ }
3533
+ else if (aotCacheStoreUnavailable)
3534
+ {
3535
+ persistentInfo->setDoNotRequestJITServerAOTCacheStore (true );
3536
+ if (TR::Options::getVerboseOption (TR_VerboseJITServer))
3537
+ TR_VerboseLog::writeLineLocked (TR_Vlog_JITServer,
3538
+ " Cannot store methods in server AOT cache (serverUID=%llu). Disabling future AOT cache store requests for this server." ,
3539
+ (unsigned long long )persistentInfo->getServerUID ());
3540
+ }
3541
+ entry->_compErrCode = compilationFailure;
3542
+ entry->_doNotLoadFromJITServerAOTCache = true ;
3543
+ if (entry->_compilationAttemptsLeft > 0 )
3544
+ entry->_tryCompilingAgain = true ;
3545
+ compiler->failCompilation <JITServer::ServerCompilationFailure>(" JITServer compilation failed." );
3546
+ }
3505
3547
else
3506
3548
{
3507
3549
TR_ASSERT (JITServer::MessageType::compilationFailure == response,
0 commit comments