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

src/share/vm/prims/whitebox.cpp

Print this page




1019   if (inc > max_size_t) {
1020     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
1021         err_msg("WB_IncMetaspaceCapacityUntilGC: inc does not fit in size_t: " JLONG_FORMAT, inc));
1022   }
1023 
1024   size_t new_cap_until_GC = 0;
1025   size_t aligned_inc = align_size_down((size_t) inc, Metaspace::commit_alignment());
1026   bool success = MetaspaceGC::inc_capacity_until_GC(aligned_inc, &new_cap_until_GC);
1027   if (!success) {
1028     THROW_MSG_0(vmSymbols::java_lang_IllegalStateException(),
1029                 "WB_IncMetaspaceCapacityUntilGC: could not increase capacity until GC "
1030                 "due to contention with another thread");
1031   }
1032   return (jlong) new_cap_until_GC;
1033 WB_END
1034 
1035 WB_ENTRY(jlong, WB_MetaspaceCapacityUntilGC(JNIEnv* env, jobject wb))
1036   return (jlong) MetaspaceGC::capacity_until_GC();
1037 WB_END
1038 







1039 //Some convenience methods to deal with objects from java
1040 int WhiteBox::offset_for_field(const char* field_name, oop object,
1041     Symbol* signature_symbol) {
1042   assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
1043   Thread* THREAD = Thread::current();
1044 
1045   //Get the class of our object
1046   Klass* arg_klass = object->klass();
1047   //Turn it into an instance-klass
1048   InstanceKlass* ik = InstanceKlass::cast(arg_klass);
1049 
1050   //Create symbols to look for in the class
1051   TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
1052       THREAD);
1053 
1054   //To be filled in with an offset of the field we're looking for
1055   fieldDescriptor fd;
1056 
1057   Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
1058   if (res == NULL) {


1211                                                       (void*)&WB_GetStringVMFlag},
1212   {CC"isInStringTable",    CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable  },
1213   {CC"fullGC",   CC"()V",                             (void*)&WB_FullGC },
1214   {CC"youngGC",  CC"()V",                             (void*)&WB_YoungGC },
1215   {CC"readReservedMemory", CC"()V",                   (void*)&WB_ReadReservedMemory },
1216   {CC"allocateMetaspace",
1217      CC"(Ljava/lang/ClassLoader;J)J",                 (void*)&WB_AllocateMetaspace },
1218   {CC"freeMetaspace",
1219      CC"(Ljava/lang/ClassLoader;JJ)V",                (void*)&WB_FreeMetaspace },
1220   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
1221   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
1222   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
1223   {CC"getNMethod",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1224                                                       (void*)&WB_GetNMethod         },
1225   {CC"forceNMethodSweep",  CC"()V",                   (void*)&WB_ForceNMethodSweep  },
1226   {CC"allocateCodeBlob",   CC"(II)J",                 (void*)&WB_AllocateCodeBlob   },
1227   {CC"freeCodeBlob",       CC"(J)V",                  (void*)&WB_FreeCodeBlob       },
1228   {CC"getCodeHeapEntries", CC"(I)[Ljava/lang/Object;",(void*)&WB_GetCodeHeapEntries },
1229   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
1230   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },

1231 };
1232 
1233 #undef CC
1234 
1235 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
1236   {
1237     if (WhiteBoxAPI) {
1238       // Make sure that wbclass is loaded by the null classloader
1239       instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass());
1240       Handle loader(ikh->class_loader());
1241       if (loader.is_null()) {
1242         WhiteBox::register_methods(env, wbclass, thread, methods, sizeof(methods) / sizeof(methods[0]));
1243         WhiteBox::register_extended(env, wbclass, thread);
1244         WhiteBox::set_used();
1245       }
1246     }
1247   }
1248 JVM_END


