Skip to content
Open
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
7 changes: 7 additions & 0 deletions ddprof-lib/src/main/cpp/hotspot/jitCodeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ CodeBlob* JitCodeCache::findRuntimeStub(const void *address) {
_stubs_lock.unlockShared();
return stub;
}

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

static CodeBlob* findRuntimeStub(const void *address);

// Approximate heap usage of the runtime-stubs code cache, via
// CodeCache::memoryUsage() (a capacity/count-based estimate today; #677
// makes it exact). Read under the shared stubs lock because
// DynamicCodeGenerated() mutates _runtime_stubs (add()/expand()) concurrently.
static long long runtimeStubsMemoryUsage();
static bool isJitCode(const void* pc) {
return CodeHeap::contains(pc);
}
Expand Down
6 changes: 5 additions & 1 deletion ddprof-lib/src/main/cpp/profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "itimer.h"
#include "hotspot/vmStructs.inline.h"
#include "hotspot/hotspotSupport.h"
#include "hotspot/jitCodeCache.h"
#include "j9/j9Support.h"
#include "j9/j9WallClock.h"
#include "jvmSupport.h"
Expand Down Expand Up @@ -1737,8 +1738,11 @@ 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 (it previously duplicated
// native_libs.memoryUsage() by copy-paste). Read under its shared lock.
Counters::set(CODECACHE_RUNTIME_STUBS_SIZE_BYTES,
native_libs.memoryUsage());
JitCodeCache::runtimeStubsMemoryUsage());

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