53 #include "oops/method.inline.hpp"
54 #include "oops/objArrayKlass.hpp"
55 #include "oops/objArrayOop.inline.hpp"
56 #include "oops/oop.inline.hpp"
57 #include "oops/typeArrayOop.inline.hpp"
58 #include "prims/resolvedMethodTable.hpp"
59 #include "prims/wbtestmethods/parserTests.hpp"
60 #include "prims/whitebox.inline.hpp"
61 #include "runtime/arguments.hpp"
62 #include "runtime/deoptimization.hpp"
63 #include "runtime/fieldDescriptor.inline.hpp"
64 #include "runtime/flags/jvmFlag.hpp"
65 #include "runtime/frame.inline.hpp"
66 #include "runtime/handles.inline.hpp"
67 #include "runtime/handshake.hpp"
68 #include "runtime/interfaceSupport.inline.hpp"
69 #include "runtime/javaCalls.hpp"
70 #include "runtime/jniHandles.inline.hpp"
71 #include "runtime/os.hpp"
72 #include "runtime/sweeper.hpp"
73 #include "runtime/thread.hpp"
74 #include "runtime/threadSMR.hpp"
75 #include "runtime/vm_version.hpp"
76 #include "services/memoryService.hpp"
77 #include "utilities/align.hpp"
78 #include "utilities/debug.hpp"
79 #include "utilities/elfFile.hpp"
80 #include "utilities/exceptions.hpp"
81 #include "utilities/macros.hpp"
82 #if INCLUDE_CDS
83 #include "prims/cdsoffsets.hpp"
84 #endif // INCLUDE_CDS
85 #if INCLUDE_G1GC
86 #include "gc/g1/g1Arguments.hpp"
87 #include "gc/g1/g1CollectedHeap.inline.hpp"
88 #include "gc/g1/g1ConcurrentMark.hpp"
89 #include "gc/g1/g1ConcurrentMarkThread.hpp"
90 #include "gc/g1/heapRegionRemSet.hpp"
91 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
92 #endif // INCLUDE_G1GC
445
446 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
447 if (UseG1GC) {
448 G1CollectedHeap* g1h = G1CollectedHeap::heap();
449 size_t nr = g1h->num_free_regions();
450 return (jlong)nr;
451 }
452 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1NumFreeRegions: G1 GC is not enabled");
453 WB_END
454
455 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
456 if (UseG1GC) {
457 G1CollectedHeap* g1h = G1CollectedHeap::heap();
458 return g1h->concurrent_mark()->cm_thread()->during_cycle();
459 }
460 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled");
461 WB_END
462
463 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
464 if (UseG1GC) {
465 G1CollectedHeap* g1h = G1CollectedHeap::heap();
466 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
467 g1h->collect(GCCause::_wb_conc_mark);
468 return true;
469 }
470 return false;
471 }
472 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
473 WB_END
474
475 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
476 if (UseG1GC) {
477 return (jint)HeapRegion::GrainBytes;
478 }
479 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
480 WB_END
481
482 #endif // INCLUDE_G1GC
483
484 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1363
1364 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1365 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1366 WhiteBox::compilation_locked = false;
1367 mo.notify_all();
1368 WB_END
1369
1370 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1371 // Force a code cache sweep and block until it finished
1372 NMethodSweeper::force_sweep();
1373 WB_END
1374
1375 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1376 ResourceMark rm(THREAD);
1377 int len;
1378 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1379 return (StringTable::lookup(name, len) != NULL);
1380 WB_END
1381
1382 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1383 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1384 Universe::heap()->collect(GCCause::_wb_full_gc);
1385 #if INCLUDE_G1GC
1386 if (UseG1GC) {
1387 // Needs to be cleared explicitly for G1
1388 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1389 }
1390 #endif // INCLUDE_G1GC
1391 WB_END
1392
1393 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1394 Universe::heap()->collect(GCCause::_wb_young_gc);
1395 WB_END
1396
1397 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1398 // static+volatile in order to force the read to happen
1399 // (not be eliminated by the compiler)
1400 static char c;
1401 static volatile char* p;
1402
|
53 #include "oops/method.inline.hpp"
54 #include "oops/objArrayKlass.hpp"
55 #include "oops/objArrayOop.inline.hpp"
56 #include "oops/oop.inline.hpp"
57 #include "oops/typeArrayOop.inline.hpp"
58 #include "prims/resolvedMethodTable.hpp"
59 #include "prims/wbtestmethods/parserTests.hpp"
60 #include "prims/whitebox.inline.hpp"
61 #include "runtime/arguments.hpp"
62 #include "runtime/deoptimization.hpp"
63 #include "runtime/fieldDescriptor.inline.hpp"
64 #include "runtime/flags/jvmFlag.hpp"
65 #include "runtime/frame.inline.hpp"
66 #include "runtime/handles.inline.hpp"
67 #include "runtime/handshake.hpp"
68 #include "runtime/interfaceSupport.inline.hpp"
69 #include "runtime/javaCalls.hpp"
70 #include "runtime/jniHandles.inline.hpp"
71 #include "runtime/os.hpp"
72 #include "runtime/sweeper.hpp"
73 #include "runtime/synchronizer.hpp"
74 #include "runtime/thread.hpp"
75 #include "runtime/threadSMR.hpp"
76 #include "runtime/vm_version.hpp"
77 #include "services/memoryService.hpp"
78 #include "utilities/align.hpp"
79 #include "utilities/debug.hpp"
80 #include "utilities/elfFile.hpp"
81 #include "utilities/exceptions.hpp"
82 #include "utilities/macros.hpp"
83 #if INCLUDE_CDS
84 #include "prims/cdsoffsets.hpp"
85 #endif // INCLUDE_CDS
86 #if INCLUDE_G1GC
87 #include "gc/g1/g1Arguments.hpp"
88 #include "gc/g1/g1CollectedHeap.inline.hpp"
89 #include "gc/g1/g1ConcurrentMark.hpp"
90 #include "gc/g1/g1ConcurrentMarkThread.hpp"
91 #include "gc/g1/heapRegionRemSet.hpp"
92 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
93 #endif // INCLUDE_G1GC
446
447 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
448 if (UseG1GC) {
449 G1CollectedHeap* g1h = G1CollectedHeap::heap();
450 size_t nr = g1h->num_free_regions();
451 return (jlong)nr;
452 }
453 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1NumFreeRegions: G1 GC is not enabled");
454 WB_END
455
456 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
457 if (UseG1GC) {
458 G1CollectedHeap* g1h = G1CollectedHeap::heap();
459 return g1h->concurrent_mark()->cm_thread()->during_cycle();
460 }
461 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled");
462 WB_END
463
464 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
465 if (UseG1GC) {
466 if (AsyncDeflateIdleMonitors) {
467 // AsyncDeflateIdleMonitors needs to know when System.gc() or
468 // the equivalent is called so any special clean up can be done
469 // at a safepoint, e.g., TestHumongousClassLoader.java.
470 ObjectSynchronizer::set_is_special_deflation_requested(true);
471 }
472 G1CollectedHeap* g1h = G1CollectedHeap::heap();
473 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
474 g1h->collect(GCCause::_wb_conc_mark);
475 return true;
476 }
477 return false;
478 }
479 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
480 WB_END
481
482 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
483 if (UseG1GC) {
484 return (jint)HeapRegion::GrainBytes;
485 }
486 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
487 WB_END
488
489 #endif // INCLUDE_G1GC
490
491 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1370
1371 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1372 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1373 WhiteBox::compilation_locked = false;
1374 mo.notify_all();
1375 WB_END
1376
1377 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1378 // Force a code cache sweep and block until it finished
1379 NMethodSweeper::force_sweep();
1380 WB_END
1381
1382 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1383 ResourceMark rm(THREAD);
1384 int len;
1385 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1386 return (StringTable::lookup(name, len) != NULL);
1387 WB_END
1388
1389 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1390 if (AsyncDeflateIdleMonitors) {
1391 // AsyncDeflateIdleMonitors needs to know when System.gc() or
1392 // the equivalent is called so any special clean up can be done
1393 // at a safepoint, e.g., TestHumongousClassLoader.java.
1394 ObjectSynchronizer::set_is_special_deflation_requested(true);
1395 }
1396 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1397 Universe::heap()->collect(GCCause::_wb_full_gc);
1398 #if INCLUDE_G1GC
1399 if (UseG1GC) {
1400 // Needs to be cleared explicitly for G1
1401 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1402 }
1403 #endif // INCLUDE_G1GC
1404 WB_END
1405
1406 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1407 Universe::heap()->collect(GCCause::_wb_young_gc);
1408 WB_END
1409
1410 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1411 // static+volatile in order to force the read to happen
1412 // (not be eliminated by the compiler)
1413 static char c;
1414 static volatile char* p;
1415
|