Skip to content

Commit 686b845

Browse files
committed
USDT event for JVMTI object allocation sample
1 parent 3eef5e4 commit 686b845

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
provider hotspot_jvmti {
2+
probe AllocObject__sample(char*, size_t, size_t);
3+
};
4+
5+
#pragma D attributes Standard/Standard/Common provider hotspot_jvmti provider
6+
#pragma D attributes Private/Private/Unknown provider hotspot_jvmti module
7+
#pragma D attributes Private/Private/Unknown provider hotspot_jvmti function
8+
#pragma D attributes Standard/Standard/Common provider hotspot_jvmti name
9+
#pragma D attributes Evolving/Evolving/Common provider hotspot_jvmti args

src/hotspot/share/runtime/threadHeapSampler.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include "runtime/threadHeapSampler.hpp"
3333
#include "utilities/checkedCast.hpp"
3434

35+
#include "oops/oop.inline.hpp"
36+
#include "utilities/dtrace.hpp"
37+
3538
// Cheap random number generator.
3639
uint64_t ThreadHeapSampler::_rnd;
3740
// Default is 512kb.
@@ -424,6 +427,8 @@ void ThreadHeapSampler::check_for_sampling(oop obj, size_t allocation_size, size
424427
return;
425428
}
426429

430+
HOTSPOT_JVMTI_ALLOCOBJECT_SAMPLE(obj->klass()->name()->as_C_string(), allocation_size, bytes_since_allocation);
431+
427432
JvmtiExport::sampled_object_alloc_event_collector(obj);
428433

429434
size_t overflow_bytes = total_allocated_bytes - _bytes_until_sample;

src/hotspot/share/utilities/dtrace.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "dtracefiles/hotspot.h"
3838
#include "dtracefiles/hotspot_jni.h"
39+
#include "dtracefiles/hotspot_jvmti.h"
3940
#include "dtracefiles/hs_private.h"
4041

4142
#else /* defined(DTRACE_ENABLED) */

src/hotspot/share/utilities/dtrace_disabled.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,9 @@
10801080
#define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0)
10811081
#define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED() 0
10821082

1083+
/* JVMTI */
1084+
#define HOTSPOT_JVMTI_ALLOCOBJECT_SAMPLE(arg0, arg1, arg2)
1085+
10831086
/* Modules */
10841087
#define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1)
10851088
#define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED() 0

0 commit comments

Comments
 (0)