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 9032 : 8137167: JEP165: Compiler Control: Implementation task
Summary: Compiler Control JEP
Reviewed-by: roland, twisti


 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* directive;
 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     directive = DirectivesStack::getMatchingDirective(cch, CompileBroker::compiler((int)compLevel));
 563   } else {
 564     // Calling with NULL matches default directive
 565     directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler((int)compLevel));
 566   }
 567   bool result = CompileBroker::compiler(compLevel)->is_intrinsic_available(mh, directive);
 568   DirectivesStack::release(directive);
 569   return result;
 570 WB_END
 571 
 572 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
 573   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 574   CHECK_JNI_EXCEPTION_(env, CompLevel_none);
 575   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 576   nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
 577   return (code != NULL ? code->comp_level() : CompLevel_none);
 578 WB_END
 579 
 580 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
 581   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 582   CHECK_JNI_EXCEPTION(env);
 583   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 584   if (is_osr) {
 585     mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox");
 586   } else {
 587     mh->set_not_compilable(comp_level, true /* report */, "WhiteBox");
 588   }
 589 WB_END


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


1490       CC"(Ljava/lang/reflect/Executable;IZ)V",        (void*)&WB_MakeMethodNotCompilable},
1491   {CC"testSetDontInlineMethod0",
1492       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetDontInlineMethod},
1493   {CC"getMethodCompilationLevel0",
1494       CC"(Ljava/lang/reflect/Executable;Z)I",         (void*)&WB_GetMethodCompilationLevel},
1495   {CC"getMethodEntryBci0",
1496       CC"(Ljava/lang/reflect/Executable;)I",          (void*)&WB_GetMethodEntryBci},
1497   {CC"getCompileQueueSize",
1498       CC"(I)I",                                       (void*)&WB_GetCompileQueueSize},
1499   {CC"testSetForceInlineMethod0",
1500       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetForceInlineMethod},
1501   {CC"enqueueMethodForCompilation0",
1502       CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
1503   {CC"clearMethodState0",
1504       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},
1505   {CC"lockCompilation",    CC"()V",                   (void*)&WB_LockCompilation},
1506   {CC"unlockCompilation",  CC"()V",                   (void*)&WB_UnlockCompilation},
1507   {CC"matchesMethod",
1508       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
1509                                                       (void*)&WB_MatchesMethod},
1510   {CC"matchesInline",
1511       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
1512                                                       (void*)&WB_MatchesInline},
1513   {CC"shouldPrintAssembly",
1514         CC"(Ljava/lang/reflect/Executable;)Z",
1515                                                         (void*)&WB_ShouldPrintAssembly},
1516 
1517   {CC"isConstantVMFlag",   CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},
1518   {CC"isLockedVMFlag",     CC"(Ljava/lang/String;)Z", (void*)&WB_IsLockedVMFlag},
1519   {CC"setBooleanVMFlag",   CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
1520   {CC"setIntVMFlag",       CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntVMFlag},
1521   {CC"setUintVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintVMFlag},
1522   {CC"setIntxVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
1523   {CC"setUintxVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
1524   {CC"setUint64VMFlag",    CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
1525   {CC"setSizeTVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetSizeTVMFlag},
1526   {CC"setDoubleVMFlag",    CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag},
1527   {CC"setStringVMFlag",    CC"(Ljava/lang/String;Ljava/lang/String;)V",
1528                                                       (void*)&WB_SetStringVMFlag},
1529   {CC"getBooleanVMFlag",   CC"(Ljava/lang/String;)Ljava/lang/Boolean;",
1530                                                       (void*)&WB_GetBooleanVMFlag},
1531   {CC"getIntVMFlag",       CC"(Ljava/lang/String;)Ljava/lang/Long;",
1532                                                       (void*)&WB_GetIntVMFlag},
1533   {CC"getUintVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1534                                                       (void*)&WB_GetUintVMFlag},
1535   {CC"getIntxVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1536                                                       (void*)&WB_GetIntxVMFlag},


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