@@ -955,6 +955,72 @@ WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method
955
955
}
956
956
WB_END
957
957
958
+ WB_ENTRY (jint, WB_GetMethodDecompileCount(JNIEnv* env, jobject o, jobject method))
959
+ jmethodID jmid = reflected_method_to_jmid(thread, env, method);
960
+ CHECK_JNI_EXCEPTION_ (env, 0 );
961
+ methodHandle mh (THREAD, Method::checked_resolve_jmethod_id(jmid));
962
+ uint cnt = 0 ;
963
+ MethodData* mdo = mh->method_data ();
964
+ if (mdo != NULL ) {
965
+ cnt = mdo->decompile_count ();
966
+ }
967
+ return cnt;
968
+ WB_END
969
+
970
+ // Get the trap count of a method for a specific reason. If the trap count for
971
+ // that reason did overflow, this includes the overflow trap count of the method.
972
+ // If 'reason' is NULL, the sum of the traps for all reasons will be returned.
973
+ // This number includes the overflow trap count if the trap count for any reason
974
+ // did overflow.
975
+ WB_ENTRY (jint, WB_GetMethodTrapCount(JNIEnv* env, jobject o, jobject method, jstring reason_obj))
976
+ jmethodID jmid = reflected_method_to_jmid(thread, env, method);
977
+ CHECK_JNI_EXCEPTION_ (env, 0 );
978
+ methodHandle mh (THREAD, Method::checked_resolve_jmethod_id(jmid));
979
+ uint cnt = 0 ;
980
+ MethodData* mdo = mh->method_data ();
981
+ if (mdo != NULL ) {
982
+ ResourceMark rm (THREAD);
983
+ char * reason_str = (reason_obj == NULL ) ?
984
+ NULL : java_lang_String::as_utf8_string (JNIHandles::resolve_non_null (reason_obj));
985
+ bool overflow = false ;
986
+ for (uint reason = 0 ; reason < mdo->trap_reason_limit (); reason++) {
987
+ if (reason_str != NULL && !strcmp (reason_str, Deoptimization::trap_reason_name (reason))) {
988
+ cnt = mdo->trap_count (reason);
989
+ // Count in the overflow trap count on overflow
990
+ if (cnt == (uint )-1 ) {
991
+ cnt = mdo->trap_count_limit () + mdo->overflow_trap_count ();
992
+ }
993
+ break ;
994
+ } else if (reason_str == NULL ) {
995
+ uint c = mdo->trap_count (reason);
996
+ if (c == (uint )-1 ) {
997
+ c = mdo->trap_count_limit ();
998
+ if (!overflow) {
999
+ // Count overflow trap count just once
1000
+ overflow = true ;
1001
+ c += mdo->overflow_trap_count ();
1002
+ }
1003
+ }
1004
+ cnt += c;
1005
+ }
1006
+ }
1007
+ }
1008
+ return cnt;
1009
+ WB_END
1010
+
1011
+ WB_ENTRY (jint, WB_GetDeoptCount(JNIEnv* env, jobject o, jstring reason_obj, jstring action_obj))
1012
+ if (reason_obj == NULL && action_obj == NULL ) {
1013
+ return Deoptimization::total_deoptimization_count ();
1014
+ }
1015
+ ResourceMark rm (THREAD);
1016
+ const char *reason_str = (reason_obj == NULL ) ?
1017
+ NULL : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(reason_obj));
1018
+ const char *action_str = (action_obj == NULL ) ?
1019
+ NULL : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(action_obj));
1020
+
1021
+ return Deoptimization::deoptimization_count(reason_str, action_str);
1022
+ WB_END
1023
+
958
1024
WB_ENTRY (jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method))
959
1025
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
960
1026
CHECK_JNI_EXCEPTION_ (env, InvocationEntryBci);
@@ -2527,6 +2593,13 @@ static JNINativeMethod methods[] = {
2527
2593
CC" (Ljava/lang/reflect/Executable;Z)Z" , (void *)&WB_TestSetDontInlineMethod},
2528
2594
{CC" getMethodCompilationLevel0" ,
2529
2595
CC" (Ljava/lang/reflect/Executable;Z)I" , (void *)&WB_GetMethodCompilationLevel},
2596
+ {CC" getMethodDecompileCount0" ,
2597
+ CC" (Ljava/lang/reflect/Executable;)I" , (void *)&WB_GetMethodDecompileCount},
2598
+ {CC" getMethodTrapCount0" ,
2599
+ CC" (Ljava/lang/reflect/Executable;Ljava/lang/String;)I" ,
2600
+ (void *)&WB_GetMethodTrapCount},
2601
+ {CC" getDeoptCount0" ,
2602
+ CC" (Ljava/lang/String;Ljava/lang/String;)I" , (void *)&WB_GetDeoptCount},
2530
2603
{CC" getMethodEntryBci0" ,
2531
2604
CC" (Ljava/lang/reflect/Executable;)I" , (void *)&WB_GetMethodEntryBci},
2532
2605
{CC" getCompileQueueSize" ,
0 commit comments