Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(0.48) Ensure JIT/AOT code is not invalidated post-restore under -XX:+DebugOnRestore #20219

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3026,6 +3026,17 @@ J9::Options::fePostProcessAOT(void * base)
bool
J9::Options::isFSDNeeded(J9JavaVM *javaVM, J9HookInterface **vmHooks)
{
#if defined(J9VM_OPT_CRIU_SUPPORT)
J9VMThread * vmThread = javaVM->internalVMFunctions->currentVMThread(javaVM);
if (javaVM->internalVMFunctions->isCheckpointAllowed(vmThread))
{
if (javaVM->internalVMFunctions->isDebugOnRestoreEnabled(vmThread))
{
return false;
}
}
#endif

return
#if defined(J9VM_JIT_FULL_SPEED_DEBUG)
(javaVM->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_CAN_ACCESS_LOCALS) ||
Expand Down
4 changes: 3 additions & 1 deletion runtime/compiler/control/OptionsPostRestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,10 @@ J9::OptionsPostRestore::postProcessInternalCompilerOptions()
TR::Options::FSDInitStatus fsdStatus = TR::Options::resetFSD(vm, _vmThread, doAOT);
disableAOT = !doAOT;

if (fsdStatus != TR::Options::FSDInitStatus::FSDInit_NotInitialized)
if (!_compInfo->getCRRuntime()->isFSDEnabled()
&& fsdStatus == TR::Options::FSDInitStatus::FSDInit_Initialized)
{
_compInfo->getCRRuntime()->setFSDEnabled(true);
invalidateAll = true;
disableAOT = true;
}
Expand Down
7 changes: 7 additions & 0 deletions runtime/compiler/control/rossa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
#include "runtime/MetricsServer.hpp"
#endif /* defined(J9VM_OPT_JITSERVER) */

#if defined(J9VM_OPT_CRIU_SUPPORT)
#include "runtime/CRRuntime.hpp"
#endif

extern "C" int32_t encodeCount(int32_t count);

extern "C" {
Expand Down Expand Up @@ -2046,6 +2050,9 @@ aboutToBootstrap(J9JavaVM * javaVM, J9JITConfig * jitConfig)
#endif

#if defined(J9VM_OPT_CRIU_SUPPORT)
if (compInfo->getCRRuntime())
compInfo->getCRRuntime()->cacheEventsStatus();

bool debugOnRestoreEnabled = javaVM->internalVMFunctions->isDebugOnRestoreEnabled(curThread);

/* If the JVM is in CRIU mode and checkpointing is allowed, then the JIT should be
Expand Down
21 changes: 15 additions & 6 deletions runtime/compiler/runtime/CRRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,20 @@ TR::CRRuntime::CRRuntime(J9JITConfig *jitConfig, TR::CompilationInfo *compInfo)
_forcedRecomps(),
_impMethodForCR(),
_proactiveCompEnv(),
_jniMethodAddr()
_jniMethodAddr(),
_vmMethodTraceEnabled(false),
_vmExceptionEventsHooked(false),
_fsdEnabled(false)
{
#if defined(J9VM_OPT_JITSERVER)
_canPerformRemoteCompilationInCRIUMode = false;
_remoteCompilationRequestedAtBootstrap = false;
_remoteCompilationExplicitlyDisabledAtBootstrap = false;
#endif
}

void
TR::CRRuntime::cacheEventsStatus()
{
// TR::CompilationInfo is initialized in the JIT_INITIALIZED bootstrap
// stage, whereas J9_EXTENDED_RUNTIME_METHOD_TRACE_ENABLED is set in the
Expand All @@ -109,11 +122,7 @@ TR::CRRuntime::CRRuntime(J9JITConfig *jitConfig, TR::CompilationInfo *compInfo)
|| J9_EVENT_IS_RESERVED(jitConfig->javaVM->hookInterface, J9HOOK_VM_EXCEPTION_THROW);
_vmExceptionEventsHooked = exceptionCatchEventHooked || exceptionThrowEventHooked;

#if defined(J9VM_OPT_JITSERVER)
_canPerformRemoteCompilationInCRIUMode = false;
_remoteCompilationRequestedAtBootstrap = false;
_remoteCompilationExplicitlyDisabledAtBootstrap = false;
#endif
_fsdEnabled = J9::Options::_fsdInitStatus == J9::Options::FSDInit_Initialized;
}

void
Expand Down
11 changes: 11 additions & 0 deletions runtime/compiler/runtime/CRRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class CRRuntime

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

/**
* @brief Cache the status of JVMTI events such as exception throw/catch
* as well as whether method trace and FSD were enabled
* pre-checkpoint.
*/
void cacheEventsStatus();

/* The CR Monitor (Checkpoint/Restore Monitor) must always be acquired with
* Comp Monitor in hand. If waiting on the CR Monitor, the Comp Monitor
* should be released. After being notified, the CR Monitor should be
Expand Down Expand Up @@ -108,6 +115,9 @@ class CRRuntime
void setVMExceptionEventsHooked(bool trace) { _vmExceptionEventsHooked = trace; }
bool isVMExceptionEventsHooked() { return _vmExceptionEventsHooked; }

void setFSDEnabled(bool trace) { _fsdEnabled = trace; }
bool isFSDEnabled() { return _fsdEnabled; }

#if defined(J9VM_OPT_JITSERVER)
bool canPerformRemoteCompilationInCRIUMode() { return _canPerformRemoteCompilationInCRIUMode; }
void setCanPerformRemoteCompilationInCRIUMode(bool remoteComp) { _canPerformRemoteCompilationInCRIUMode = remoteComp; }
Expand Down Expand Up @@ -422,6 +432,7 @@ class CRRuntime

bool _vmMethodTraceEnabled;
bool _vmExceptionEventsHooked;
bool _fsdEnabled;

#if defined(J9VM_OPT_JITSERVER)
bool _canPerformRemoteCompilationInCRIUMode;
Expand Down