50 #include "gc_implementation/g1/concurrentMark.hpp" |
50 #include "gc_implementation/g1/concurrentMark.hpp" |
51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
52 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
52 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
53 #endif // INCLUDE_ALL_GCS |
53 #endif // INCLUDE_ALL_GCS |
54 |
54 |
55 #ifdef INCLUDE_NMT |
55 #if INCLUDE_NMT |
|
56 #include "services/mallocSiteTable.hpp" |
56 #include "services/memTracker.hpp" |
57 #include "services/memTracker.hpp" |
|
58 #include "utilities/nativeCallStack.hpp" |
57 #endif // INCLUDE_NMT |
59 #endif // INCLUDE_NMT |
58 |
60 |
59 #include "compiler/compileBroker.hpp" |
61 #include "compiler/compileBroker.hpp" |
60 #include "runtime/compilationPolicy.hpp" |
62 #include "runtime/compilationPolicy.hpp" |
61 |
63 |
253 #if INCLUDE_NMT |
255 #if INCLUDE_NMT |
254 // Alloc memory using the test memory type so that we can use that to see if |
256 // Alloc memory using the test memory type so that we can use that to see if |
255 // NMT picks it up correctly |
257 // NMT picks it up correctly |
256 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) |
258 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) |
257 jlong addr = 0; |
259 jlong addr = 0; |
258 |
|
259 if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { |
|
260 addr = (jlong)(uintptr_t)os::malloc(size, mtTest); |
260 addr = (jlong)(uintptr_t)os::malloc(size, mtTest); |
261 } |
|
262 |
|
263 return addr; |
261 return addr; |
|
262 WB_END |
|
263 |
|
264 // Alloc memory with pseudo call stack. The test can create psudo malloc |
|
265 // allocation site to stress the malloc tracking. |
|
266 WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack)) |
|
267 address pc = (address)(size_t)pseudo_stack; |
|
268 NativeCallStack stack(&pc, 1); |
|
269 return (jlong)os::malloc(size, mtTest, stack); |
264 WB_END |
270 WB_END |
265 |
271 |
266 // Free the memory allocated by NMTAllocTest |
272 // Free the memory allocated by NMTAllocTest |
267 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) |
273 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) |
268 os::free((void*)(uintptr_t)mem, mtTest); |
274 os::free((void*)(uintptr_t)mem, mtTest); |
269 WB_END |
275 WB_END |
270 |
276 |
271 WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) |
277 WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) |
272 jlong addr = 0; |
278 jlong addr = 0; |
273 |
279 |
274 if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { |
|
275 addr = (jlong)(uintptr_t)os::reserve_memory(size); |
280 addr = (jlong)(uintptr_t)os::reserve_memory(size); |
276 MemTracker::record_virtual_memory_type((address)addr, mtTest); |
281 MemTracker::record_virtual_memory_type((address)addr, mtTest); |
277 } |
|
278 |
282 |
279 return addr; |
283 return addr; |
280 WB_END |
284 WB_END |
281 |
285 |
282 |
286 |
291 |
295 |
292 WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
296 WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
293 os::release_memory((char *)(uintptr_t)addr, size); |
297 os::release_memory((char *)(uintptr_t)addr, size); |
294 WB_END |
298 WB_END |
295 |
299 |
296 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature |
|
297 WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) |
|
298 |
|
299 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { |
|
300 return false; |
|
301 } |
|
302 |
|
303 return MemTracker::wbtest_wait_for_data_merge(); |
|
304 WB_END |
|
305 |
|
306 WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) |
300 WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) |
307 return MemTracker::tracking_level() == MemTracker::NMT_detail; |
301 return MemTracker::tracking_level() == NMT_detail; |
308 WB_END |
302 WB_END |
|
303 |
|
304 WB_ENTRY(void, WB_NMTOverflowHashBucket(JNIEnv* env, jobject o, jlong num)) |
|
305 address pc = (address)1; |
|
306 for (jlong index = 0; index < num; index ++) { |
|
307 NativeCallStack stack(&pc, 1); |
|
308 os::malloc(0, mtTest, stack); |
|
309 pc += MallocSiteTable::hash_buckets(); |
|
310 } |
|
311 WB_END |
|
312 |
309 |
313 |
310 #endif // INCLUDE_NMT |
314 #endif // INCLUDE_NMT |
311 |
315 |
312 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { |
316 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { |
313 assert(method != NULL, "method should not be null"); |
317 assert(method != NULL, "method should not be null"); |
855 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
859 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
856 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
860 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
857 #endif // INCLUDE_ALL_GCS |
861 #endif // INCLUDE_ALL_GCS |
858 #if INCLUDE_NMT |
862 #if INCLUDE_NMT |
859 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, |
863 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, |
|
864 {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack}, |
860 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, |
865 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, |
861 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, |
866 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, |
862 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, |
867 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, |
863 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, |
868 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, |
864 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, |
869 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, |
865 {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge}, |
870 {CC"NMTOverflowHashBucket", CC"(J)V", (void*)&WB_NMTOverflowHashBucket}, |
866 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, |
871 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, |
867 #endif // INCLUDE_NMT |
872 #endif // INCLUDE_NMT |
868 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, |
873 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, |
869 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", |
874 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", |
870 (void*)&WB_DeoptimizeMethod }, |
875 (void*)&WB_DeoptimizeMethod }, |