47 #include "gc_implementation/g1/concurrentMark.hpp" |
47 #include "gc_implementation/g1/concurrentMark.hpp" |
48 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
48 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
49 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
49 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
50 #endif // INCLUDE_ALL_GCS |
50 #endif // INCLUDE_ALL_GCS |
51 |
51 |
52 #ifdef INCLUDE_NMT |
52 #if INCLUDE_NMT |
|
53 #include "services/mallocSiteTable.hpp" |
53 #include "services/memTracker.hpp" |
54 #include "services/memTracker.hpp" |
|
55 #include "utilities/nativeCallStack.hpp" |
54 #endif // INCLUDE_NMT |
56 #endif // INCLUDE_NMT |
55 |
57 |
56 #include "compiler/compileBroker.hpp" |
58 #include "compiler/compileBroker.hpp" |
57 #include "runtime/compilationPolicy.hpp" |
59 #include "runtime/compilationPolicy.hpp" |
58 |
60 |
274 #if INCLUDE_NMT |
276 #if INCLUDE_NMT |
275 // Alloc memory using the test memory type so that we can use that to see if |
277 // Alloc memory using the test memory type so that we can use that to see if |
276 // NMT picks it up correctly |
278 // NMT picks it up correctly |
277 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) |
279 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) |
278 jlong addr = 0; |
280 jlong addr = 0; |
279 |
|
280 if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { |
|
281 addr = (jlong)(uintptr_t)os::malloc(size, mtTest); |
281 addr = (jlong)(uintptr_t)os::malloc(size, mtTest); |
282 } |
|
283 |
|
284 return addr; |
282 return addr; |
|
283 WB_END |
|
284 |
|
285 // Alloc memory with pseudo call stack. The test can create psudo malloc |
|
286 // allocation site to stress the malloc tracking. |
|
287 WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack)) |
|
288 address pc = (address)(size_t)pseudo_stack; |
|
289 NativeCallStack stack(&pc, 1); |
|
290 return (jlong)os::malloc(size, mtTest, stack); |
285 WB_END |
291 WB_END |
286 |
292 |
287 // Free the memory allocated by NMTAllocTest |
293 // Free the memory allocated by NMTAllocTest |
288 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) |
294 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) |
289 os::free((void*)(uintptr_t)mem, mtTest); |
295 os::free((void*)(uintptr_t)mem, mtTest); |
290 WB_END |
296 WB_END |
291 |
297 |
292 WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) |
298 WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) |
293 jlong addr = 0; |
299 jlong addr = 0; |
294 |
300 |
295 if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { |
|
296 addr = (jlong)(uintptr_t)os::reserve_memory(size); |
301 addr = (jlong)(uintptr_t)os::reserve_memory(size); |
297 MemTracker::record_virtual_memory_type((address)addr, mtTest); |
302 MemTracker::record_virtual_memory_type((address)addr, mtTest); |
298 } |
|
299 |
303 |
300 return addr; |
304 return addr; |
301 WB_END |
305 WB_END |
302 |
306 |
303 |
307 |
312 |
316 |
313 WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
317 WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
314 os::release_memory((char *)(uintptr_t)addr, size); |
318 os::release_memory((char *)(uintptr_t)addr, size); |
315 WB_END |
319 WB_END |
316 |
320 |
317 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature |
|
318 WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) |
|
319 |
|
320 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { |
|
321 return false; |
|
322 } |
|
323 |
|
324 return MemTracker::wbtest_wait_for_data_merge(); |
|
325 WB_END |
|
326 |
|
327 WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) |
321 WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) |
328 return MemTracker::tracking_level() == MemTracker::NMT_detail; |
322 return MemTracker::tracking_level() == NMT_detail; |
329 WB_END |
323 WB_END |
|
324 |
|
325 WB_ENTRY(void, WB_NMTOverflowHashBucket(JNIEnv* env, jobject o, jlong num)) |
|
326 address pc = (address)1; |
|
327 for (jlong index = 0; index < num; index ++) { |
|
328 NativeCallStack stack(&pc, 1); |
|
329 os::malloc(0, mtTest, stack); |
|
330 pc += MallocSiteTable::hash_buckets(); |
|
331 } |
|
332 WB_END |
|
333 |
330 |
334 |
331 #endif // INCLUDE_NMT |
335 #endif // INCLUDE_NMT |
332 |
336 |
333 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { |
337 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { |
334 assert(method != NULL, "method should not be null"); |
338 assert(method != NULL, "method should not be null"); |
859 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
863 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
860 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
864 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
861 #endif // INCLUDE_ALL_GCS |
865 #endif // INCLUDE_ALL_GCS |
862 #if INCLUDE_NMT |
866 #if INCLUDE_NMT |
863 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, |
867 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, |
|
868 {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack}, |
864 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, |
869 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, |
865 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, |
870 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, |
866 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, |
871 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, |
867 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, |
872 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, |
868 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, |
873 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, |
869 {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge}, |
874 {CC"NMTOverflowHashBucket", CC"(J)V", (void*)&WB_NMTOverflowHashBucket}, |
870 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, |
875 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, |
871 #endif // INCLUDE_NMT |
876 #endif // INCLUDE_NMT |
872 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, |
877 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, |
873 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", |
878 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", |
874 (void*)&WB_DeoptimizeMethod }, |
879 (void*)&WB_DeoptimizeMethod }, |