src/share/vm/prims/whitebox.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/prims

src/share/vm/prims/whitebox.cpp

Print this page
rev 8995 : 8046155: JEP165: Compiler Control
Summary:
Reviewed-by:


 536     return CompilationPolicy::can_be_compiled(mh, comp_level);
 537   }
 538 WB_END
 539 
 540 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
 541   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 542   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 543   MutexLockerEx mu(Compile_lock);
 544   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 545   return mh->queued_for_compilation();
 546 WB_END
 547 
 548 WB_ENTRY(jboolean, WB_IsIntrinsicAvailable(JNIEnv* env, jobject o, jobject method, jobject compilation_context, jint compLevel))
 549   if (compLevel < CompLevel_none || compLevel > CompLevel_highest_tier) {
 550     return false; // Intrinsic is not available on a non-existent compilation level.
 551   }
 552   jmethodID method_id, compilation_context_id;
 553   method_id = reflected_method_to_jmid(thread, env, method);
 554   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 555   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(method_id));


 556   if (compilation_context != NULL) {
 557     compilation_context_id = reflected_method_to_jmid(thread, env, compilation_context);
 558     CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 559     methodHandle cch(THREAD, Method::checked_resolve_jmethod_id(compilation_context_id));
 560     return CompileBroker::compiler(compLevel)->is_intrinsic_available(mh, cch);
 561   } else {
 562     return CompileBroker::compiler(compLevel)->is_intrinsic_available(mh, NULL);

 563   }

 564 WB_END
 565 
 566 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
 567   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 568   CHECK_JNI_EXCEPTION_(env, CompLevel_none);
 569   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 570   nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
 571   return (code != NULL ? code->comp_level() : CompLevel_none);
 572 WB_END
 573 
 574 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
 575   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 576   CHECK_JNI_EXCEPTION(env);
 577   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 578   if (is_osr) {
 579     mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox");
 580   } else {
 581     mh->set_not_compilable(comp_level, true /* report */, "WhiteBox");
 582   }
 583 WB_END


 609 WB_END
 610 
 611 WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
 612   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 613   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 614   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 615   bool result = mh->force_inline();
 616   mh->set_force_inline(value == JNI_TRUE);
 617   return result;
 618 WB_END
 619 
 620 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
 621   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 622   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 623   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 624   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
 625   MutexLockerEx mu(Compile_lock);
 626   return (mh->queued_for_compilation() || nm != NULL);
 627 WB_END
 628 






























 629 
 630 WB_ENTRY(jint, WB_MatchesMethod(JNIEnv* env, jobject o, jobject method, jstring pattern))
 631   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 632   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 633 
 634   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 635 
 636   ResourceMark rm;
 637   char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern));
 638 
 639   const char* error_msg = NULL;
 640 
 641   BasicMatcher* m = BasicMatcher::parse_method_pattern(method_str, error_msg);
 642   if (m == NULL) {
 643     assert(error_msg != NULL, "Must have error_msg");
 644     tty->print_cr("Got error: %s", error_msg);
 645     return -1;
 646   }
 647 
 648   // Pattern works - now check if it matches


