Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ddprof-lib/src/main/cpp/hotspot/hotspotSupport.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,10 @@ class HotspotSupport {
returnJitCodeCache::isJitCode(p);
}

staticinlinelonglongruntimeStubsMemoryUsage() {
returnJitCodeCache::runtimeStubsMemoryUsage();
}

// If should load all jmethodIDs
staticinlineboolshouldPreloadJmethodIDs(Arguments& args) {
CStack cstack = args._cstack;
Expand Down
7 changes: 7 additions & 0 deletions ddprof-lib/src/main/cpp/hotspot/jitCodeCache.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,3 +52,10 @@ CodeBlob* JitCodeCache::findRuntimeStub(const void *address) {
_stubs_lock.unlockShared();
return stub;
}

longlongJitCodeCache::runtimeStubsMemoryUsage() {
_stubs_lock.lockShared();
longlong usage = _runtime_stubs.memoryUsage();
_stubs_lock.unlockShared();
return usage;
}
5 changes: 5 additions & 0 deletions ddprof-lib/src/main/cpp/hotspot/jitCodeCache.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,11 @@ class JitCodeCache {
}

static CodeBlob* findRuntimeStub(constvoid *address);

// Heap usage of the runtime-stubs code cache, via CodeCache::memoryUsage().
// Read under the shared stubs lock because DynamicCodeGenerated() mutates
// _runtime_stubs (add()/expand()) concurrently.
staticlonglongruntimeStubsMemoryUsage();
staticboolisJitCode(constvoid* pc) {
returnCodeHeap::contains(pc);
}
Expand Down
3 changes: 3 additions & 0 deletions ddprof-lib/src/main/cpp/jvmSupport.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,9 @@ class JVMSupport {
static int walkJavaStack(StackWalkRequest& request);
static inline bool canUnwind(const StackFrame& frame, const void*& pc);
static inline bool isJitCode(const void* pc);
// Live heap usage of the JIT runtime-stubs code cache. HotSpot-only; 0 on
// other VMs (J9/Zing), which have no such cache.
static inline long long runtimeStubsMemoryUsage();

static void loadAllMethodIDsIfNeeded(jvmtiEnv *jvmti, JNIEnv *jni);
static bool loadMethodIDsIfNeeded(jvmtiEnv *jvmti, JNIEnv *jni, jclass klass);
Expand Down
8 changes: 8 additions & 0 deletions ddprof-lib/src/main/cpp/jvmSupport.inline.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,14 @@ bool JVMSupport::isJitCode(const void* pc) {
}
}

long longJVMSupport::runtimeStubsMemoryUsage() {
if (VM::isHotspot()) {
returnHotspotSupport::runtimeStubsMemoryUsage();
} else {
return0;
}
}

// Resolve method pointer to jmethodID
jmethodIDJVMSupport::resolve(constvoid*method) {
if (VM::isHotspot()) {
Expand Down
7 changes: 6 additions & 1 deletion ddprof-lib/src/main/cpp/profiler.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@
#include "j9/j9Support.h"
#include "j9/j9WallClock.h"
#include "jvmSupport.h"
#include "jvmSupport.inline.h"
#include "jvmThread.h"
#include "libraryPatcher.h"
#include "objectSampler.h"
Expand DownExpand Up@@ -1780,8 +1781,12 @@ Error Profiler::dump(const char *path, const int length) {
const CodeCacheArray& native_libs = _libs->native_libs();
Counters::set(CODECACHE_NATIVE_COUNT, native_libs.count());
Counters::set(CODECACHE_NATIVE_SIZE_BYTES, native_libs.memoryUsage());
// The runtime-stubs counter reflects the JIT runtime-stubs code cache, a
// separate cache from the native libraries. Routed through JVMSupport so
// the HotSpot-only implementation stays behind the VM abstraction (0 on
// J9/Zing). Read under its shared lock.
Counters::set(CODECACHE_RUNTIME_STUBS_SIZE_BYTES,
Comment thread
rkennke marked this conversation as resolved.
native_libs.memoryUsage());
JVMSupport::runtimeStubsMemoryUsage());

Error err = Error::OK;
// rotateDictsAndRun rotates the dictionaries, takes lockAll() around the
Expand Down
Loading