Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/whitebox.cpp @ 7971:4102b59539ce
8005012: Add WB APIs to better support NMT testing
Summary: Add WB API functions to enable better NMT testing
Reviewed-by: dholmes, zgu
author | ctornqvi |
---|---|
date | Fri, 01 Feb 2013 23:48:08 +0100 |
parents | da91efe96a93 |
children | 3c9bc17b9403 |
comparison
equal
deleted
inserted
replaced
7962:4c75576d18d0 | 7971:4102b59539ce |
---|---|
40 #ifndef SERIALGC | 40 #ifndef SERIALGC |
41 #include "gc_implementation/g1/concurrentMark.hpp" | 41 #include "gc_implementation/g1/concurrentMark.hpp" |
42 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" | 42 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
43 #include "gc_implementation/g1/heapRegionRemSet.hpp" | 43 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
44 #endif // !SERIALGC | 44 #endif // !SERIALGC |
45 | |
46 #ifdef INCLUDE_NMT | |
47 #include "services/memTracker.hpp" | |
48 #endif // INCLUDE_NMT | |
45 | 49 |
46 bool WhiteBox::_used = false; | 50 bool WhiteBox::_used = false; |
47 | 51 |
48 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj)) | 52 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj)) |
49 return (jlong)(void*)JNIHandles::resolve(obj); | 53 return (jlong)(void*)JNIHandles::resolve(obj); |
107 | 111 |
108 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o)) | 112 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o)) |
109 return (jint)HeapRegion::GrainBytes; | 113 return (jint)HeapRegion::GrainBytes; |
110 WB_END | 114 WB_END |
111 #endif // !SERIALGC | 115 #endif // !SERIALGC |
116 | |
117 #ifdef INCLUDE_NMT | |
118 // Keep track of the 3 allocations in NMTAllocTest so we can free them later | |
119 // on and verify that they're not visible anymore | |
120 static void* nmtMtTest1 = NULL, *nmtMtTest2 = NULL, *nmtMtTest3 = NULL; | |
121 | |
122 // Alloc memory using the test memory type so that we can use that to see if | |
123 // NMT picks it up correctly | |
124 WB_ENTRY(jboolean, WB_NMTAllocTest(JNIEnv* env)) | |
125 void *mem; | |
126 | |
127 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { | |
128 return false; | |
129 } | |
130 | |
131 // Allocate 2 * 128k + 256k + 1024k and free the 1024k one to make sure we track | |
132 // everything correctly. Total should be 512k held alive. | |
133 nmtMtTest1 = os::malloc(128 * 1024, mtTest); | |
134 mem = os::malloc(1024 * 1024, mtTest); | |
135 nmtMtTest2 = os::malloc(256 * 1024, mtTest); | |
136 os::free(mem, mtTest); | |
137 nmtMtTest3 = os::malloc(128 * 1024, mtTest); | |
138 | |
139 return true; | |
140 WB_END | |
141 | |
142 // Free the memory allocated by NMTAllocTest | |
143 WB_ENTRY(jboolean, WB_NMTFreeTestMemory(JNIEnv* env)) | |
144 | |
145 if (nmtMtTest1 == NULL || nmtMtTest2 == NULL || nmtMtTest3 == NULL) { | |
146 return false; | |
147 } | |
148 | |
149 os::free(nmtMtTest1, mtTest); | |
150 nmtMtTest1 = NULL; | |
151 os::free(nmtMtTest2, mtTest); | |
152 nmtMtTest2 = NULL; | |
153 os::free(nmtMtTest3, mtTest); | |
154 nmtMtTest3 = NULL; | |
155 | |
156 return true; | |
157 WB_END | |
158 | |
159 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature | |
160 WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) | |
161 | |
162 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { | |
163 return false; | |
164 } | |
165 | |
166 return MemTracker::wbtest_wait_for_data_merge(); | |
167 WB_END | |
168 | |
169 #endif // INCLUDE_NMT | |
112 | 170 |
113 //Some convenience methods to deal with objects from java | 171 //Some convenience methods to deal with objects from java |
114 int WhiteBox::offset_for_field(const char* field_name, oop object, | 172 int WhiteBox::offset_for_field(const char* field_name, oop object, |
115 Symbol* signature_symbol) { | 173 Symbol* signature_symbol) { |
116 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); | 174 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); |
175 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, | 233 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, |
176 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, | 234 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, |
177 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, | 235 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
178 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, | 236 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
179 #endif // !SERIALGC | 237 #endif // !SERIALGC |
238 #ifdef INCLUDE_NMT | |
239 {CC"NMTAllocTest", CC"()Z", (void*)&WB_NMTAllocTest }, | |
240 {CC"NMTFreeTestMemory", CC"()Z", (void*)&WB_NMTFreeTestMemory }, | |
241 {CC"NMTWaitForDataMerge",CC"()Z", (void*)&WB_NMTWaitForDataMerge}, | |
242 #endif // INCLUDE_NMT | |
180 }; | 243 }; |
181 | 244 |
182 #undef CC | 245 #undef CC |
183 | 246 |
184 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) | 247 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) |