Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/whitebox.cpp @ 8051:12e01444ca2d
8006683: Add WhiteBox API to testing of compiler
Reviewed-by: kvn, vlivanov
author | iignatyev |
---|---|
date | Wed, 13 Feb 2013 08:29:04 -0800 |
parents | 3c9bc17b9403 |
children | ede380e13960 |
comparison
equal
deleted
inserted
replaced
8050:aaad39923cdb | 8051:12e01444ca2d |
---|---|
45 #endif // INCLUDE_ALL_GCS | 45 #endif // INCLUDE_ALL_GCS |
46 | 46 |
47 #ifdef INCLUDE_NMT | 47 #ifdef INCLUDE_NMT |
48 #include "services/memTracker.hpp" | 48 #include "services/memTracker.hpp" |
49 #endif // INCLUDE_NMT | 49 #endif // INCLUDE_NMT |
50 | |
51 #include "compiler/compileBroker.hpp" | |
50 | 52 |
51 bool WhiteBox::_used = false; | 53 bool WhiteBox::_used = false; |
52 | 54 |
53 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj)) | 55 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj)) |
54 return (jlong)(void*)JNIHandles::resolve(obj); | 56 return (jlong)(void*)JNIHandles::resolve(obj); |
167 return MemTracker::wbtest_wait_for_data_merge(); | 169 return MemTracker::wbtest_wait_for_data_merge(); |
168 WB_END | 170 WB_END |
169 | 171 |
170 #endif // INCLUDE_NMT | 172 #endif // INCLUDE_NMT |
171 | 173 |
174 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { | |
175 assert(method != NULL, "method should not be null"); | |
176 ThreadToNativeFromVM ttn(thread); | |
177 return env->FromReflectedMethod(method); | |
178 } | |
179 | |
180 WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o)) | |
181 MutexLockerEx mu(Compile_lock); | |
182 CodeCache::mark_all_nmethods_for_deoptimization(); | |
183 VM_Deoptimize op; | |
184 VMThread::execute(&op); | |
185 WB_END | |
186 | |
187 WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method)) | |
188 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
189 MutexLockerEx mu(Compile_lock); | |
190 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
191 int result = 0; | |
192 nmethod* code = mh->code(); | |
193 if (code != NULL) { | |
194 code->mark_for_deoptimization(); | |
195 ++result; | |
196 } | |
197 result += CodeCache::mark_for_deoptimization(mh()); | |
198 if (result > 0) { | |
199 VM_Deoptimize op; | |
200 VMThread::execute(&op); | |
201 } | |
202 return result; | |
203 WB_END | |
204 | |
205 WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method)) | |
206 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
207 MutexLockerEx mu(Compile_lock); | |
208 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
209 nmethod* code = mh->code(); | |
210 if (code == NULL) { | |
211 return JNI_FALSE; | |
212 } | |
213 return (code->is_alive() && !code->is_marked_for_deoptimization()); | |
214 WB_END | |
215 | |
216 WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method)) | |
217 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
218 MutexLockerEx mu(Compile_lock); | |
219 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
220 return !mh->is_not_compilable(); | |
221 WB_END | |
222 | |
223 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method)) | |
224 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
225 MutexLockerEx mu(Compile_lock); | |
226 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
227 return mh->queued_for_compilation(); | |
228 WB_END | |
229 | |
230 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method)) | |
231 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
232 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
233 nmethod* code = mh->code(); | |
234 return (code != NULL ? code->comp_level() : CompLevel_none); | |
235 WB_END | |
236 | |
237 | |
238 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method)) | |
239 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
240 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
241 mh->set_not_compilable(); | |
242 WB_END | |
243 | |
244 WB_ENTRY(jboolean, WB_SetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) | |
245 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
246 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
247 bool result = mh->dont_inline(); | |
248 mh->set_dont_inline(value == JNI_TRUE); | |
249 return result; | |
250 WB_END | |
251 | |
252 WB_ENTRY(jint, WB_GetCompileQueuesSize(JNIEnv* env, jobject o)) | |
253 return CompileBroker::queue_size(CompLevel_full_optimization) /* C2 */ + | |
254 CompileBroker::queue_size(CompLevel_full_profile) /* C1 */; | |
255 WB_END | |
256 | |
172 //Some convenience methods to deal with objects from java | 257 //Some convenience methods to deal with objects from java |
173 int WhiteBox::offset_for_field(const char* field_name, oop object, | 258 int WhiteBox::offset_for_field(const char* field_name, oop object, |
174 Symbol* signature_symbol) { | 259 Symbol* signature_symbol) { |
175 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); | 260 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); |
176 Thread* THREAD = Thread::current(); | 261 Thread* THREAD = Thread::current(); |
223 #define CC (char*) | 308 #define CC (char*) |
224 | 309 |
225 static JNINativeMethod methods[] = { | 310 static JNINativeMethod methods[] = { |
226 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, | 311 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, |
227 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, | 312 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
228 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, | 313 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, |
229 {CC "parseCommandLine", | 314 {CC"parseCommandLine", |
230 CC "(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", | 315 CC"(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", |
231 (void*) &WB_ParseCommandLine | 316 (void*) &WB_ParseCommandLine |
232 }, | 317 }, |
233 #if INCLUDE_ALL_GCS | 318 #if INCLUDE_ALL_GCS |
234 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, | 319 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, |
235 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, | 320 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, |
239 #ifdef INCLUDE_NMT | 324 #ifdef INCLUDE_NMT |
240 {CC"NMTAllocTest", CC"()Z", (void*)&WB_NMTAllocTest }, | 325 {CC"NMTAllocTest", CC"()Z", (void*)&WB_NMTAllocTest }, |
241 {CC"NMTFreeTestMemory", CC"()Z", (void*)&WB_NMTFreeTestMemory }, | 326 {CC"NMTFreeTestMemory", CC"()Z", (void*)&WB_NMTFreeTestMemory }, |
242 {CC"NMTWaitForDataMerge",CC"()Z", (void*)&WB_NMTWaitForDataMerge}, | 327 {CC"NMTWaitForDataMerge",CC"()Z", (void*)&WB_NMTWaitForDataMerge}, |
243 #endif // INCLUDE_NMT | 328 #endif // INCLUDE_NMT |
329 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, | |
330 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Method;)I", | |
331 (void*)&WB_DeoptimizeMethod }, | |
332 {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Method;)Z", | |
333 (void*)&WB_IsMethodCompiled }, | |
334 {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Method;)Z", | |
335 (void*)&WB_IsMethodCompilable}, | |
336 {CC"isMethodQueuedForCompilation", | |
337 CC"(Ljava/lang/reflect/Method;)Z", (void*)&WB_IsMethodQueuedForCompilation}, | |
338 {CC"makeMethodNotCompilable", | |
339 CC"(Ljava/lang/reflect/Method;)V", (void*)&WB_MakeMethodNotCompilable}, | |
340 {CC"setDontInlineMethod", | |
341 CC"(Ljava/lang/reflect/Method;Z)Z", (void*)&WB_SetDontInlineMethod}, | |
342 {CC"getMethodCompilationLevel", | |
343 CC"(Ljava/lang/reflect/Method;)I", (void*)&WB_GetMethodCompilationLevel}, | |
344 {CC"getCompileQueuesSize", | |
345 CC"()I", (void*)&WB_GetCompileQueuesSize}, | |
244 }; | 346 }; |
245 | 347 |
246 #undef CC | 348 #undef CC |
247 | 349 |
248 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) | 350 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) |