Skip to content

Commit bf4fdbc

Browse files
authored
Merge pull request #20191 from JasonFengJ9/jdwpoptionfile-v0.48
(0.48) CRIU supports Java debugger via the restore option file
2 parents 6b84dcc + 1fb1de2 commit bf4fdbc

File tree

15 files changed

+614
-221
lines changed

15 files changed

+614
-221
lines changed

runtime/jvmti/j9jvmti.tdf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,3 +683,18 @@ TraceEntry=Trc_JVMTI_jvmtiHookVMCheckpoint_Entry Overhead=1 Level=2 Noenv Templa
683683
TraceExit=Trc_JVMTI_jvmtiHookVMCheckpoint_Exit Overhead=1 Level=2 Noenv Template="HookVMCheckpoint"
684684
TraceEntry=Trc_JVMTI_jvmtiHookVMRestore_Entry Overhead=1 Level=2 Noenv Template="HookVMRestore"
685685
TraceExit=Trc_JVMTI_jvmtiHookVMRestore_Exit Overhead=1 Level=2 Noenv Template="HookVMRestore"
686+
687+
TraceEvent=Trc_JVMTI_jvmtiAddCapabilities_no_capability Overhead=1 Level=1 Template="jvmtiAddCapabilities() failed: ~(((U_8 *) &potentialCapabilities)[%zu] = %x, result (%x)"
688+
TraceEvent=Trc_JVMTI_jvmtiAddCapabilities_not_onload Overhead=1 Level=1 Template="jvmtiAddCapabilities() failed: not JVMTI_PHASE_ONLOAD"
689+
TraceEvent=Trc_JVMTI_jvmtiAddCapabilities_object_alloc_set_already Overhead=1 Level=1 Template="jvmtiAddCapabilities() failed: J9JVMTI_FLAG_SAMPLED_OBJECT_ALLOC_ENABLED was set"
690+
TraceEvent=Trc_JVMTI_jvmtiAddCapabilities_mapCapabilitiesToEvents_failed Overhead=1 Level=1 Template="jvmtiAddCapabilities() failed: mapCapabilitiesToEvents()"
691+
TraceEvent=Trc_JVMTI_jvmtiAddCapabilities_hookNonEventCapabilities_failed Overhead=1 Level=1 Template="jvmtiAddCapabilities() failed: hookNonEventCapabilities()"
692+
693+
TraceEvent=Trc_JVMTI_criuAddCapabilities_invoked Noenv Overhead=1 Level=3 Template="CRIU adds capabilities before checkpoint"
694+
TraceEvent=Trc_JVMTI_createAgentLibraryWithOption_OOM Noenv Overhead=1 Level=3 Template="createAgentLibraryWithOption j9mem_allocate_memory OOM"
695+
TraceEvent=Trc_JVMTI_createAgentLibraryWithOption_Xrunjdwp_result Noenv Overhead=1 Level=3 Template="createAgentLibraryWithOption Xrunjdwp optionsPtr (%s) optionsLengthTmp (%zu) agentLibrary (%p) result (%d)"
696+
TraceEvent=Trc_JVMTI_createAgentLibraryWithOption_agentlib_result Noenv Overhead=1 Level=3 Template="createAgentLibraryWithOption optionsPtr (%s) libraryLength (%zu) options (%s) optionsLength (%zu) agentLibrary (%p) result (%d)"
697+
TraceEntry=Trc_JVMTI_jvmtiHookVMRestoreCRIUInit_Entry Overhead=1 Level=3 Noenv Template="jvmtiHookVMRestoreCRIUInit"
698+
TraceExit=Trc_JVMTI_jvmtiHookVMRestoreCRIUInit_Exit Overhead=1 Level=3 Noenv Template="jvmtiHookVMRestoreCRIUInit"
699+
TraceEntry=Trc_JVMTI_jvmtiHookVMRestoreStartAgent_Entry Overhead=1 Level=3 Noenv Template="jvmtiHookVMRestoreStartAgent"
700+
TraceExit=Trc_JVMTI_jvmtiHookVMRestoreStartAgent_Exit Overhead=1 Level=3 Noenv Template="jvmtiHookVMRestoreStartAgent"

