diff --git a/src/hotspot/os/posix/dtrace/hotspot_jvmti.d b/src/hotspot/os/posix/dtrace/hotspot_jvmti.d new file mode 100644 index 0000000000000..d2c15fee59b67 --- /dev/null +++ b/src/hotspot/os/posix/dtrace/hotspot_jvmti.d @@ -0,0 +1,9 @@ +provider hotspot_jvmti { + probe AllocObject__sample(char*, size_t, size_t); +}; + +#pragma D attributes Standard/Standard/Common provider hotspot_jvmti provider +#pragma D attributes Private/Private/Unknown provider hotspot_jvmti module +#pragma D attributes Private/Private/Unknown provider hotspot_jvmti function +#pragma D attributes Standard/Standard/Common provider hotspot_jvmti name +#pragma D attributes Evolving/Evolving/Common provider hotspot_jvmti args diff --git a/src/hotspot/share/runtime/threadHeapSampler.cpp b/src/hotspot/share/runtime/threadHeapSampler.cpp index 04f3f8b220a30..1c39dd6138be7 100644 --- a/src/hotspot/share/runtime/threadHeapSampler.cpp +++ b/src/hotspot/share/runtime/threadHeapSampler.cpp @@ -32,6 +32,9 @@ #include "runtime/threadHeapSampler.hpp" #include "utilities/checkedCast.hpp" +#include "oops/oop.inline.hpp" +#include "utilities/dtrace.hpp" + // Cheap random number generator. uint64_t ThreadHeapSampler::_rnd; // Default is 512kb. @@ -424,6 +427,8 @@ void ThreadHeapSampler::check_for_sampling(oop obj, size_t allocation_size, size return; } + HOTSPOT_JVMTI_ALLOCOBJECT_SAMPLE(obj->klass()->name()->as_C_string(), allocation_size, bytes_since_allocation); + JvmtiExport::sampled_object_alloc_event_collector(obj); size_t overflow_bytes = total_allocated_bytes - _bytes_until_sample; diff --git a/src/hotspot/share/utilities/dtrace.hpp b/src/hotspot/share/utilities/dtrace.hpp index d6fa51efbeaa1..47bf302dfdefc 100644 --- a/src/hotspot/share/utilities/dtrace.hpp +++ b/src/hotspot/share/utilities/dtrace.hpp @@ -36,6 +36,7 @@ #include "dtracefiles/hotspot.h" #include "dtracefiles/hotspot_jni.h" +#include "dtracefiles/hotspot_jvmti.h" #include "dtracefiles/hs_private.h" #else /* defined(DTRACE_ENABLED) */ diff --git a/src/hotspot/share/utilities/dtrace_disabled.hpp b/src/hotspot/share/utilities/dtrace_disabled.hpp index 6cbd79326ac1f..3c6dd1abbb843 100644 --- a/src/hotspot/share/utilities/dtrace_disabled.hpp +++ b/src/hotspot/share/utilities/dtrace_disabled.hpp @@ -1080,6 +1080,9 @@ #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0) #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED() 0 +/* JVMTI */ +#define HOTSPOT_JVMTI_ALLOCOBJECT_SAMPLE(arg0, arg1, arg2) + /* Modules */ #define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1) #define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED() 0