1.1 --- a/src/share/vm/prims/whitebox.cpp Wed Aug 27 09:36:55 2014 +0200 1.2 +++ b/src/share/vm/prims/whitebox.cpp Wed Aug 27 08:19:12 2014 -0400 1.3 @@ -49,8 +49,10 @@ 1.4 #include "gc_implementation/g1/heapRegionRemSet.hpp" 1.5 #endif // INCLUDE_ALL_GCS 1.6 1.7 -#ifdef INCLUDE_NMT 1.8 +#if INCLUDE_NMT 1.9 +#include "services/mallocSiteTable.hpp" 1.10 #include "services/memTracker.hpp" 1.11 +#include "utilities/nativeCallStack.hpp" 1.12 #endif // INCLUDE_NMT 1.13 1.14 #include "compiler/compileBroker.hpp" 1.15 @@ -276,12 +278,16 @@ 1.16 // NMT picks it up correctly 1.17 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) 1.18 jlong addr = 0; 1.19 + addr = (jlong)(uintptr_t)os::malloc(size, mtTest); 1.20 + return addr; 1.21 +WB_END 1.22 1.23 - if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { 1.24 - addr = (jlong)(uintptr_t)os::malloc(size, mtTest); 1.25 - } 1.26 - 1.27 - return addr; 1.28 +// Alloc memory with pseudo call stack. The test can create psudo malloc 1.29 +// allocation site to stress the malloc tracking. 1.30 +WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack)) 1.31 + address pc = (address)(size_t)pseudo_stack; 1.32 + NativeCallStack stack(&pc, 1); 1.33 + return (jlong)os::malloc(size, mtTest, stack); 1.34 WB_END 1.35 1.36 // Free the memory allocated by NMTAllocTest 1.37 @@ -292,10 +298,8 @@ 1.38 WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) 1.39 jlong addr = 0; 1.40 1.41 - if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { 1.42 addr = (jlong)(uintptr_t)os::reserve_memory(size); 1.43 MemTracker::record_virtual_memory_type((address)addr, mtTest); 1.44 - } 1.45 1.46 return addr; 1.47 WB_END 1.48 @@ -314,20 +318,20 @@ 1.49 os::release_memory((char *)(uintptr_t)addr, size); 1.50 WB_END 1.51 1.52 -// Block until the current generation of NMT data to be merged, used to reliably test the NMT feature 1.53 -WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) 1.54 - 1.55 - if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { 1.56 - return false; 1.57 - } 1.58 - 1.59 - return MemTracker::wbtest_wait_for_data_merge(); 1.60 +WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) 1.61 + return MemTracker::tracking_level() == NMT_detail; 1.62 WB_END 1.63 1.64 -WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) 1.65 - return MemTracker::tracking_level() == MemTracker::NMT_detail; 1.66 +WB_ENTRY(void, WB_NMTOverflowHashBucket(JNIEnv* env, jobject o, jlong num)) 1.67 + address pc = (address)1; 1.68 + for (jlong index = 0; index < num; index ++) { 1.69 + NativeCallStack stack(&pc, 1); 1.70 + os::malloc(0, mtTest, stack); 1.71 + pc += MallocSiteTable::hash_buckets(); 1.72 + } 1.73 WB_END 1.74 1.75 + 1.76 #endif // INCLUDE_NMT 1.77 1.78 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { 1.79 @@ -861,12 +865,13 @@ 1.80 #endif // INCLUDE_ALL_GCS 1.81 #if INCLUDE_NMT 1.82 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, 1.83 + {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack}, 1.84 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, 1.85 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, 1.86 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, 1.87 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, 1.88 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, 1.89 - {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge}, 1.90 + {CC"NMTOverflowHashBucket", CC"(J)V", (void*)&WB_NMTOverflowHashBucket}, 1.91 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, 1.92 #endif // INCLUDE_NMT 1.93 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },