Mercurial > hg > truffle
comparison src/share/vm/prims/whitebox.cpp @ 14521:29ccc4cbabca
Merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 12 Mar 2014 13:30:08 +0100 |
parents | c66479743828 |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14520:f84115370178 | 14521:29ccc4cbabca |
---|---|
103 WB_END | 103 WB_END |
104 | 104 |
105 WB_ENTRY(void, WB_PrintHeapSizes(JNIEnv* env, jobject o)) { | 105 WB_ENTRY(void, WB_PrintHeapSizes(JNIEnv* env, jobject o)) { |
106 CollectorPolicy * p = Universe::heap()->collector_policy(); | 106 CollectorPolicy * p = Universe::heap()->collector_policy(); |
107 gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap " | 107 gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap " |
108 SIZE_FORMAT" Maximum heap "SIZE_FORMAT" Min alignment "SIZE_FORMAT" Max alignment "SIZE_FORMAT, | 108 SIZE_FORMAT" Maximum heap "SIZE_FORMAT" Space alignment "SIZE_FORMAT" Heap alignment "SIZE_FORMAT, |
109 p->min_heap_byte_size(), p->initial_heap_byte_size(), p->max_heap_byte_size(), | 109 p->min_heap_byte_size(), p->initial_heap_byte_size(), p->max_heap_byte_size(), |
110 p->space_alignment(), p->heap_alignment()); | 110 p->space_alignment(), p->heap_alignment()); |
111 } | 111 } |
112 WB_END | 112 WB_END |
113 | 113 |
314 VMThread::execute(&op); | 314 VMThread::execute(&op); |
315 WB_END | 315 WB_END |
316 | 316 |
317 WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) | 317 WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) |
318 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 318 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
319 int result = 0; | |
320 CHECK_JNI_EXCEPTION_(env, result); | |
319 MutexLockerEx mu(Compile_lock); | 321 MutexLockerEx mu(Compile_lock); |
320 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 322 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
321 int result = 0; | |
322 nmethod* code; | 323 nmethod* code; |
323 if (is_osr) { | 324 if (is_osr) { |
324 int bci = InvocationEntryBci; | 325 int bci = InvocationEntryBci; |
325 while ((code = mh->lookup_osr_nmethod_for(bci, CompLevel_none, false)) != NULL) { | 326 while ((code = mh->lookup_osr_nmethod_for(bci, CompLevel_none, false)) != NULL) { |
326 code->mark_for_deoptimization(); | 327 code->mark_for_deoptimization(); |
342 return result; | 343 return result; |
343 WB_END | 344 WB_END |
344 | 345 |
345 WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) | 346 WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) |
346 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 347 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
348 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); | |
347 MutexLockerEx mu(Compile_lock); | 349 MutexLockerEx mu(Compile_lock); |
348 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 350 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
349 nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); | 351 nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); |
350 if (code == NULL) { | 352 if (code == NULL) { |
351 return JNI_FALSE; | 353 return JNI_FALSE; |
353 return (code->is_alive() && !code->is_marked_for_deoptimization()); | 355 return (code->is_alive() && !code->is_marked_for_deoptimization()); |
354 WB_END | 356 WB_END |
355 | 357 |
356 WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) | 358 WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) |
357 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 359 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
360 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); | |
358 MutexLockerEx mu(Compile_lock); | 361 MutexLockerEx mu(Compile_lock); |
359 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 362 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
360 if (is_osr) { | 363 if (is_osr) { |
361 return CompilationPolicy::can_be_osr_compiled(mh, comp_level); | 364 return CompilationPolicy::can_be_osr_compiled(mh, comp_level); |
362 } else { | 365 } else { |
364 } | 367 } |
365 WB_END | 368 WB_END |
366 | 369 |
367 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method)) | 370 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method)) |
368 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 371 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
372 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); | |
369 MutexLockerEx mu(Compile_lock); | 373 MutexLockerEx mu(Compile_lock); |
370 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 374 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
371 return mh->queued_for_compilation(); | 375 return mh->queued_for_compilation(); |
372 WB_END | 376 WB_END |
373 | 377 |
374 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) | 378 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) |
375 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 379 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
380 CHECK_JNI_EXCEPTION_(env, CompLevel_none); | |
376 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 381 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
377 nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); | 382 nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); |
378 return (code != NULL ? code->comp_level() : CompLevel_none); | 383 return (code != NULL ? code->comp_level() : CompLevel_none); |
379 WB_END | 384 WB_END |
380 | 385 |
381 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) | 386 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) |
382 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 387 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
388 CHECK_JNI_EXCEPTION(env); | |
383 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 389 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
384 if (is_osr) { | 390 if (is_osr) { |
385 mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox"); | 391 mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox"); |
386 } else { | 392 } else { |
387 mh->set_not_compilable(comp_level, true /* report */, "WhiteBox"); | 393 mh->set_not_compilable(comp_level, true /* report */, "WhiteBox"); |
388 } | 394 } |
389 WB_END | 395 WB_END |
390 | 396 |
391 WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method)) | 397 WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method)) |
392 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 398 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
399 CHECK_JNI_EXCEPTION_(env, InvocationEntryBci); | |
393 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 400 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
394 nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); | 401 nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); |
395 return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); | 402 return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); |
396 WB_END | 403 WB_END |
397 | 404 |
398 WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) | 405 WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) |
399 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 406 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
407 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); | |
400 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 408 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
401 bool result = mh->dont_inline(); | 409 bool result = mh->dont_inline(); |
402 mh->set_dont_inline(value == JNI_TRUE); | 410 mh->set_dont_inline(value == JNI_TRUE); |
403 return result; | 411 return result; |
404 WB_END | 412 WB_END |
412 } | 420 } |
413 WB_END | 421 WB_END |
414 | 422 |
415 WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) | 423 WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) |
416 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 424 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
425 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); | |
417 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 426 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
418 bool result = mh->force_inline(); | 427 bool result = mh->force_inline(); |
419 mh->set_force_inline(value == JNI_TRUE); | 428 mh->set_force_inline(value == JNI_TRUE); |
420 return result; | 429 return result; |
421 WB_END | 430 WB_END |
422 | 431 |
423 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) | 432 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) |
424 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 433 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
434 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); | |
425 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 435 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
426 nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); | 436 nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); |
427 MutexLockerEx mu(Compile_lock); | 437 MutexLockerEx mu(Compile_lock); |
428 return (mh->queued_for_compilation() || nm != NULL); | 438 return (mh->queued_for_compilation() || nm != NULL); |
429 WB_END | 439 WB_END |
430 | 440 |
431 WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) | 441 WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) |
432 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | 442 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
443 CHECK_JNI_EXCEPTION(env); | |
433 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | 444 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
434 MutexLockerEx mu(Compile_lock); | 445 MutexLockerEx mu(Compile_lock); |
435 MethodData* mdo = mh->method_data(); | 446 MethodData* mdo = mh->method_data(); |
436 MethodCounters* mcs = mh->method_counters(); | 447 MethodCounters* mcs = mh->method_counters(); |
437 | 448 |
614 ResourceMark rm; | 625 ResourceMark rm; |
615 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI | 626 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI |
616 bool result = true; | 627 bool result = true; |
617 // one by one registration natives for exception catching | 628 // one by one registration natives for exception catching |
618 jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string()); | 629 jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string()); |
630 CHECK_JNI_EXCEPTION(env); | |
619 for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) { | 631 for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) { |
620 if (env->RegisterNatives(wbclass, methods + i, 1) != 0) { | 632 if (env->RegisterNatives(wbclass, methods + i, 1) != 0) { |
621 result = false; | 633 result = false; |
622 if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) { | 634 jthrowable throwable_obj = env->ExceptionOccurred(); |
623 // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native | 635 if (throwable_obj != NULL) { |
624 // ignoring the exception | |
625 tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); | |
626 env->ExceptionClear(); | 636 env->ExceptionClear(); |
637 if (env->IsInstanceOf(throwable_obj, exceptionKlass)) { | |
638 // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native | |
639 // ignoring the exception | |
640 tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); | |
641 } | |
627 } else { | 642 } else { |
628 // register is failed w/o exception or w/ unexpected exception | 643 // register is failed w/o exception or w/ unexpected exception |
629 tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature); | 644 tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature); |
630 env->UnregisterNatives(wbclass); | 645 env->UnregisterNatives(wbclass); |
631 break; | 646 break; |