1443       CC"(Ljava/lang/reflect/Executable;IZ)V",        (void*)&WB_MakeMethodNotCompilable},
1444   {CC"testSetDontInlineMethod0",
1445       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetDontInlineMethod},
1446   {CC"getMethodCompilationLevel0",
1447       CC"(Ljava/lang/reflect/Executable;Z)I",         (void*)&WB_GetMethodCompilationLevel},
1448   {CC"getMethodEntryBci0",
1449       CC"(Ljava/lang/reflect/Executable;)I",          (void*)&WB_GetMethodEntryBci},
1450   {CC"getCompileQueueSize",
1451       CC"(I)I",                                       (void*)&WB_GetCompileQueueSize},
1452   {CC"testSetForceInlineMethod0",
1453       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetForceInlineMethod},
1454   {CC"enqueueMethodForCompilation0",
1455       CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
1456   {CC"clearMethodState0",
1457       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},
1458   {CC"lockCompilation",    CC"()V",                   (void*)&WB_LockCompilation},
1459   {CC"unlockCompilation",  CC"()V",                   (void*)&WB_UnlockCompilation},
1460   {CC"matchesMethod",
1461       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
1462                                                       (void*)&WB_MatchesMethod},



1463   {CC"isConstantVMFlag",   CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},
1464   {CC"isLockedVMFlag",     CC"(Ljava/lang/String;)Z", (void*)&WB_IsLockedVMFlag},
1465   {CC"setBooleanVMFlag",   CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
1466   {CC"setIntVMFlag",       CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntVMFlag},
1467   {CC"setUintVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintVMFlag},
1468   {CC"setIntxVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
1469   {CC"setUintxVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
1470   {CC"setUint64VMFlag",    CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
1471   {CC"setSizeTVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetSizeTVMFlag},
1472   {CC"setDoubleVMFlag",    CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag},
1473   {CC"setStringVMFlag",    CC"(Ljava/lang/String;Ljava/lang/String;)V",
1474                                                       (void*)&WB_SetStringVMFlag},
1475   {CC"getBooleanVMFlag",   CC"(Ljava/lang/String;)Ljava/lang/Boolean;",
1476                                                       (void*)&WB_GetBooleanVMFlag},
1477   {CC"getIntVMFlag",       CC"(Ljava/lang/String;)Ljava/lang/Long;",
1478                                                       (void*)&WB_GetIntVMFlag},
1479   {CC"getUintVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1480                                                       (void*)&WB_GetUintVMFlag},
1481   {CC"getIntxVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1482                                                       (void*)&WB_GetIntxVMFlag},




 536     return CompilationPolicy::can_be_compiled(mh, comp_level);
 537   }
 538 WB_END
 539 
 540 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
 541   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 542   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 543   MutexLockerEx mu(Compile_lock);
 544   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 545   return mh->queued_for_compilation();
 546 WB_END
 547 
 548 WB_ENTRY(jboolean, WB_IsIntrinsicAvailable(JNIEnv* env, jobject o, jobject method, jobject compilation_context, jint compLevel))
 549   if (compLevel < CompLevel_none || compLevel > CompLevel_highest_tier) {
 550     return false; // Intrinsic is not available on a non-existent compilation level.
 551   }
 552   jmethodID method_id, compilation_context_id;
 553   method_id = reflected_method_to_jmid(thread, env, method);
 554   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 555   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(method_id));
 556 
 557   DirectiveSet* dirset;
 558   if (compilation_context != NULL) {
 559     compilation_context_id = reflected_method_to_jmid(thread, env, compilation_context);
 560     CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 561     methodHandle cch(THREAD, Method::checked_resolve_jmethod_id(compilation_context_id));
 562     dirset = CompileBroker::dirstack()->getMatchingDirective(cch, (int)compLevel);
 563   } else {
 564     // Calling with NULL matches default directive
 565     dirset = CompileBroker::dirstack()->getMatchingDirective(NULL, (int)compLevel);
 566   }
 567   return CompileBroker::compiler(compLevel)->is_intrinsic_available(mh, dirset);
 568 WB_END
 569 
 570 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
 571   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 572   CHECK_JNI_EXCEPTION_(env, CompLevel_none);
 573   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 574   nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
 575   return (code != NULL ? code->comp_level() : CompLevel_none);
 576 WB_END
 577 
 578 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
 579   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 580   CHECK_JNI_EXCEPTION(env);
 581   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 582   if (is_osr) {
 583     mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox");
 584   } else {
 585     mh->set_not_compilable(comp_level, true /* report */, "WhiteBox");
 586   }
 587 WB_END


 613 WB_END
 614 
 615 WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
 616   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 617   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 618   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 619   bool result = mh->force_inline();
 620   mh->set_force_inline(value == JNI_TRUE);
 621   return result;
 622 WB_END
 623 
 624 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
 625   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 626   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 627   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 628   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
 629   MutexLockerEx mu(Compile_lock);
 630   return (mh->queued_for_compilation() || nm != NULL);
 631 WB_END
 632 
 633 WB_ENTRY(jint, WB_MatchesInline(JNIEnv* env, jobject o, jobject method, jstring pattern))
 634   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 635   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 636 
 637   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 638 
 639   ResourceMark rm;
 640   const char* error_msg = NULL;
 641   char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern));
 642   InlineMatcher* m = InlineMatcher::parse_inline_pattern(method_str, error_msg);
 643 
 644   if (m == NULL) {
 645     assert(error_msg != NULL, "Always have an error message");
 646     tty->print_cr("Got error: %s", error_msg);
 647     return -1; // Pattern failed
 648   }
 649 
 650   // Pattern works - now check if it matches
 651   int result;
 652   if (m->match(mh, InlineMatcher::force_inline)) {
 653     result = 2; // Force inline match
 654   } else if (m->match(mh, InlineMatcher::dont_inline)) {
 655     result = 1; // Dont inline match
 656   } else {
 657     result = 0; // No match
 658   }
 659   delete m;
 660   return result;
 661 WB_END
 662 
 663 
 664 WB_ENTRY(jint, WB_MatchesMethod(JNIEnv* env, jobject o, jobject method, jstring pattern))
 665   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 666   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 667 
 668   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 669 
 670   ResourceMark rm;
 671   char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern));
 672 
 673   const char* error_msg = NULL;
 674 
 675   BasicMatcher* m = BasicMatcher::parse_method_pattern(method_str, error_msg);
 676   if (m == NULL) {
 677     assert(error_msg != NULL, "Must have error_msg");
 678     tty->print_cr("Got error: %s", error_msg);
 679     return -1;
 680   }
 681 
 682   // Pattern works - now check if it matches


1477       CC"(Ljava/lang/reflect/Executable;IZ)V",        (void*)&WB_MakeMethodNotCompilable},
1478   {CC"testSetDontInlineMethod0",
1479       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetDontInlineMethod},
1480   {CC"getMethodCompilationLevel0",
1481       CC"(Ljava/lang/reflect/Executable;Z)I",         (void*)&WB_GetMethodCompilationLevel},
1482   {CC"getMethodEntryBci0",
1483       CC"(Ljava/lang/reflect/Executable;)I",          (void*)&WB_GetMethodEntryBci},
1484   {CC"getCompileQueueSize",
1485       CC"(I)I",                                       (void*)&WB_GetCompileQueueSize},
1486   {CC"testSetForceInlineMethod0",
1487       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetForceInlineMethod},
1488   {CC"enqueueMethodForCompilation0",
1489       CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
1490   {CC"clearMethodState0",
1491       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},
1492   {CC"lockCompilation",    CC"()V",                   (void*)&WB_LockCompilation},
1493   {CC"unlockCompilation",  CC"()V",                   (void*)&WB_UnlockCompilation},
1494   {CC"matchesMethod",
1495       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
1496                                                       (void*)&WB_MatchesMethod},
1497   {CC"matchesInline",
1498       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
1499                                                       (void*)&WB_MatchesInline},
1500   {CC"isConstantVMFlag",   CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},
1501   {CC"isLockedVMFlag",     CC"(Ljava/lang/String;)Z", (void*)&WB_IsLockedVMFlag},
1502   {CC"setBooleanVMFlag",   CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
1503   {CC"setIntVMFlag",       CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntVMFlag},
1504   {CC"setUintVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintVMFlag},
1505   {CC"setIntxVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
1506   {CC"setUintxVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
1507   {CC"setUint64VMFlag",    CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
1508   {CC"setSizeTVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetSizeTVMFlag},
1509   {CC"setDoubleVMFlag",    CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag},
1510   {CC"setStringVMFlag",    CC"(Ljava/lang/String;Ljava/lang/String;)V",
1511                                                       (void*)&WB_SetStringVMFlag},
1512   {CC"getBooleanVMFlag",   CC"(Ljava/lang/String;)Ljava/lang/Boolean;",
1513                                                       (void*)&WB_GetBooleanVMFlag},
1514   {CC"getIntVMFlag",       CC"(Ljava/lang/String;)Ljava/lang/Long;",
1515                                                       (void*)&WB_GetIntVMFlag},
1516   {CC"getUintVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1517                                                       (void*)&WB_GetUintVMFlag},
1518   {CC"getIntxVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1519                                                       (void*)&WB_GetIntxVMFlag},


src/share/vm/prims/whitebox.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File