< prev index next >

src/share/vm/prims/whitebox.cpp

Print this page




 788     needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAtPut);
 789   }
 790   if (value != NULL) {
 791     env->ReleaseStringUTFChars(value, ccstrValue);
 792   }
 793   if (needFree) {
 794     FREE_C_HEAP_ARRAY(char, ccstrResult);
 795   }
 796 WB_END
 797 
 798 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
 799   WhiteBox::compilation_locked = true;
 800 WB_END
 801 
 802 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
 803   MonitorLockerEx mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
 804   WhiteBox::compilation_locked = false;
 805   mo.notify_all();
 806 WB_END
 807 
 808 void WhiteBox::sweeper_thread_entry(JavaThread* thread, TRAPS) {
 809   guarantee(WhiteBoxAPI, "internal testing API :: WhiteBox has to be enabled");
 810   {
 811     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 812     NMethodSweeper::_should_sweep = true;
 813   }
 814   NMethodSweeper::possibly_sweep();
 815 }
 816 
 817 JavaThread* WhiteBox::create_sweeper_thread(TRAPS) {
 818   // create sweeper thread w/ custom entry -- one iteration instead of loop
 819   CodeCacheSweeperThread* sweeper_thread = new CodeCacheSweeperThread();
 820   sweeper_thread->set_entry_point(&WhiteBox::sweeper_thread_entry);
 821 
 822   // create j.l.Thread object and associate it w/ sweeper thread
 823   {
 824     // inherit deamon property from current thread
 825     bool is_daemon = java_lang_Thread::is_daemon(JavaThread::current()->threadObj());
 826 
 827     HandleMark hm(THREAD);
 828     Handle thread_group(THREAD, Universe::system_thread_group());
 829     const char* name = "WB Sweeper thread";
 830     sweeper_thread->allocate_threadObj(thread_group, name, is_daemon, THREAD);
 831   }
 832 
 833   {
 834     MutexLocker mu(Threads_lock, THREAD);
 835     Threads::add(sweeper_thread);
 836   }
 837   return sweeper_thread;
 838 }
 839 
 840 WB_ENTRY(jobject, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
 841   JavaThread* sweeper_thread = WhiteBox::create_sweeper_thread(Thread::current());
 842   if (sweeper_thread == NULL) {
 843     return NULL;
 844   }
 845   jobject result = JNIHandles::make_local(env, sweeper_thread->threadObj());
 846   Thread::start(sweeper_thread);
 847   return result;
 848 WB_END
 849 
 850 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
 851   ResourceMark rm(THREAD);
 852   int len;
 853   jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
 854   return (StringTable::lookup(name, len) != NULL);
 855 WB_END
 856 
 857 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
 858   Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true);
 859   Universe::heap()->collect(GCCause::_last_ditch_collection);
 860 #if INCLUDE_ALL_GCS
 861   if (UseG1GC) {
 862     // Needs to be cleared explicitly for G1
 863     Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(false);
 864   }
 865 #endif // INCLUDE_ALL_GCS
 866 WB_END
 867 