1019   if (inc > max_size_t) {
1020     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
1021         err_msg("WB_IncMetaspaceCapacityUntilGC: inc does not fit in size_t: " JLONG_FORMAT, inc));
1022   }
1023 
1024   size_t new_cap_until_GC = 0;
1025   size_t aligned_inc = align_size_down((size_t) inc, Metaspace::commit_alignment());
1026   bool success = MetaspaceGC::inc_capacity_until_GC(aligned_inc, &new_cap_until_GC);
1027   if (!success) {
1028     THROW_MSG_0(vmSymbols::java_lang_IllegalStateException(),
1029                 "WB_IncMetaspaceCapacityUntilGC: could not increase capacity until GC "
1030                 "due to contention with another thread");
1031   }
1032   return (jlong) new_cap_until_GC;
1033 WB_END
1034 
1035 WB_ENTRY(jlong, WB_MetaspaceCapacityUntilGC(JNIEnv* env, jobject wb))
1036   return (jlong) MetaspaceGC::capacity_until_GC();
1037 WB_END
1038 
1039 WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue))
1040   Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ?
1041                                            Monitor::_safepoint_check_always :
1042                                            Monitor::_safepoint_check_never;
1043   MutexLockerEx ml(new Mutex(Mutex::leaf, "SFPT_Test_lock", true, sfpt_check_required),
1044                    attemptedNoSafepointValue == JNI_TRUE );
1045 WB_END
1046 //Some convenience methods to deal with objects from java
1047 int WhiteBox::offset_for_field(const char* field_name, oop object,
1048     Symbol* signature_symbol) {
1049   assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
1050   Thread* THREAD = Thread::current();
1051 
1052   //Get the class of our object
1053   Klass* arg_klass = object->klass();
1054   //Turn it into an instance-klass
1055   InstanceKlass* ik = InstanceKlass::cast(arg_klass);
1056 
1057   //Create symbols to look for in the class
1058   TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
1059       THREAD);
1060 
1061   //To be filled in with an offset of the field we're looking for
1062   fieldDescriptor fd;
1063 
1064   Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
1065   if (res == NULL) {


1218                                                       (void*)&WB_GetStringVMFlag},
1219   {CC"isInStringTable",    CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable  },
1220   {CC"fullGC",   CC"()V",                             (void*)&WB_FullGC },
1221   {CC"youngGC",  CC"()V",                             (void*)&WB_YoungGC },
1222   {CC"readReservedMemory", CC"()V",                   (void*)&WB_ReadReservedMemory },
1223   {CC"allocateMetaspace",
1224      CC"(Ljava/lang/ClassLoader;J)J",                 (void*)&WB_AllocateMetaspace },
1225   {CC"freeMetaspace",
1226      CC"(Ljava/lang/ClassLoader;JJ)V",                (void*)&WB_FreeMetaspace },
1227   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
1228   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
1229   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
1230   {CC"getNMethod",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1231                                                       (void*)&WB_GetNMethod         },
1232   {CC"forceNMethodSweep",  CC"()V",                   (void*)&WB_ForceNMethodSweep  },
1233   {CC"allocateCodeBlob",   CC"(II)J",                 (void*)&WB_AllocateCodeBlob   },
1234   {CC"freeCodeBlob",       CC"(J)V",                  (void*)&WB_FreeCodeBlob       },
1235   {CC"getCodeHeapEntries", CC"(I)[Ljava/lang/Object;",(void*)&WB_GetCodeHeapEntries },
1236   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
1237   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
1238   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
1239 };
1240 
1241 #undef CC
1242 
1243 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
1244   {
1245     if (WhiteBoxAPI) {
1246       // Make sure that wbclass is loaded by the null classloader
1247       instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass());
1248       Handle loader(ikh->class_loader());
1249       if (loader.is_null()) {
1250         WhiteBox::register_methods(env, wbclass, thread, methods, sizeof(methods) / sizeof(methods[0]));
1251         WhiteBox::register_extended(env, wbclass, thread);
1252         WhiteBox::set_used();
1253       }
1254     }
1255   }
1256 JVM_END
src/share/vm/prims/whitebox.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File