Skip to content

Commit

Permalink
Merge pull request #16501 from dipak-bagadiya/jvmti-MountUnmout-fix
Browse files Browse the repository at this point in the history
Add JVMTI VirtualThread Mount and Unmount Events
  • Loading branch information
gacholio authored Feb 2, 2023
2 parents cf3c1ee + 326b9e1 commit 114c390
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 53 deletions.
3 changes: 3 additions & 0 deletions runtime/include/ibmjvmti.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
#define COM_SUN_HOTSPOT_FUNCTIONS_GET_VIRTUAL_THREAD "com.sun.hotspot.functions.GetVirtualThread"
#define COM_SUN_HOTSPOT_FUNCTIONS_GET_CARRIER_THREAD "com.sun.hotspot.functions.GetCarrierThread"

#define COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT "com.sun.hotspot.events.VirtualThreadMount"
#define COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT "com.sun.hotspot.events.VirtualThreadUnmount"

#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA5 1
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA6 2
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA7 3
Expand Down
4 changes: 3 additions & 1 deletion runtime/j9vm/javanextvmi.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2022 IBM Corp. and others
* Copyright (c) 2018, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -390,6 +390,7 @@ JVM_VirtualThreadMountEnd(JNIEnv *env, jobject thread, jboolean firstMount)

TRIGGER_J9HOOK_VM_VIRTUAL_THREAD_STARTED(vm->hookInterface, currentThread);
}
TRIGGER_J9HOOK_VM_VIRTUAL_THREAD_MOUNT(vm->hookInterface, currentThread);

/* Allow thread to be inspected again. */
Assert_SC_true(-1 == J9OBJECT_I64_LOAD(currentThread, threadObj, vm->virtualThreadInspectorCountOffset));
Expand Down Expand Up @@ -460,6 +461,7 @@ JVM_VirtualThreadUnmountBegin(JNIEnv *env, jobject thread, jboolean lastUnmount)
*/
J9OBJECT_I64_STORE(currentThread, threadObj, vm->virtualThreadInspectorCountOffset, -1);

