comparison src/share/vm/prims/whitebox.cpp @ 9056:3b890cd4da64

8009125: Add NMT tests for Virtual Memory operations Summary: Tests added for Reserve/Commit/Uncommit/Unreserve operations Reviewed-by: zgu, mgerdin
author ctornqvi
date Wed, 03 Apr 2013 21:41:33 +0200
parents ede380e13960
children 7a5aec879506
comparison
equal deleted inserted replaced
8852:a4e8dac9db8c 9056:3b890cd4da64
116 return (jint)HeapRegion::GrainBytes; 116 return (jint)HeapRegion::GrainBytes;
117 WB_END 117 WB_END
118 #endif // INCLUDE_ALL_GCS 118 #endif // INCLUDE_ALL_GCS
119 119
120 #ifdef INCLUDE_NMT 120 #ifdef INCLUDE_NMT
121 // Keep track of the 3 allocations in NMTAllocTest so we can free them later
122 // on and verify that they're not visible anymore
123 static void* nmtMtTest1 = NULL, *nmtMtTest2 = NULL, *nmtMtTest3 = NULL;
124
125 // Alloc memory using the test memory type so that we can use that to see if 121 // Alloc memory using the test memory type so that we can use that to see if
126 // NMT picks it up correctly 122 // NMT picks it up correctly
127 WB_ENTRY(jboolean, WB_NMTAllocTest(JNIEnv* env)) 123 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
128 void *mem; 124 jlong addr = 0;
129 125
130 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { 126 if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) {
131 return false; 127 addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
132 } 128 }
133 129
134 // Allocate 2 * 128k + 256k + 1024k and free the 1024k one to make sure we track 130 return addr;
135 // everything correctly. Total should be 512k held alive.
136 nmtMtTest1 = os::malloc(128 * 1024, mtTest);
137 mem = os::malloc(1024 * 1024, mtTest);
138 nmtMtTest2 = os::malloc(256 * 1024, mtTest);
139 os::free(mem, mtTest);
140 nmtMtTest3 = os::malloc(128 * 1024, mtTest);
141
142 return true;
143 WB_END 131 WB_END
144 132
145 // Free the memory allocated by NMTAllocTest 133 // Free the memory allocated by NMTAllocTest
146 WB_ENTRY(jboolean, WB_NMTFreeTestMemory(JNIEnv* env)) 134 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem))
147 135 os::free((void*)(uintptr_t)mem, mtTest);
148 if (nmtMtTest1 == NULL || nmtMtTest2 == NULL || nmtMtTest3 == NULL) { 136 WB_END
149 return false; 137
150 } 138 WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size))
151 139 jlong addr = 0;
152 os::free(nmtMtTest1, mtTest); 140
153 nmtMtTest1 = NULL; 141 if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) {
154 os::free(nmtMtTest2, mtTest); 142 addr = (jlong)(uintptr_t)os::reserve_memory(size);
155 nmtMtTest2 = NULL; 143 MemTracker::record_virtual_memory_type((address)addr, mtTest);
156 os::free(nmtMtTest3, mtTest); 144 }
157 nmtMtTest3 = NULL; 145
158 146 return addr;
159 return true; 147 WB_END
148
149
150 WB_ENTRY(void, WB_NMTCommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size))
151 os::commit_memory((char *)(uintptr_t)addr, size);
152 MemTracker::record_virtual_memory_type((address)(uintptr_t)addr, mtTest);
153 WB_END
154
155 WB_ENTRY(void, WB_NMTUncommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size))
156 os::uncommit_memory((char *)(uintptr_t)addr, size);
157 WB_END
158
159 WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size))
160 os::release_memory((char *)(uintptr_t)addr, size);
160 WB_END 161 WB_END
161 162
162 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature 163 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature
163 WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) 164 WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env))
164 165
338 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, 339 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
339 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, 340 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
340 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, 341 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
341 #endif // INCLUDE_ALL_GCS 342 #endif // INCLUDE_ALL_GCS
342 #ifdef INCLUDE_NMT 343 #ifdef INCLUDE_NMT
343 {CC"NMTAllocTest", CC"()Z", (void*)&WB_NMTAllocTest }, 344 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
344 {CC"NMTFreeTestMemory", CC"()Z", (void*)&WB_NMTFreeTestMemory }, 345 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree },
345 {CC"NMTWaitForDataMerge",CC"()Z", (void*)&WB_NMTWaitForDataMerge}, 346 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory },
347 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory },
348 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory },
349 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory },
350 {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge},
346 #endif // INCLUDE_NMT 351 #endif // INCLUDE_NMT
347 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, 352 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
348 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Method;)I", 353 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Method;)I",
349 (void*)&WB_DeoptimizeMethod }, 354 (void*)&WB_DeoptimizeMethod },
350 {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Method;)Z", 355 {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Method;)Z",