1368                                                       (void*)&WB_GetUint64VMFlag},
1369   {CC"getSizeTVMFlag",     CC"(Ljava/lang/String;)Ljava/lang/Long;",
1370                                                       (void*)&WB_GetSizeTVMFlag},
1371   {CC"getDoubleVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/Double;",
1372                                                       (void*)&WB_GetDoubleVMFlag},
1373   {CC"getStringVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/String;",
1374                                                       (void*)&WB_GetStringVMFlag},
1375   {CC"isInStringTable",    CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable  },
1376   {CC"fullGC",   CC"()V",                             (void*)&WB_FullGC },
1377   {CC"youngGC",  CC"()V",                             (void*)&WB_YoungGC },
1378   {CC"readReservedMemory", CC"()V",                   (void*)&WB_ReadReservedMemory },
1379   {CC"allocateMetaspace",
1380      CC"(Ljava/lang/ClassLoader;J)J",                 (void*)&WB_AllocateMetaspace },
1381   {CC"freeMetaspace",
1382      CC"(Ljava/lang/ClassLoader;JJ)V",                (void*)&WB_FreeMetaspace },
1383   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
1384   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
1385   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
1386   {CC"getNMethod",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1387                                                       (void*)&WB_GetNMethod         },
1388   {CC"forceNMethodSweep0", CC"()Ljava/lang/Thread;",  (void*)&WB_ForceNMethodSweep  },
1389   {CC"allocateCodeBlob",   CC"(II)J",                 (void*)&WB_AllocateCodeBlob   },
1390   {CC"freeCodeBlob",       CC"(J)V",                  (void*)&WB_FreeCodeBlob       },
1391   {CC"getCodeHeapEntries", CC"(I)[Ljava/lang/Object;",(void*)&WB_GetCodeHeapEntries },
1392   {CC"getCompilationActivityMode",
1393                            CC"()I",                   (void*)&WB_GetCompilationActivityMode},
1394   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
1395   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
1396   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
1397   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
1398   {CC"isMonitorInflated",  CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated  },
1399   {CC"forceSafepoint",     CC"()V",                   (void*)&WB_ForceSafepoint     },
1400   {CC"getMethodBooleanOption",
1401       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
1402                                                       (void*)&WB_GetMethodBooleaneOption},
1403   {CC"getMethodIntxOption",
1404       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1405                                                       (void*)&WB_GetMethodIntxOption},
1406   {CC"getMethodUintxOption",
1407       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1408                                                       (void*)&WB_GetMethodUintxOption},




 788     needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAtPut);
 789   }
 790   if (value != NULL) {
 791     env->ReleaseStringUTFChars(value, ccstrValue);
 792   }
 793   if (needFree) {
 794     FREE_C_HEAP_ARRAY(char, ccstrResult);
 795   }
 796 WB_END
 797 
 798 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
 799   WhiteBox::compilation_locked = true;
 800 WB_END
 801 
 802 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
 803   MonitorLockerEx mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
 804   WhiteBox::compilation_locked = false;
 805   mo.notify_all();
 806 WB_END
 807 
 808 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
 809   // Force a code cache sweep and block until it finished
 810   NMethodSweeper::force_sweep();





































 811 WB_END
 812 
 813 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
 814   ResourceMark rm(THREAD);
 815   int len;
 816   jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
 817   return (StringTable::lookup(name, len) != NULL);
 818 WB_END
 819 
 820 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
 821   Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true);
 822   Universe::heap()->collect(GCCause::_last_ditch_collection);
 823 #if INCLUDE_ALL_GCS
 824   if (UseG1GC) {
 825     // Needs to be cleared explicitly for G1
 826     Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(false);
 827   }
 828 #endif // INCLUDE_ALL_GCS
 829 WB_END
 830 


1331                                                       (void*)&WB_GetUint64VMFlag},
1332   {CC"getSizeTVMFlag",     CC"(Ljava/lang/String;)Ljava/lang/Long;",
1333                                                       (void*)&WB_GetSizeTVMFlag},
1334   {CC"getDoubleVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/Double;",
1335                                                       (void*)&WB_GetDoubleVMFlag},
1336   {CC"getStringVMFlag",    CC"(Ljava/lang/String;)Ljava/lang/String;",
1337                                                       (void*)&WB_GetStringVMFlag},
1338   {CC"isInStringTable",    CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable  },
1339   {CC"fullGC",   CC"()V",                             (void*)&WB_FullGC },
1340   {CC"youngGC",  CC"()V",                             (void*)&WB_YoungGC },
1341   {CC"readReservedMemory", CC"()V",                   (void*)&WB_ReadReservedMemory },
1342   {CC"allocateMetaspace",
1343      CC"(Ljava/lang/ClassLoader;J)J",                 (void*)&WB_AllocateMetaspace },
1344   {CC"freeMetaspace",
1345      CC"(Ljava/lang/ClassLoader;JJ)V",                (void*)&WB_FreeMetaspace },
1346   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
1347   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
1348   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
1349   {CC"getNMethod",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1350                                                       (void*)&WB_GetNMethod         },
1351   {CC"forceNMethodSweep",  CC"()V",                   (void*)&WB_ForceNMethodSweep  },
1352   {CC"allocateCodeBlob",   CC"(II)J",                 (void*)&WB_AllocateCodeBlob   },
1353   {CC"freeCodeBlob",       CC"(J)V",                  (void*)&WB_FreeCodeBlob       },
1354   {CC"getCodeHeapEntries", CC"(I)[Ljava/lang/Object;",(void*)&WB_GetCodeHeapEntries },
1355   {CC"getCompilationActivityMode",
1356                            CC"()I",                   (void*)&WB_GetCompilationActivityMode},
1357   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
1358   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
1359   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
1360   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
1361   {CC"isMonitorInflated",  CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated  },
1362   {CC"forceSafepoint",     CC"()V",                   (void*)&WB_ForceSafepoint     },
1363   {CC"getMethodBooleanOption",
1364       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
1365                                                       (void*)&WB_GetMethodBooleaneOption},
1366   {CC"getMethodIntxOption",
1367       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1368                                                       (void*)&WB_GetMethodIntxOption},
1369   {CC"getMethodUintxOption",
1370       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1371                                                       (void*)&WB_GetMethodUintxOption},


< prev index next >