Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Aug 21, 2024
1 parent 6006208 commit 3a5bfec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/hotspot/os/posix/dtrace/hotspot_gc.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
provider hotspot_gc {
probe AllocObject__sample(char*, size_t, size_t);
};

#pragma D attributes Standard/Standard/Common provider hotspot_gc provider
#pragma D attributes Private/Private/Unknown provider hotspot_gc module
#pragma D attributes Private/Private/Unknown provider hotspot_gc function
#pragma D attributes Standard/Standard/Common provider hotspot_gc name
#pragma D attributes Evolving/Evolving/Common provider hotspot_gc args
5 changes: 5 additions & 0 deletions src/hotspot/share/runtime/threadHeapSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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.
Expand Down Expand Up @@ -425,6 +428,8 @@ void ThreadHeapSampler::check_for_sampling(oop obj, size_t allocation_size, size
return;
}

HOTSPOT_GC_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;
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/dtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "dtracefiles/hotspot.h"
#include "dtracefiles/hotspot_jni.h"
#include "dtracefiles/hotspot_gc.h"
#include "dtracefiles/hs_private.h"

#else /* defined(DTRACE_ENABLED) */
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/utilities/dtrace_disabled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,8 @@
#define HOTSPOT_JNI_GETMODULE_RETURN(arg0)
#define HOTSPOT_JNI_GETMODULE_RETURN_ENABLED()

#define HOTSPOT_GC_ALLOCOBJECT_SAMPLE(arg0, arg1, arg2)

#else /* !defined(DTRACE_ENABLED) */
#error This file should only be included when dtrace is not enabled
#endif /* !defined(DTRACE_ENABLED) */
Expand Down

0 comments on commit 3a5bfec

Please sign in to comment.