Skip to content

Commit b3bcb8b

Browse files
authored
Merge pull request #20219 from dsouzai/fsdPostRestore_0.48
(0.48) Ensure JIT/AOT code is not invalidated post-restore under `-XX:+DebugOnRestore`
2 parents 2fec638 + 76bf3f8 commit b3bcb8b

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

runtime/compiler/control/J9Options.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,6 +3026,17 @@ J9::Options::fePostProcessAOT(void * base)
30263026
bool
30273027
J9::Options::isFSDNeeded(J9JavaVM *javaVM, J9HookInterface **vmHooks)
30283028
{
3029+
#if defined(J9VM_OPT_CRIU_SUPPORT)
3030+
J9VMThread * vmThread = javaVM->internalVMFunctions->currentVMThread(javaVM);
3031+
if (javaVM->internalVMFunctions->isCheckpointAllowed(vmThread))
3032+
{
3033+
if (javaVM->internalVMFunctions->isDebugOnRestoreEnabled(vmThread))
3034+
{
3035+
return false;
3036+
}
3037+
}
3038+
#endif
3039+
30293040
return
30303041
#if defined(J9VM_JIT_FULL_SPEED_DEBUG)
30313042
(javaVM->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_CAN_ACCESS_LOCALS) ||

runtime/compiler/control/OptionsPostRestore.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,10 @@ J9::OptionsPostRestore::postProcessInternalCompilerOptions()
744744
TR::Options::FSDInitStatus fsdStatus = TR::Options::resetFSD(vm, _vmThread, doAOT);
745745
disableAOT = !doAOT;
746746

747-
if (fsdStatus != TR::Options::FSDInitStatus::FSDInit_NotInitialized)
747+
if (!_compInfo->getCRRuntime()->isFSDEnabled()
748+
&& fsdStatus == TR::Options::FSDInitStatus::FSDInit_Initialized)
748749
{
750+
_compInfo->getCRRuntime()->setFSDEnabled(true);
749751
invalidateAll = true;
750752
disableAOT = true;
751753
}

runtime/compiler/control/rossa.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@
126126
#include "runtime/MetricsServer.hpp"
127127
#endif /* defined(J9VM_OPT_JITSERVER) */
128128

129+
#if defined(J9VM_OPT_CRIU_SUPPORT)
130+
#include "runtime/CRRuntime.hpp"
131+
#endif
132+
129133
extern "C" int32_t encodeCount(int32_t count);
130134

131135
extern "C" {
@@ -2046,6 +2050,9 @@ aboutToBootstrap(J9JavaVM * javaVM, J9JITConfig * jitConfig)
20462050
#endif
20472051

20482052
#if defined(J9VM_OPT_CRIU_SUPPORT)
2053+
if (compInfo->getCRRuntime())
2054+
compInfo->getCRRuntime()->cacheEventsStatus();
2055+
20492056
bool debugOnRestoreEnabled = javaVM->internalVMFunctions->isDebugOnRestoreEnabled(curThread);
20502057

20512058
/* If the JVM is in CRIU mode and checkpointing is allowed, then the JIT should be

runtime/compiler/runtime/CRRuntime.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,20 @@ TR::CRRuntime::CRRuntime(J9JITConfig *jitConfig, TR::CompilationInfo *compInfo)
9191
_forcedRecomps(),
9292
_impMethodForCR(),
9393
_proactiveCompEnv(),
94-
_jniMethodAddr()
94+
_jniMethodAddr(),
95+
_vmMethodTraceEnabled(false),
96+
_vmExceptionEventsHooked(false),
97+
_fsdEnabled(false)
98+
{
99+
#if defined(J9VM_OPT_JITSERVER)
100+
_canPerformRemoteCompilationInCRIUMode = false;
101+
_remoteCompilationRequestedAtBootstrap = false;
102+
_remoteCompilationExplicitlyDisabledAtBootstrap = false;
103+
#endif
104+
}
105+
106+
void
107+
TR::CRRuntime::cacheEventsStatus()
95108
{
96109
// TR::CompilationInfo is initialized in the JIT_INITIALIZED bootstrap
97110
// stage, whereas J9_EXTENDED_RUNTIME_METHOD_TRACE_ENABLED is set in the
@@ -109,11 +122,7 @@ TR::CRRuntime::CRRuntime(J9JITConfig *jitConfig, TR::CompilationInfo *compInfo)
109122
|| J9_EVENT_IS_RESERVED(jitConfig->javaVM->hookInterface, J9HOOK_VM_EXCEPTION_THROW);
110123
_vmExceptionEventsHooked = exceptionCatchEventHooked || exceptionThrowEventHooked;
111124

112-
#if defined(J9VM_OPT_JITSERVER)
113-
_canPerformRemoteCompilationInCRIUMode = false;
114-
_remoteCompilationRequestedAtBootstrap = false;
115-
_remoteCompilationExplicitlyDisabledAtBootstrap = false;
116-
#endif
125+
_fsdEnabled = J9::Options::_fsdInitStatus == J9::Options::FSDInit_Initialized;
117126
}
118127

119128
void

runtime/compiler/runtime/CRRuntime.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ class CRRuntime
6969

7070
CRRuntime(J9JITConfig *jitConfig, TR::CompilationInfo *compInfo);
7171

72+
/**
73+
* @brief Cache the status of JVMTI events such as exception throw/catch
74+
* as well as whether method trace and FSD were enabled
75+
* pre-checkpoint.
76+
*/
77+
void cacheEventsStatus();
78+
7279
/* The CR Monitor (Checkpoint/Restore Monitor) must always be acquired with
7380
* Comp Monitor in hand. If waiting on the CR Monitor, the Comp Monitor
7481
* should be released. After being notified, the CR Monitor should be
@@ -108,6 +115,9 @@ class CRRuntime
108115
void setVMExceptionEventsHooked(bool trace) { _vmExceptionEventsHooked = trace; }
109116
bool isVMExceptionEventsHooked() { return _vmExceptionEventsHooked; }
110117

118+
void setFSDEnabled(bool trace) { _fsdEnabled = trace; }
119+
bool isFSDEnabled() { return _fsdEnabled; }
120+
111121
#if defined(J9VM_OPT_JITSERVER)
112122
bool canPerformRemoteCompilationInCRIUMode() { return _canPerformRemoteCompilationInCRIUMode; }
113123
void setCanPerformRemoteCompilationInCRIUMode(bool remoteComp) { _canPerformRemoteCompilationInCRIUMode = remoteComp; }
@@ -422,6 +432,7 @@ class CRRuntime
422432

423433
bool _vmMethodTraceEnabled;
424434
bool _vmExceptionEventsHooked;
435+
bool _fsdEnabled;
425436

426437
#if defined(J9VM_OPT_JITSERVER)
427438
bool _canPerformRemoteCompilationInCRIUMode;

0 commit comments

Comments
 (0)