< prev index next >

src/share/vm/prims/whitebox.cpp

Print this page
rev 8983 : 8222670: pathological case of JIT recompilation and code cache bloat
Summary: Prevent downgraded compilation tasks from recompiling.
Reviewed-by: thartmann, sgehwolf, phh, andrew
   1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 616   }
 617 
 618   mh->clear_not_c1_compilable();
 619   mh->clear_not_c2_compilable();
 620   mh->clear_not_c2_osr_compilable();
 621   NOT_PRODUCT(mh->set_compiled_invocation_count(0));
 622   if (mcs != NULL) {
 623     mcs->backedge_counter()->init();
 624     mcs->invocation_counter()->init();
 625     mcs->set_interpreter_invocation_count(0);
 626     mcs->set_interpreter_throwout_count(0);
 627 
 628 #ifdef TIERED
 629     mcs->set_rate(0.0F);
 630     mh->set_prev_event_count(0);
 631     mh->set_prev_time(0);
 632 #endif
 633   }
 634 WB_END
 635 



















 636 template <typename T>
 637 static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) {
 638   if (name == NULL) {
 639     return false;
 640   }
 641   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
 642   const char* flag_name = env->GetStringUTFChars(name, NULL);
 643   bool result = (*TAt)(flag_name, value);
 644   env->ReleaseStringUTFChars(name, flag_name);
 645   return result;
 646 }
 647 
 648 template <typename T>
 649 static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAtPut)(const char*, T*, Flag::Flags)) {
 650   if (name == NULL) {
 651     return false;
 652   }
 653   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
 654   const char* flag_name = env->GetStringUTFChars(name, NULL);
 655   bool result = (*TAtPut)(flag_name, value, Flag::INTERNAL);


1102   {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Executable;IZ)Z",
1103                                                       (void*)&WB_IsMethodCompilable},
1104   {CC"isMethodQueuedForCompilation",
1105       CC"(Ljava/lang/reflect/Executable;)Z",          (void*)&WB_IsMethodQueuedForCompilation},
1106   {CC"makeMethodNotCompilable",
1107       CC"(Ljava/lang/reflect/Executable;IZ)V",        (void*)&WB_MakeMethodNotCompilable},
1108   {CC"testSetDontInlineMethod",
1109       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetDontInlineMethod},
1110   {CC"getMethodCompilationLevel",
1111       CC"(Ljava/lang/reflect/Executable;Z)I",         (void*)&WB_GetMethodCompilationLevel},
1112   {CC"getMethodEntryBci",
1113       CC"(Ljava/lang/reflect/Executable;)I",          (void*)&WB_GetMethodEntryBci},
1114   {CC"getCompileQueueSize",
1115       CC"(I)I",                                       (void*)&WB_GetCompileQueueSize},
1116   {CC"testSetForceInlineMethod",
1117       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetForceInlineMethod},
1118   {CC"enqueueMethodForCompilation",
1119       CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
1120   {CC"clearMethodState",
1121       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},


1122   {CC"setBooleanVMFlag",   CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
1123   {CC"setIntxVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
1124   {CC"setUintxVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
1125   {CC"setUint64VMFlag",    CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
1126   {CC"setDoubleVMFlag",    CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag},
1127   {CC"setStringVMFlag",    CC"(Ljava/lang/String;Ljava/lang/String;)V",
1128                                                       (void*)&WB_SetStringVMFlag},
1129   {CC"getBooleanVMFlag",   CC"(Ljava/lang/String;)Ljava/lang/Boolean;",
1130                                                       (void*)&WB_GetBooleanVMFlag},
1131   {CC"getIntxVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1132                                                       (void*)&WB_GetIntxVMFlag},
1133   {CC"getUintxVMFlag",     CC"(Ljava/lang/String;)Ljava/lang/Long;",
1134                                                       (void*)&WB_GetUintxVMFlag},
1135   {CC"getUint64VMFlag",    CC"(Ljava/lang/String;)Ljava/lang/Long;",
1136                                                       (void*)&WB_GetUint64VMFlag},
1137   {CC"getDoubleVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/Double;",
1138                                                       (void*)&WB_GetDoubleVMFlag},
1139   {CC"getStringVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/String;",
1140                                                       (void*)&WB_GetStringVMFlag},
1141   {CC"isInStringTable",    CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable  },


   1 /*
   2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 616   }
 617 
 618   mh->clear_not_c1_compilable();
 619   mh->clear_not_c2_compilable();
 620   mh->clear_not_c2_osr_compilable();
 621   NOT_PRODUCT(mh->set_compiled_invocation_count(0));
 622   if (mcs != NULL) {
 623     mcs->backedge_counter()->init();
 624     mcs->invocation_counter()->init();
 625     mcs->set_interpreter_invocation_count(0);
 626     mcs->set_interpreter_throwout_count(0);
 627 
 628 #ifdef TIERED
 629     mcs->set_rate(0.0F);
 630     mh->set_prev_event_count(0);
 631     mh->set_prev_time(0);
 632 #endif
 633   }
 634 WB_END
 635 
 636 WB_ENTRY(void, WB_MarkMethodProfiled(JNIEnv* env, jobject o, jobject method))
 637   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
 638   CHECK_JNI_EXCEPTION(env);
 639   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
 640 
 641   MethodData* mdo = mh->method_data();
 642   if (mdo == NULL) {
 643     Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR);
 644     mdo = mh->method_data();
 645   }
 646   mdo->init();
 647   InvocationCounter* icnt = mdo->invocation_counter();
 648   InvocationCounter* bcnt = mdo->backedge_counter();
 649   // set i-counter according to AdvancedThresholdPolicy::is_method_profiled
 650   // because SimpleThresholdPolicy::call_predicate_helper uses > in jdk8u, that's why we need to plus one.
 651   icnt->set(InvocationCounter::wait_for_compile, Tier4MinInvocationThreshold + 1);
 652   bcnt->set(InvocationCounter::wait_for_compile, Tier4CompileThreshold + 1);
 653 WB_END
 654 
 655 template <typename T>
 656 static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) {
 657   if (name == NULL) {
 658     return false;
 659   }
 660   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
 661   const char* flag_name = env->GetStringUTFChars(name, NULL);
 662   bool result = (*TAt)(flag_name, value);
 663   env->ReleaseStringUTFChars(name, flag_name);
 664   return result;
 665 }
 666 
 667 template <typename T>
 668 static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAtPut)(const char*, T*, Flag::Flags)) {
 669   if (name == NULL) {
 670     return false;
 671   }
 672   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
 673   const char* flag_name = env->GetStringUTFChars(name, NULL);
 674   bool result = (*TAtPut)(flag_name, value, Flag::INTERNAL);


1121   {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Executable;IZ)Z",
1122                                                       (void*)&WB_IsMethodCompilable},
1123   {CC"isMethodQueuedForCompilation",
1124       CC"(Ljava/lang/reflect/Executable;)Z",          (void*)&WB_IsMethodQueuedForCompilation},
1125   {CC"makeMethodNotCompilable",
1126       CC"(Ljava/lang/reflect/Executable;IZ)V",        (void*)&WB_MakeMethodNotCompilable},
1127   {CC"testSetDontInlineMethod",
1128       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetDontInlineMethod},
1129   {CC"getMethodCompilationLevel",
1130       CC"(Ljava/lang/reflect/Executable;Z)I",         (void*)&WB_GetMethodCompilationLevel},
1131   {CC"getMethodEntryBci",
1132       CC"(Ljava/lang/reflect/Executable;)I",          (void*)&WB_GetMethodEntryBci},
1133   {CC"getCompileQueueSize",
1134       CC"(I)I",                                       (void*)&WB_GetCompileQueueSize},
1135   {CC"testSetForceInlineMethod",
1136       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetForceInlineMethod},
1137   {CC"enqueueMethodForCompilation",
1138       CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
1139   {CC"clearMethodState",
1140       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},
1141   {CC"markMethodProfiled",
1142       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_MarkMethodProfiled},
1143   {CC"setBooleanVMFlag",   CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
1144   {CC"setIntxVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
1145   {CC"setUintxVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
1146   {CC"setUint64VMFlag",    CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
1147   {CC"setDoubleVMFlag",    CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag},
1148   {CC"setStringVMFlag",    CC"(Ljava/lang/String;Ljava/lang/String;)V",
1149                                                       (void*)&WB_SetStringVMFlag},
1150   {CC"getBooleanVMFlag",   CC"(Ljava/lang/String;)Ljava/lang/Boolean;",
1151                                                       (void*)&WB_GetBooleanVMFlag},
1152   {CC"getIntxVMFlag",      CC"(Ljava/lang/String;)Ljava/lang/Long;",
1153                                                       (void*)&WB_GetIntxVMFlag},
1154   {CC"getUintxVMFlag",     CC"(Ljava/lang/String;)Ljava/lang/Long;",
1155                                                       (void*)&WB_GetUintxVMFlag},
1156   {CC"getUint64VMFlag",    CC"(Ljava/lang/String;)Ljava/lang/Long;",
1157                                                       (void*)&WB_GetUint64VMFlag},
1158   {CC"getDoubleVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/Double;",
1159                                                       (void*)&WB_GetDoubleVMFlag},
1160   {CC"getStringVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/String;",
1161                                                       (void*)&WB_GetStringVMFlag},
1162   {CC"isInStringTable",    CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable  },


< prev index next >