TRIGGER_J9HOOK_VM_VIRTUAL_THREAD_UNMOUNT(vm->hookInterface, currentThread);
if (lastUnmount) {
if (NULL != vm->liveVirtualThreadList) {
j9object_t threadPrev = J9OBJECT_OBJECT_LOAD(currentThread, threadObj, vm->virtualThreadLinkPreviousOffset);
Expand Down
6 changes: 6 additions & 0 deletions runtime/jvmti/j9jvmti.tdf
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,9 @@ TraceEntry=Trc_JVMTI_jvmtiGetVirtualThread_Exit Overhead=1 Level=1 Noenv Templat

TraceEntry=Trc_JVMTI_jvmtiGetCarrierThread_Entry Overhead=1 Level=1 Noenv Template="GetCarrierThread env=%p"
TraceEntry=Trc_JVMTI_jvmtiGetCarrierThread_Exit Overhead=1 Level=1 Noenv Template="GetCarrierThread returning %d"

TraceEntry=Trc_JVMTI_jvmtiHookVirtualThreadUnmount_Entry Overhead=1 Level=5 Noenv Template="HookVirtualThreadUnmount"
TraceExit=Trc_JVMTI_jvmtiHookVirtualThreadUnmount_Exit Overhead=1 Level=5 Noenv Template="HookVirtualThreadUnmount"

TraceEntry=Trc_JVMTI_jvmtiHookVirtualThreadMount_Entry Overhead=1 Level=5 Noenv Template="HookVirtualThreadMount"
TraceExit=Trc_JVMTI_jvmtiHookVirtualThreadMount_Exit Overhead=1 Level=5 Noenv Template="HookVirtualThreadMount"
6 changes: 4 additions & 2 deletions runtime/jvmti/jvmtiEventManagement.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2022 IBM Corp. and others
* Copyright (c) 1991, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -100,7 +100,7 @@ jvmtiSetEventNotificationMode(jvmtiEnv* env,
/* Ensure the required capabilities are enabled for the event if the event is being enabled */

if (mode == JVMTI_ENABLE) {
switch(event_type) {
switch((int)event_type) {
case JVMTI_EVENT_FIELD_MODIFICATION:
ENSURE_CAPABILITY(env, can_generate_field_modification_events);
break;
Expand Down Expand Up @@ -159,6 +159,8 @@ jvmtiSetEventNotificationMode(jvmtiEnv* env,
#if JAVA_SPEC_VERSION >= 19
case JVMTI_EVENT_VIRTUAL_THREAD_START:
case JVMTI_EVENT_VIRTUAL_THREAD_END:
case J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT:
case J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT:
ENSURE_CAPABILITY(env, can_support_virtual_threads);
break;
#endif /* JAVA_SPEC_VERSION >= 19 */
Expand Down
26 changes: 26 additions & 0 deletions runtime/jvmti/jvmtiExtensionMechanism.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ static const jvmtiParamInfo jvmtiRegisterTracePointSubscriber_params[] = {
static const jvmtiParamInfo jvmtiDeregisterTracepointSubscriber_params[] = {
{ "subscriptionID", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, JNI_FALSE }
};
#if JAVA_SPEC_VERSION >= 19
/* (jvmtiEnv *jvmti_env, jthread thread) */
static const jvmtiParamInfo jvmtiVirtualThreadMount_params[] = {
{ "jni_env", JVMTI_KIND_IN_PTR, JVMTI_TYPE_JNIENV, JNI_FALSE },
{ "thread", JVMTI_KIND_IN, JVMTI_TYPE_JTHREAD, JNI_FALSE }
};

static const jvmtiParamInfo jvmtiVirtualThreadUnmount_params[] = {
{ "jni_env", JVMTI_KIND_IN_PTR, JVMTI_TYPE_JNIENV, JNI_FALSE },
{ "thread", JVMTI_KIND_IN, JVMTI_TYPE_JTHREAD, JNI_FALSE }
};
#endif /* JAVA_SPEC_VERSION >= 19 */

#if JAVA_SPEC_VERSION >= 19
/* (jvmtiEnv *jvmti_env, jthread carrier_thread, jthread *virtual_thread_ptr) */
Expand Down Expand Up @@ -824,6 +836,20 @@ static const J9JVMTIExtensionEventInfo J9JVMTIExtensionEventInfoTable[] = {
J9NLS_JVMTI_COM_IBM_GARBAGE_COLLECTION_CYCLE_FINISH_DESCRIPTION,
EMPTY_SIZE_AND_TABLE,
},
#if JAVA_SPEC_VERSION >= 19
{
J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT,
COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT,
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT,
SIZE_AND_TABLE(jvmtiVirtualThreadMount_params),
},
{
J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT,
COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT,
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT,
SIZE_AND_TABLE(jvmtiVirtualThreadUnmount_params),
},
#endif /* JAVA_SPEC_VERSION >= 19 */
};

#define NUM_EXTENSION_EVENTS (sizeof(J9JVMTIExtensionEventInfoTable) / sizeof(J9JVMTIExtensionEventInfoTable[0]))
Expand Down
4 changes: 3 additions & 1 deletion runtime/jvmti/jvmtiHelpers.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2022 IBM Corp. and others
* Copyright (c) 1991, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -75,6 +75,8 @@ static const UDATA reasonCodeFromJVMTIEvent[] = {
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VM_DUMP_END, /* J9JVMTI_EVENT_COM_IBM_VM_DUMP_END */
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_START, /* J9JVMTI_EVENT_COM_IBM_GARBAGE_COLLECTION_CYCLE_START */
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_FINISH, /* J9JVMTI_EVENT_COM_IBM_GARBAGE_COLLECTION_CYCLE_FINISH */
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VIRTUAL_THREAD_MOUNT, /* J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT */
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VIRTUAL_THREAD_UNMOUNT, /* J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT */
};
#endif /* J9VM_OPT_JAVA_OFFLOAD_SUPPORT */

Expand Down
92 changes: 91 additions & 1 deletion runtime/jvmti/jvmtiHook.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2022 IBM Corp. and others
* Copyright (c) 1991, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -148,6 +148,8 @@ static UDATA methodExists(J9Class * methodClass, U_8 * nameData, UDATA nameLengt
static void jvmtiHookVirtualThreadStarted (J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData);
static void jvmtiHookVirtualThreadEnd (J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData);
static void jvmtiHookVirtualThreadDestroy (J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void jvmtiHookVirtualThreadMount (J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData);
static void jvmtiHookVirtualThreadUnmount (J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData);
#endif /* JAVA_SPEC_VERSION >= 19 */

static void
Expand Down Expand Up @@ -421,6 +423,86 @@ jvmtiHookVirtualThreadDestroy(J9HookInterface **hook, UDATA eventNum, void *even

TRACE_JVMTI_EVENT_RETURN(jvmtiHookVirtualThreadDestroy);
}

/**
* Virtual thread mount event.
*
* @param hook Hook interface used by the JVM.
* @param eventNum The hook event number
* @param eventData hook specific event data.
* @param userData pointer to J9VMRuntimeStateListener
* @return void.
*/
static void
jvmtiHookVirtualThreadMount(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9VMVirtualThreadMountEvent *data = eventData;
J9JVMTIEnv *j9env = userData;
J9VMThread *currentThread = data->currentThread;
jvmtiExtensionEvent callback = *J9JVMTI_EXTENSION_CALLBACK(j9env, J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT);

Trc_JVMTI_jvmtiHookVirtualThreadMount_Entry();

ENSURE_EVENT_PHASE_LIVE(jvmtiHookVirtualThreadMount, j9env);

/* Call the event callback */

if (NULL != callback) {
jthread threadRef = NULL;
UDATA hadVMAccess = 0;
UDATA javaOffloadOldState = 0;
if (prepareForEvent(
j9env, currentThread, currentThread, J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT,
&threadRef, &hadVMAccess, TRUE, 0, &javaOffloadOldState)
) {
callback((jvmtiEnv *)j9env, (JNIEnv *)currentThread, threadRef);
finishedEvent(currentThread, J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT, hadVMAccess, javaOffloadOldState);
}
}

TRACE_JVMTI_EVENT_RETURN(jvmtiHookVirtualThreadMount);
}

/**
* Virtual thread unmount event.
*
* @param hook Hook interface used by the JVM.
* @param eventNum The hook event number
* @param eventData hook specific event data.
* @param userData pointer to J9VMRuntimeStateListener
* @return void.
*/
static void
jvmtiHookVirtualThreadUnmount(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9VMVirtualThreadUnmountEvent *data = eventData;
J9JVMTIEnv *j9env = userData;
jvmtiExtensionEvent callback = *J9JVMTI_EXTENSION_CALLBACK(j9env, J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT);
J9VMThread *currentThread = data->currentThread;

Trc_JVMTI_jvmtiHookVirtualThreadUnmount_Entry();

ENSURE_EVENT_PHASE_LIVE(jvmtiHookVirtualThreadUnmount, j9env);

/* Call the event callback */

if (NULL != callback) {
jthread threadRef = NULL;
UDATA hadVMAccess = 0;
UDATA javaOffloadOldState = 0;

if (prepareForEvent(
j9env, currentThread, currentThread, J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT,
&threadRef, &hadVMAccess, TRUE, 0, &javaOffloadOldState)
) {
callback((jvmtiEnv *)j9env, (JNIEnv *)currentThread, threadRef);
finishedEvent(data->currentThread, J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT, hadVMAccess, javaOffloadOldState);
}
}

TRACE_JVMTI_EVENT_RETURN(jvmtiHookVirtualThreadUnmount);
}

#endif /* JAVA_SPEC_VERSION >= 19 */

static IDATA
Expand Down Expand Up @@ -618,6 +700,14 @@ processEvent(J9JVMTIEnv* j9env, jint event, J9HookRedirectorFunction redirectorF
} else {
return 0;
}
#if JAVA_SPEC_VERSION >= 19
case J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT:
return redirectorFunction(vmHook, J9HOOK_VM_VIRTUAL_THREAD_MOUNT, jvmtiHookVirtualThreadMount, OMR_GET_CALLSITE(), j9env);

case J9JVMTI_EVENT_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT:
return redirectorFunction(vmHook, J9HOOK_VM_VIRTUAL_THREAD_UNMOUNT, jvmtiHookVirtualThreadUnmount, OMR_GET_CALLSITE(), j9env);
#endif /* JAVA_SPEC_VERSION >= 19 */

}

return 0;
Expand Down
14 changes: 14 additions & 0 deletions runtime/nls/j9ti/jvmti.nls
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,17 @@ J9NLS_JVMTI_COM_SUN_HOTSPOT_FUNCTIONS_GET_CARRIER_THREAD.explanation=Internation
J9NLS_JVMTI_COM_SUN_HOTSPOT_FUNCTIONS_GET_CARRIER_THREAD.system_action=None
J9NLS_JVMTI_COM_SUN_HOTSPOT_FUNCTIONS_GET_CARRIER_THREAD.user_response=None
# END NON-TRANSLATABLE

J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT=Report a virtual thread mount.
# START NON-TRANSLATABLE
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT.explanation=Internationalized description of a JVMTI extension
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT.system_action=None
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT.user_response=None
# END NON-TRANSLATABLE

J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT=Report a virtual thread unmount.
# START NON-TRANSLATABLE
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT.explanation=Internationalized description of a JVMTI extension
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT.system_action=None
J9NLS_JVMTI_COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT.user_response=None
# END NON-TRANSLATABLE
84 changes: 42 additions & 42 deletions runtime/oti/j9consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,51 +741,51 @@ extern "C" {
/* Jazz 99339: The reason code for JVMTI event callbacks on zOS.
* Note: refer to jvmtiEventCallbacks (/runtime/include/jvmti.h) for reserved JVMTI events.
*/
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_INIT 0x16
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_DEATH 0x17
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_THREAD_START 0x18
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_THREAD_END 0x19
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_CLASS_FILE_LOAD_HOOK 0x1A
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_CLASS_LOAD 0x1B
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_CLASS_PREPARE 0x1C
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_START 0x1D
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_EXCEPTION 0x1E
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_EXCEPTION_CATCH 0x1F
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_SINGLE_STEP 0x20
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_FRAME_POP 0x21
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_BREAKPOINT 0x22
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_FIELD_ACCESS 0x23
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_FIELD_MODIFICATION 0x24
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_METHOD_ENTRY 0x25
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_METHOD_EXIT 0x26
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_NATIVE_METHOD_BIND 0x27
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_COMPILED_METHOD_LOAD 0x28
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_COMPILED_METHOD_UNLOAD 0x29
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_DYNAMIC_CODE_GENERATED 0x2A
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_DATA_DUMP_REQUEST 0x2B
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_INIT 0x16
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_DEATH 0x17
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_THREAD_START 0x18
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_THREAD_END 0x19
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_CLASS_FILE_LOAD_HOOK 0x1A
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_CLASS_LOAD 0x1B
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_CLASS_PREPARE 0x1C
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_START 0x1D
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_EXCEPTION 0x1E
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_EXCEPTION_CATCH 0x1F
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_SINGLE_STEP 0x20
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_FRAME_POP 0x21
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_BREAKPOINT 0x22
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_FIELD_ACCESS 0x23
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_FIELD_MODIFICATION 0x24
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_METHOD_ENTRY 0x25
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_METHOD_EXIT 0x26
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_NATIVE_METHOD_BIND 0x27
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_COMPILED_METHOD_LOAD 0x28
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_COMPILED_METHOD_UNLOAD 0x29
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_DYNAMIC_CODE_GENERATED 0x2A
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_DATA_DUMP_REQUEST 0x2B
/* 0x2C Reserved for JVMTI event */
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_WAIT 0x2D
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_WAITED 0x2E
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_CONTENDED_ENTER 0x2F
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_CONTENDED_ENTERED 0x30
/* 0x31 Reserved for JVMTI event */
/* 0x32 Reserved for JVMTI event */
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_WAIT 0x2D
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_WAITED 0x2E
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_CONTENDED_ENTER 0x2F
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_MONITOR_CONTENDED_ENTERED 0x30
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VIRTUAL_THREAD_MOUNT 0x31
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VIRTUAL_THREAD_UNMOUNT 0x32
/* 0x33 Reserved for JVMTI event */
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_RESOURCE_EXHAUSTED 0x34
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_GC_START 0x35
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_GC_FINISH 0x36
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_OBJECT_FREE 0x37
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_OBJECT_ALLOC 0x38
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_RESOURCE_EXHAUSTED 0x34
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_GC_START 0x35
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_GC_FINISH 0x36
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_OBJECT_FREE 0x37
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_VM_OBJECT_ALLOC 0x38
/* 0x39 Reserved for JVMTI event */
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_SAMPLED_OBJECT_ALLOC 0x3A
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_COMPILING_START 0x3B
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_COMPILING_END 0x3C
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_INSTRUMENTABLE_OBJECT_ALLOC 0x3D
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VM_DUMP_START 0x3E
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VM_DUMP_END 0x3F
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_START 0x40
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_FINISH 0x41
#define J9_JNI_OFFLOAD_SWITCH_TRACE_SUBSCRIBER_THREAD 0x42
#define J9_JNI_OFFLOAD_SWITCH_JVMTI_SAMPLED_OBJECT_ALLOC 0x3A
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_COMPILING_START 0x3B
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_COMPILING_END 0x3C
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_INSTRUMENTABLE_OBJECT_ALLOC 0x3D
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VM_DUMP_START 0x3E
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VM_DUMP_END 0x3F
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_START 0x40
#define J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_FINISH 0x41
#define J9_JNI_OFFLOAD_SWITCH_TRACE_SUBSCRIBER_THREAD 0x42

#define J9_JNI_OFFLOAD_SWITCH_THRESHOLD 0x4000
#define J9_JNI_OFFLOAD_WITH_SUBTASKS_FLAG 0x40000000
Expand Down
22 changes: 21 additions & 1 deletion runtime/oti/j9vm.hdf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2006, 2022 IBM Corp. and others
Copyright (c) 2006, 2023 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -1351,4 +1351,24 @@ typedef UDATA (* lookupNativeAddressCallback)(struct J9VMThread *currentThread,
<struct>J9VirtualThreadEndEvent</struct>
<data type="struct J9VMThread*" name="currentThread" description="current thread" />
</event>

<event>
<name>J9HOOK_VM_VIRTUAL_THREAD_MOUNT</name>
<description>
Triggered whenever a virtual thread mounts.
currentThread->threadObject is the virtual thread at the point of trigger.
</description>
<struct>J9VMVirtualThreadMountEvent</struct>
<data type="struct J9VMThread*" name="currentThread" description="current thread" />
</event>

<event>
<name>J9HOOK_VM_VIRTUAL_THREAD_UNMOUNT</name>
<description>
Triggered whenever a virtual thread unmounts.
currentThread->threadObject is the virtual thread at the point of trigger.
</description>
<struct>J9VMVirtualThreadUnmountEvent</struct>
<data type="struct J9VMThread*" name="currentThread" description="current thread" />
</event>
</interface>
Loading

0 comments on commit 114c390

Please sign in to comment.