859 if (inc > max_size_t) {
860 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
861 err_msg("WB_IncMetaspaceCapacityUntilGC: inc does not fit in size_t: " JLONG_FORMAT, inc));
862 }
863
864 size_t new_cap_until_GC = 0;
865 size_t aligned_inc = align_size_down((size_t) inc, Metaspace::commit_alignment());
866 bool success = MetaspaceGC::inc_capacity_until_GC(aligned_inc, &new_cap_until_GC);
867 if (!success) {
868 THROW_MSG_0(vmSymbols::java_lang_IllegalStateException(),
869 "WB_IncMetaspaceCapacityUntilGC: could not increase capacity until GC "
870 "due to contention with another thread");
871 }
872 return (jlong) new_cap_until_GC;
873 WB_END
874
875 WB_ENTRY(jlong, WB_MetaspaceCapacityUntilGC(JNIEnv* env, jobject wb))
876 return (jlong) MetaspaceGC::capacity_until_GC();
877 WB_END
878
879 //Some convenience methods to deal with objects from java
880 int WhiteBox::offset_for_field(const char* field_name, oop object,
881 Symbol* signature_symbol) {
882 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
883 Thread* THREAD = Thread::current();
884
885 //Get the class of our object
886 Klass* arg_klass = object->klass();
887 //Turn it into an instance-klass
888 InstanceKlass* ik = InstanceKlass::cast(arg_klass);
889
890 //Create symbols to look for in the class
891 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
892 THREAD);
893
894 //To be filled in with an offset of the field we're looking for
895 fieldDescriptor fd;
896
897 Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
898 if (res == NULL) {
1038 (void*)&WB_GetSizeTVMFlag},
1039 {CC"getDoubleVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Double;",
1040 (void*)&WB_GetDoubleVMFlag},
1041 {CC"getStringVMFlag", CC"(Ljava/lang/String;)Ljava/lang/String;",
1042 (void*)&WB_GetStringVMFlag},
1043 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable },
1044 {CC"fullGC", CC"()V", (void*)&WB_FullGC },
1045 {CC"youngGC", CC"()V", (void*)&WB_YoungGC },
1046 {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory },
1047 {CC"allocateMetaspace",
1048 CC"(Ljava/lang/ClassLoader;J)J", (void*)&WB_AllocateMetaspace },
1049 {CC"freeMetaspace",
1050 CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace },
1051 {CC"incMetaspaceCapacityUntilGC", CC"(J)J", (void*)&WB_IncMetaspaceCapacityUntilGC },
1052 {CC"metaspaceCapacityUntilGC", CC"()J", (void*)&WB_MetaspaceCapacityUntilGC },
1053 {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures },
1054 {CC"getNMethod", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1055 (void*)&WB_GetNMethod },
1056 {CC"getThreadStackSize", CC"()J", (void*)&WB_GetThreadStackSize },
1057 {CC"getThreadRemainingStackSize", CC"()J", (void*)&WB_GetThreadRemainingStackSize },
1058 };
1059
1060 #undef CC
1061
1062 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
1063 {
1064 if (WhiteBoxAPI) {
1065 // Make sure that wbclass is loaded by the null classloader
1066 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass());
1067 Handle loader(ikh->class_loader());
1068 if (loader.is_null()) {
1069 WhiteBox::register_methods(env, wbclass, thread, methods, sizeof(methods) / sizeof(methods[0]));
1070 WhiteBox::register_extended(env, wbclass, thread);
1071 WhiteBox::set_used();
1072 }
1073 }
1074 }
1075 JVM_END
|
859 if (inc > max_size_t) {
860 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
861 err_msg("WB_IncMetaspaceCapacityUntilGC: inc does not fit in size_t: " JLONG_FORMAT, inc));
862 }
863
864 size_t new_cap_until_GC = 0;
865 size_t aligned_inc = align_size_down((size_t) inc, Metaspace::commit_alignment());
866 bool success = MetaspaceGC::inc_capacity_until_GC(aligned_inc, &new_cap_until_GC);
867 if (!success) {
868 THROW_MSG_0(vmSymbols::java_lang_IllegalStateException(),
869 "WB_IncMetaspaceCapacityUntilGC: could not increase capacity until GC "
870 "due to contention with another thread");
871 }
872 return (jlong) new_cap_until_GC;
873 WB_END
874
875 WB_ENTRY(jlong, WB_MetaspaceCapacityUntilGC(JNIEnv* env, jobject wb))
876 return (jlong) MetaspaceGC::capacity_until_GC();
877 WB_END
878
879 WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue))
880 Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ?
881 Monitor::_safepoint_check_always :
882 Monitor::_safepoint_check_never;
883 MutexLockerEx ml(new Mutex(Mutex::leaf, "SFPT_Test_lock", true, sfpt_check_required),
884 attemptedNoSafepointValue == JNI_TRUE );
885 WB_END
886 //Some convenience methods to deal with objects from java
887 int WhiteBox::offset_for_field(const char* field_name, oop object,
888 Symbol* signature_symbol) {
889 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
890 Thread* THREAD = Thread::current();
891
892 //Get the class of our object
893 Klass* arg_klass = object->klass();
894 //Turn it into an instance-klass
895 InstanceKlass* ik = InstanceKlass::cast(arg_klass);
896
897 //Create symbols to look for in the class
898 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
899 THREAD);
900
901 //To be filled in with an offset of the field we're looking for
902 fieldDescriptor fd;
903
904 Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
905 if (res == NULL) {
1045 (void*)&WB_GetSizeTVMFlag},
1046 {CC"getDoubleVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Double;",
1047 (void*)&WB_GetDoubleVMFlag},
1048 {CC"getStringVMFlag", CC"(Ljava/lang/String;)Ljava/lang/String;",
1049 (void*)&WB_GetStringVMFlag},
1050 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable },
1051 {CC"fullGC", CC"()V", (void*)&WB_FullGC },
1052 {CC"youngGC", CC"()V", (void*)&WB_YoungGC },
1053 {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory },
1054 {CC"allocateMetaspace",
1055 CC"(Ljava/lang/ClassLoader;J)J", (void*)&WB_AllocateMetaspace },
1056 {CC"freeMetaspace",
1057 CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace },
1058 {CC"incMetaspaceCapacityUntilGC", CC"(J)J", (void*)&WB_IncMetaspaceCapacityUntilGC },
1059 {CC"metaspaceCapacityUntilGC", CC"()J", (void*)&WB_MetaspaceCapacityUntilGC },
1060 {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures },
1061 {CC"getNMethod", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1062 (void*)&WB_GetNMethod },
1063 {CC"getThreadStackSize", CC"()J", (void*)&WB_GetThreadStackSize },
1064 {CC"getThreadRemainingStackSize", CC"()J", (void*)&WB_GetThreadRemainingStackSize },
1065 {CC"assertMatchingSafepointCalls", CC"(ZZ)V", (void*)&WB_AssertMatchingSafepointCalls },
1066 };
1067
1068 #undef CC
1069
1070 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
1071 {
1072 if (WhiteBoxAPI) {
1073 // Make sure that wbclass is loaded by the null classloader
1074 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass());
1075 Handle loader(ikh->class_loader());
1076 if (loader.is_null()) {
1077 WhiteBox::register_methods(env, wbclass, thread, methods, sizeof(methods) / sizeof(methods[0]));
1078 WhiteBox::register_extended(env, wbclass, thread);
1079 WhiteBox::set_used();
1080 }
1081 }
1082 }
1083 JVM_END
|