runtime/jvmti/jvmtiCapability.c

Lines changed: 69 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ jvmtiAddCapabilities(jvmtiEnv* env,
364364

365365
/* Make sure all of the requested capabilities are available */
366366

367-
if ((byte & ~(((U_8 *) &potentialCapabilities)[i])) != 0) {
367+
if (0 != (byte & ~(((U_8 *) &potentialCapabilities)[i]))) {
368+
Trc_JVMTI_jvmtiAddCapabilities_no_capability(currentThread,
369+
i, ((U_8 *) &potentialCapabilities)[i], (byte & ~(((U_8 *) &potentialCapabilities)[i])));
368370
goto fail;
369371
}
370372

@@ -382,6 +384,7 @@ jvmtiAddCapabilities(jvmtiEnv* env,
382384
vm->requiredDebugAttributes |= J9VM_DEBUG_ATTRIBUTE_MAINTAIN_ORIGINAL_METHOD_ORDER;
383385
} else {
384386
rc = JVMTI_ERROR_NOT_AVAILABLE;
387+
Trc_JVMTI_jvmtiAddCapabilities_not_onload(currentThread);
385388
goto fail;
386389
}
387390
}
@@ -391,6 +394,7 @@ jvmtiAddCapabilities(jvmtiEnv* env,
391394
if (newCapabilities.can_generate_sampled_object_alloc_events) {
392395
if (J9_ARE_ANY_BITS_SET(jvmtiData->flags, J9JVMTI_FLAG_SAMPLED_OBJECT_ALLOC_ENABLED)) {
393396
rc = JVMTI_ERROR_NOT_AVAILABLE;
397+
Trc_JVMTI_jvmtiAddCapabilities_object_alloc_set_already(currentThread);
394398
goto fail;
395399
}
396400

@@ -411,13 +415,15 @@ jvmtiAddCapabilities(jvmtiEnv* env,
411415

412416
/* Reserve hooks for any events now allowed by the new capabilities */
413417

414-
if (mapCapabilitiesToEvents(j9env, &newCapabilities, reserveEvent) != 0) {
418+
if (0 != mapCapabilitiesToEvents(j9env, &newCapabilities, reserveEvent)) {
419+
Trc_JVMTI_jvmtiAddCapabilities_mapCapabilitiesToEvents_failed(currentThread);
415420
goto fail;
416421
}
417422

418423
/* Handle non-event hooks */
419424

420-
if (hookNonEventCapabilities(j9env, &newCapabilities) != 0) {
425+
if (0 != hookNonEventCapabilities(j9env, &newCapabilities)) {
426+
Trc_JVMTI_jvmtiAddCapabilities_hookNonEventCapabilities_failed(currentThread);
421427
goto fail;
422428
}
423429

@@ -540,55 +546,82 @@ mapCapabilitiesToEvents(J9JVMTIEnv * j9env, jvmtiCapabilities * capabilities, J9
540546
{
541547
IDATA rc = 0;
542548

543-
if (capabilities->can_generate_single_step_events) {
544-
rc |= eventHookFunction(j9env, JVMTI_EVENT_SINGLE_STEP);
545-
}
546-
547-
if (capabilities->can_generate_breakpoint_events) {
548-
rc |= eventHookFunction(j9env, JVMTI_EVENT_BREAKPOINT);
549-
}
550-
551-
if (capabilities->can_generate_field_access_events) {
552-
rc |= eventHookFunction(j9env, JVMTI_EVENT_FIELD_ACCESS);
553-
}
554-
555-
if (capabilities->can_generate_field_modification_events) {
556-
rc |= eventHookFunction(j9env, JVMTI_EVENT_FIELD_MODIFICATION);
549+
#if defined(J9VM_OPT_CRIU_SUPPORT)
550+
J9JavaVM * vm = j9env->vm;
551+
J9VMThread *mainThread = vm->mainThread;
552+
J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
553+
BOOLEAN skipHookReserve = vmFuncs->isCheckpointAllowed(mainThread)
554+
&& vmFuncs->isDebugOnRestoreEnabled(mainThread);
555+
/* Skip J9HookReserve for the events required by JDWP agent pre-checkpoint when DebugOnRestore is enabled,
556+
* these events will be registered post-restore if a JDWP agent is specified in the restore option file,
557+
* otherwise they are going to be unregistered by J9HookUnregister() which only clears J9HOOK_FLAG_HOOKED,
558+
* but not J9HOOK_FLAG_RESERVED.
559+
* J9HookUnreserve() might clear the flag set by other callers.
560+
*/
561+
if (!skipHookReserve)
562+
#endif /* defined(J9VM_OPT_CRIU_SUPPORT)*/
563+
{
564+
if (capabilities->can_generate_single_step_events) {
565+
rc |= eventHookFunction(j9env, JVMTI_EVENT_SINGLE_STEP);
566+
}
567+
if (capabilities->can_generate_breakpoint_events) {
568+
rc |= eventHookFunction(j9env, JVMTI_EVENT_BREAKPOINT);
569+
}
570+
if (capabilities->can_generate_field_access_events) {
571+
rc |= eventHookFunction(j9env, JVMTI_EVENT_FIELD_ACCESS);
572+
}
573+
if (capabilities->can_generate_field_modification_events) {
574+
rc |= eventHookFunction(j9env, JVMTI_EVENT_FIELD_MODIFICATION);
575+
}
576+
if (capabilities->can_generate_frame_pop_events) {
577+
rc |= eventHookFunction(j9env, JVMTI_EVENT_FRAME_POP);
578+
}
579+
if (capabilities->can_generate_monitor_events) {
580+
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_CONTENDED_ENTER);
581+
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED);
582+
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_WAIT);
583+
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_WAITED);
584+
}
585+
#if JAVA_SPEC_VERSION >= 19
586+
if (capabilities->can_support_virtual_threads) {
587+
rc |= eventHookFunction(j9env, JVMTI_EVENT_VIRTUAL_THREAD_START);
588+
rc |= eventHookFunction(j9env, JVMTI_EVENT_VIRTUAL_THREAD_END);
589+
}
590+
#endif /* JAVA_SPEC_VERSION >= 19 */
591+
if (capabilities->can_generate_garbage_collection_events) {
592+
rc |= eventHookFunction(j9env, JVMTI_EVENT_GARBAGE_COLLECTION_START);
593+
rc |= eventHookFunction(j9env, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH);
594+
}
557595
}
558-
559-
if (capabilities->can_generate_frame_pop_events) {
560-
rc |= eventHookFunction(j9env, JVMTI_EVENT_FRAME_POP);
596+
/* CRIU can't skip J9HookReserve for the following events when they are requested via
597+
* jvmtiAddCapabilities(), otherwise, the corresponding hooks will be disabled by JIT.
598+
* For example, can_generate_method_exit_events/JVMTI_EVENT_METHOD_EXIT related hooks
599+
* are J9HOOK_VM_METHOD_RETURN/J9HOOK_VM_NATIVE_METHOD_RETURN, the hook
600+
* J9HOOK_VM_METHOD_RETURN is to be disabled if not reserved in advance.
601+
* Similarly for the other events, if they are not reserved and a jdwp agent is
602+
* specified at the restore option file, the capability can't be added,
603+
* and the debugger won't be able to run.
604+
*/
605+
if (capabilities->can_generate_method_exit_events) {
606+
rc |= eventHookFunction(j9env, JVMTI_EVENT_METHOD_EXIT);
561607
}
562-
563608
if (capabilities->can_generate_method_entry_events) {
564609
rc |= eventHookFunction(j9env, JVMTI_EVENT_METHOD_ENTRY);
565610
}
566-
567-
if (capabilities->can_generate_method_exit_events) {
568-
rc |= eventHookFunction(j9env, JVMTI_EVENT_METHOD_EXIT);
611+
if (capabilities->can_generate_exception_events) {
612+
rc |= eventHookFunction(j9env, JVMTI_EVENT_EXCEPTION);
613+
rc |= eventHookFunction(j9env, JVMTI_EVENT_EXCEPTION_CATCH);
569614
}
570615

571616
if (capabilities->can_generate_native_method_bind_events) {
572617
rc |= eventHookFunction(j9env, JVMTI_EVENT_NATIVE_METHOD_BIND);
573618
}
574619

575-
if (capabilities->can_generate_exception_events) {
576-
rc |= eventHookFunction(j9env, JVMTI_EVENT_EXCEPTION);
577-
rc |= eventHookFunction(j9env, JVMTI_EVENT_EXCEPTION_CATCH);
578-
}
579-
580620
if (capabilities->can_generate_compiled_method_load_events) {
581621
rc |= eventHookFunction(j9env, JVMTI_EVENT_COMPILED_METHOD_LOAD);
582622
rc |= eventHookFunction(j9env, JVMTI_EVENT_COMPILED_METHOD_UNLOAD);
583623
}
584624

585-
if (capabilities->can_generate_monitor_events) {
586-
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_CONTENDED_ENTER);
587-
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED);
588-
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_WAIT);
589-
rc |= eventHookFunction(j9env, JVMTI_EVENT_MONITOR_WAITED);
590-
}
591-
592625
if (capabilities->can_generate_vm_object_alloc_events) {
593626
rc |= eventHookFunction(j9env, JVMTI_EVENT_VM_OBJECT_ALLOC);
594627
}
@@ -599,28 +632,14 @@ mapCapabilitiesToEvents(J9JVMTIEnv * j9env, jvmtiCapabilities * capabilities, J9
599632
}
600633
#endif /* JAVA_SPEC_VERSION >= 11 */
601634

602-
#if JAVA_SPEC_VERSION >= 19
603-
if (capabilities->can_support_virtual_threads) {
604-
rc |= eventHookFunction(j9env, JVMTI_EVENT_VIRTUAL_THREAD_START);
605-
rc |= eventHookFunction(j9env, JVMTI_EVENT_VIRTUAL_THREAD_END);
606-
}
607-
#endif /* JAVA_SPEC_VERSION >= 19 */
608-
609635
if (capabilities->can_generate_object_free_events) {
610636
rc |= eventHookFunction(j9env, JVMTI_EVENT_OBJECT_FREE);
611637
}
612638

613-
if (capabilities->can_generate_garbage_collection_events) {
614-
rc |= eventHookFunction(j9env, JVMTI_EVENT_GARBAGE_COLLECTION_START);
615-
rc |= eventHookFunction(j9env, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH);
616-
}
617-
618639
if (capabilities->can_generate_resource_exhaustion_heap_events ||
619640
capabilities->can_generate_resource_exhaustion_threads_events) {
620641
rc |= eventHookFunction(j9env, JVMTI_EVENT_RESOURCE_EXHAUSTED);
621642
}
622643

623644
return rc;
624645
}
625-
626-

runtime/jvmti/jvmtiHook.c

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,24 @@ static BOOLEAN shouldPostEvent(J9VMThread *currentThread, J9Method *method);
155155
#if defined(J9VM_OPT_CRIU_SUPPORT)
156156
static void jvmtiHookVMCheckpoint(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
157157
static void jvmtiHookVMRestore(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
158+
static void jvmtiHookVMRestoreCRIUInit(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
159+
static void jvmtiHookVMRestoreStartAgent(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
160+
static void hookDisableHelper(J9JavaVM *vm, J9HookInterface **vmHook, UDATA eventNum, J9HookFunction function, BOOLEAN unreserve, void *userData);
161+
162+
static void
163+
hookDisableHelper(J9JavaVM *vm, J9HookInterface **vmHook, UDATA eventNum, J9HookFunction function, BOOLEAN unreserve, void *userData)
164+
{
165+
if (NULL == userData) {
166+
(*vmHook)->J9HookUnregister(vmHook, eventNum, function, vm->checkpointState.jvmtienv);
167+
} else {
168+
(*vmHook)->J9HookUnregister(vmHook, eventNum, function, userData);
169+
}
170+
if (unreserve) {
171+
/* for actual hookRegister calls */
172+
(*vmHook)->J9HookUnreserve(vmHook, eventNum);
173+
}
174+
(*vmHook)->J9HookDisable(vmHook, eventNum);
175+
}
158176
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
159177

160178
static void
@@ -539,6 +557,37 @@ jvmtiHookVMCheckpoint(J9HookInterface **hook, UDATA eventNum, void *eventData, v
539557
TRACE_JVMTI_EVENT_RETURN(jvmtiHookVMCheckpoint);
540558
}
541559

560+
static void
561+
jvmtiHookVMRestoreCRIUInit(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
562+
{
563+
Trc_JVMTI_jvmtiHookVMRestoreCRIUInit_Entry();
564+
criuRestoreInitializeLib(((J9RestoreEvent *)eventData)->currentThread->javaVM, (J9JVMTIEnv *)userData);
565+
TRACE_JVMTI_EVENT_RETURN(jvmtiHookVMRestoreCRIUInit);
566+
}
567+
568+
static void
569+
jvmtiHookVMRestoreStartAgent(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
570+
{
571+
J9VMThread *currentThread = ((J9RestoreEvent *)eventData)->currentThread;
572+
J9JavaVM *vm = currentThread->javaVM;
573+
Trc_JVMTI_jvmtiHookVMRestoreStartAgent_Entry();
574+
if (J9_ARE_ANY_BITS_SET(vm->checkpointState.flags, J9VM_CRIU_IS_JDWP_ENABLED)) {
575+
J9InternalVMFunctions const * const vmFuncs = vm->internalVMFunctions;
576+
577+
vmFuncs->internalExitVMToJNI(currentThread);
578+
criuRestoreStartAgent(vm);
579+
vmFuncs->internalEnterVMFromJNI(currentThread);
580+
} else {
581+
/* Last part of cleanup if there was no JDWP agent specified.
582+
* This releases VM access hence can't be invoked within criuDisableHooks() from
583+
* J9HOOK_VM_PREPARING_FOR_RESTORE.
584+
*/
585+
jvmtiEnv *jvmti_env = vm->checkpointState.jvmtienv;
586+
(*jvmti_env)->DisposeEnvironment(jvmti_env);
587+
}
588+
TRACE_JVMTI_EVENT_RETURN(jvmtiHookVMRestoreStartAgent);
589+
}
590+
542591
static void
543592
jvmtiHookVMRestore(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
544593
{
@@ -562,6 +611,89 @@ jvmtiHookVMRestore(J9HookInterface **hook, UDATA eventNum, void *eventData, void
562611

563612
TRACE_JVMTI_EVENT_RETURN(jvmtiHookVMRestore);
564613
}
614+
615+
void
616+
criuDisableHooks(J9JVMTIData *jvmtiData, J9JVMTIEnv *j9env)
617+
{
618+
J9JavaVM *vm = jvmtiData->vm;
619+
jvmtiEnv *jvmti_env = vm->checkpointState.jvmtienv;
620+
J9HookInterface **vmHook = vm->internalVMFunctions->getVMHookInterface(vm);
621+
622+
Assert_JVMTI_true(J9_ARE_NO_BITS_SET(vm->checkpointState.flags, J9VM_CRIU_IS_JDWP_ENABLED));
623+
624+
/* can_access_local_variables, can_get_source_file_name, can_get_line_numbers, can_get_source_debug_extension
625+
* can_maintain_original_method_order, can_generate_single_step_events
626+
*/
627+
hookDisableHelper(vm, vmHook, J9HOOK_VM_REQUIRED_DEBUG_ATTRIBUTES, jvmtiHookRequiredDebugAttributes, FALSE, NULL);
628+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_CAN_ACCESS_LOCALS;
629+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_MAINTAIN_ORIGINAL_METHOD_ORDER;
630+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_SOURCE_DEBUG_EXTENSION;
631+
if (NULL != vm->jitConfig) {
632+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_LINE_NUMBER_TABLE;
633+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_LOCAL_VARIABLE_TABLE;
634+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_SOURCE_FILE;
635+
}
636+
637+
if (NULL != vm->jitConfig) {
638+
J9VMHookInterface vmhookInterface = vm->hookInterface;
639+
640+
/* can_tag_objects */
641+
hookDisableHelper(vm, vmHook, J9HOOK_MM_OMR_GLOBAL_GC_END, jvmtiHookGCEnd, FALSE, NULL);
642+
hookDisableHelper(vm, vmHook, J9HOOK_MM_OMR_LOCAL_GC_END, jvmtiHookGCEnd, FALSE, NULL);
643+
644+
/* can_generate_single_step_events */
645+
hookDisableHelper(vm, vmHook, J9HOOK_VM_SINGLE_STEP, jvmtiHookSingleStep, FALSE, NULL);
646+
647+
/* can_generate_exception_events */
648+
hookDisableHelper(vm, vmHook, J9HOOK_VM_EXCEPTION_THROW, jvmtiHookExceptionThrow, TRUE, NULL);
649+
hookDisableHelper(vm, vmHook, J9HOOK_VM_EXCEPTION_CATCH, jvmtiHookExceptionCatch, TRUE, NULL);
650+
651+
/* can_generate_frame_pop_events */
652+
hookDisableHelper(vm, vmHook, J9HOOK_VM_FRAME_POP, jvmtiHookFramePop, FALSE, NULL);
653+
654+
/* can_generate_breakpoint_events */
655+
hookDisableHelper(vm, vmHook, J9HOOK_VM_BREAKPOINT, jvmtiHookBreakpoint, TRUE, NULL);
656+
657+
/* can_generate_method_entry_events */
658+
hookDisableHelper(vm, vmHook, J9HOOK_VM_METHOD_ENTER, jvmtiHookMethodEnter, TRUE, NULL);
659+
hookDisableHelper(vm, vmHook, J9HOOK_VM_NATIVE_METHOD_ENTER, jvmtiHookMethodEnter, TRUE, NULL);
660+
661+
/* can_generate_method_exit_events */
662+
hookDisableHelper(vm, vmHook, J9HOOK_VM_METHOD_RETURN, jvmtiHookMethodExit, TRUE, NULL);
663+
hookDisableHelper(vm, vmHook, J9HOOK_VM_NATIVE_METHOD_RETURN, jvmtiHookMethodExit, TRUE, NULL);
664+
665+
/* can_generate_monitor_events */
666+
hookDisableHelper(vm, vmHook, J9HOOK_VM_MONITOR_CONTENDED_ENTER, jvmtiHookMonitorContendedEnter, FALSE, NULL);
667+
hookDisableHelper(vm, vmHook, J9HOOK_VM_MONITOR_CONTENDED_ENTERED, jvmtiHookMonitorContendedEntered, FALSE, NULL);
668+
hookDisableHelper(vm, vmHook, J9HOOK_VM_MONITOR_WAIT, jvmtiHookMonitorWait, FALSE, NULL);
669+
hookDisableHelper(vm, vmHook, J9HOOK_VM_MONITOR_WAITED, jvmtiHookMonitorWaited, FALSE, NULL);
670+
671+
/* can_generate_garbage_collection_events */
672+
hookDisableHelper(vm, vmHook, J9HOOK_MM_OMR_GLOBAL_GC_START, jvmtiHookGCStart, FALSE, NULL);
673+
hookDisableHelper(vm, vmHook, J9HOOK_MM_OMR_LOCAL_GC_START, jvmtiHookGCStart, FALSE, NULL);
674+
675+
#if JAVA_SPEC_VERSION >= 21
676+
/* can_support_virtual_threads */
677+
hookDisableHelper(vm, vmHook, J9HOOK_VM_VIRTUAL_THREAD_STARTED, jvmtiHookVirtualThreadStarted, FALSE, NULL);
678+
hookDisableHelper(vm, vmHook, J9HOOK_VM_VIRTUAL_THREAD_END, jvmtiHookVirtualThreadEnd, FALSE, NULL);
679+
#endif /* JAVA_SPEC_VERSION >= 21 */
680+
681+
/* can_generate_field_modification_events */
682+
hookDisableHelper(vm, vmHook, J9HOOK_VM_PUT_FIELD, jvmtiHookFieldModification, FALSE, NULL);
683+
hookDisableHelper(vm, vmHook, J9HOOK_VM_PUT_STATIC_FIELD, jvmtiHookFieldModification, FALSE, NULL);
684+
685+
/* can_generate_field_access_events */
686+
hookDisableHelper(vm, vmHook, J9HOOK_VM_GET_FIELD, jvmtiHookFieldAccess, FALSE, NULL);
687+
hookDisableHelper(vm, vmHook, J9HOOK_VM_GET_STATIC_FIELD, jvmtiHookFieldAccess, FALSE, NULL);
688+
689+
/* can_pop_frame & can_force_early_return */
690+
if (J9_EVENT_IS_HOOKED_OR_RESERVED(vmhookInterface, J9HOOK_VM_POP_FRAMES_INTERRUPT)) {
691+
hookDisableHelper(vm, vmHook, J9HOOK_VM_POP_FRAMES_INTERRUPT, jvmtiHookPopFramesInterrupt, TRUE, J9JVMTI_DATA_FROM_VM(vm));
692+
}
693+
}
694+
695+
(*jvmti_env)->RelinquishCapabilities(jvmti_env, &vm->checkpointState.requiredCapabilities);
696+
}
565697
#endif /* defined(J9VM_OPT_CRIU_SUPPORT)*/
566698

567699
static IDATA
@@ -1914,6 +2046,17 @@ hookGlobalEvents(J9JVMTIData * jvmtiData)
19142046
return 1;
19152047
}
19162048

2049+
#if defined(J9VM_OPT_CRIU_SUPPORT)
2050+
if (vm->internalVMFunctions->isDebugOnRestoreEnabled(vm->mainThread)) {
2051+
if ((*vmHook)->J9HookRegisterWithCallSite(vmHook, J9HOOK_TAG_AGENT_ID | J9HOOK_VM_PREPARING_FOR_RESTORE, jvmtiHookVMRestoreCRIUInit, OMR_GET_CALLSITE(), jvmtiData, J9HOOK_AGENTID_FIRST)) {
2052+
return 1;
2053+
}
2054+
if ((*vmHook)->J9HookRegisterWithCallSite(vmHook, J9HOOK_TAG_AGENT_ID | J9HOOK_VM_CRIU_RESTORE, jvmtiHookVMRestoreStartAgent, OMR_GET_CALLSITE(), jvmtiData, J9HOOK_AGENTID_FIRST)) {
2055+
return 1;
2056+
}
2057+
}
2058+
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
2059+
19172060
if ((*vmHook)->J9HookRegisterWithCallSite(vmHook, J9HOOK_TAG_AGENT_ID | J9HOOK_VM_SHUTTING_DOWN, jvmtiHookVMShutdownLast, OMR_GET_CALLSITE(), jvmtiData, J9HOOK_AGENTID_LAST)) {
19182061
return 1;
19192062
}
@@ -1952,7 +2095,6 @@ unhookGlobalEvents(J9JVMTIData * jvmtiData)
19522095
(*vmHook)->J9HookUnregister(vmHook, J9HOOK_VM_SHUTTING_DOWN, jvmtiHookVMShutdownLast, NULL);
19532096
}
19542097

1955-
19562098
static void
19572099
jvmtiHookMonitorContendedEnter(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
19582100
{

0 commit comments

Comments
 (0)