mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8046598: Scalable Native memory tracking development
Enhance scalability of native memory tracking Reviewed-by: coleenp, ctornqvi, gtriantafill
This commit is contained in:
parent
40b035d141
commit
f0cf82f571
72 changed files with 5166 additions and 6109 deletions
|
@ -52,8 +52,10 @@
|
|||
#include "gc_implementation/g1/heapRegionRemSet.hpp"
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#ifdef INCLUDE_NMT
|
||||
#if INCLUDE_NMT
|
||||
#include "services/mallocSiteTable.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "utilities/nativeCallStack.hpp"
|
||||
#endif // INCLUDE_NMT
|
||||
|
||||
#include "compiler/compileBroker.hpp"
|
||||
|
@ -255,14 +257,18 @@ WB_END
|
|||
// NMT picks it up correctly
|
||||
WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
|
||||
jlong addr = 0;
|
||||
|
||||
if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) {
|
||||
addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
|
||||
}
|
||||
|
||||
return addr;
|
||||
WB_END
|
||||
|
||||
// Alloc memory with pseudo call stack. The test can create psudo malloc
|
||||
// allocation site to stress the malloc tracking.
|
||||
WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack))
|
||||
address pc = (address)(size_t)pseudo_stack;
|
||||
NativeCallStack stack(&pc, 1);
|
||||
return (jlong)os::malloc(size, mtTest, stack);
|
||||
WB_END
|
||||
|
||||
// Free the memory allocated by NMTAllocTest
|
||||
WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem))
|
||||
os::free((void*)(uintptr_t)mem, mtTest);
|
||||
|
@ -271,10 +277,8 @@ WB_END
|
|||
WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size))
|
||||
jlong addr = 0;
|
||||
|
||||
if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) {
|
||||
addr = (jlong)(uintptr_t)os::reserve_memory(size);
|
||||
MemTracker::record_virtual_memory_type((address)addr, mtTest);
|
||||
}
|
||||
|
||||
return addr;
|
||||
WB_END
|
||||
|
@ -293,20 +297,20 @@ WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong siz
|
|||
os::release_memory((char *)(uintptr_t)addr, size);
|
||||
WB_END
|
||||
|
||||
// Block until the current generation of NMT data to be merged, used to reliably test the NMT feature
|
||||
WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env))
|
||||
|
||||
if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MemTracker::wbtest_wait_for_data_merge();
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env))
|
||||
return MemTracker::tracking_level() == MemTracker::NMT_detail;
|
||||
return MemTracker::tracking_level() == NMT_detail;
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(void, WB_NMTOverflowHashBucket(JNIEnv* env, jobject o, jlong num))
|
||||
address pc = (address)1;
|
||||
for (jlong index = 0; index < num; index ++) {
|
||||
NativeCallStack stack(&pc, 1);
|
||||
os::malloc(0, mtTest, stack);
|
||||
pc += MallocSiteTable::hash_buckets();
|
||||
}
|
||||
WB_END
|
||||
|
||||
|
||||
#endif // INCLUDE_NMT
|
||||
|
||||
static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) {
|
||||
|
@ -843,12 +847,13 @@ static JNINativeMethod methods[] = {
|
|||
#endif // INCLUDE_ALL_GCS
|
||||
#if INCLUDE_NMT
|
||||
{CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
|
||||
{CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack},
|
||||
{CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree },
|
||||
{CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory },
|
||||
{CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory },
|
||||
{CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory },
|
||||
{CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory },
|
||||
{CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge},
|
||||
{CC"NMTOverflowHashBucket", CC"(J)V", (void*)&WB_NMTOverflowHashBucket},
|
||||
{CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported},
|
||||
#endif // INCLUDE_NMT
|
||||
{CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue