55 #include "oops/objArrayKlass.hpp"
56 #include "oops/objArrayOop.inline.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "oops/typeArrayOop.inline.hpp"
59 #include "prims/resolvedMethodTable.hpp"
60 #include "prims/wbtestmethods/parserTests.hpp"
61 #include "prims/whitebox.inline.hpp"
62 #include "runtime/arguments.hpp"
63 #include "runtime/atomic.hpp"
64 #include "runtime/deoptimization.hpp"
65 #include "runtime/fieldDescriptor.inline.hpp"
66 #include "runtime/flags/jvmFlag.hpp"
67 #include "runtime/frame.inline.hpp"
68 #include "runtime/handles.inline.hpp"
69 #include "runtime/handshake.hpp"
70 #include "runtime/interfaceSupport.inline.hpp"
71 #include "runtime/javaCalls.hpp"
72 #include "runtime/jniHandles.inline.hpp"
73 #include "runtime/os.hpp"
74 #include "runtime/sweeper.hpp"
75 #include "runtime/thread.hpp"
76 #include "runtime/threadSMR.hpp"
77 #include "runtime/vm_version.hpp"
78 #include "services/memoryService.hpp"
79 #include "utilities/align.hpp"
80 #include "utilities/debug.hpp"
81 #include "utilities/elfFile.hpp"
82 #include "utilities/exceptions.hpp"
83 #include "utilities/macros.hpp"
84 #if INCLUDE_CDS
85 #include "prims/cdsoffsets.hpp"
86 #endif // INCLUDE_CDS
87 #if INCLUDE_G1GC
88 #include "gc/g1/g1Arguments.hpp"
89 #include "gc/g1/g1CollectedHeap.inline.hpp"
90 #include "gc/g1/g1ConcurrentMark.hpp"
91 #include "gc/g1/g1ConcurrentMarkThread.hpp"
92 #include "gc/g1/heapRegionRemSet.hpp"
93 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
94 #endif // INCLUDE_G1GC
459
460 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
461 if (UseG1GC) {
462 G1CollectedHeap* g1h = G1CollectedHeap::heap();
463 size_t nr = g1h->num_free_regions();
464 return (jlong)nr;
465 }
466 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1NumFreeRegions: G1 GC is not enabled");
467 WB_END
468
469 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
470 if (UseG1GC) {
471 G1CollectedHeap* g1h = G1CollectedHeap::heap();
472 return g1h->concurrent_mark()->cm_thread()->during_cycle();
473 }
474 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled");
475 WB_END
476
477 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
478 if (UseG1GC) {
479 G1CollectedHeap* g1h = G1CollectedHeap::heap();
480 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
481 g1h->collect(GCCause::_wb_conc_mark);
482 return true;
483 }
484 return false;
485 }
486 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
487 WB_END
488
489 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
490 if (UseG1GC) {
491 return (jint)HeapRegion::GrainBytes;
492 }
493 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
494 WB_END
495
496 #endif // INCLUDE_G1GC
497
498 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1430
1431 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1432 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1433 WhiteBox::compilation_locked = false;
1434 mo.notify_all();
1435 WB_END
1436
1437 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1438 // Force a code cache sweep and block until it finished
1439 NMethodSweeper::force_sweep();
1440 WB_END
1441
1442 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1443 ResourceMark rm(THREAD);
1444 int len;
1445 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1446 return (StringTable::lookup(name, len) != NULL);
1447 WB_END
1448
1449 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1450 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1451 Universe::heap()->collect(GCCause::_wb_full_gc);
1452 #if INCLUDE_G1GC
1453 if (UseG1GC) {
1454 // Needs to be cleared explicitly for G1
1455 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1456 }
1457 #endif // INCLUDE_G1GC
1458 WB_END
1459
1460 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1461 Universe::heap()->collect(GCCause::_wb_young_gc);
1462 WB_END
1463
1464 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1465 // static+volatile in order to force the read to happen
1466 // (not be eliminated by the compiler)
1467 static char c;
1468 static volatile char* p;
1469
|
55 #include "oops/objArrayKlass.hpp"
56 #include "oops/objArrayOop.inline.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "oops/typeArrayOop.inline.hpp"
59 #include "prims/resolvedMethodTable.hpp"
60 #include "prims/wbtestmethods/parserTests.hpp"
61 #include "prims/whitebox.inline.hpp"
62 #include "runtime/arguments.hpp"
63 #include "runtime/atomic.hpp"
64 #include "runtime/deoptimization.hpp"
65 #include "runtime/fieldDescriptor.inline.hpp"
66 #include "runtime/flags/jvmFlag.hpp"
67 #include "runtime/frame.inline.hpp"
68 #include "runtime/handles.inline.hpp"
69 #include "runtime/handshake.hpp"
70 #include "runtime/interfaceSupport.inline.hpp"
71 #include "runtime/javaCalls.hpp"
72 #include "runtime/jniHandles.inline.hpp"
73 #include "runtime/os.hpp"
74 #include "runtime/sweeper.hpp"
75 #include "runtime/synchronizer.hpp"
76 #include "runtime/thread.hpp"
77 #include "runtime/threadSMR.hpp"
78 #include "runtime/vm_version.hpp"
79 #include "services/memoryService.hpp"
80 #include "utilities/align.hpp"
81 #include "utilities/debug.hpp"
82 #include "utilities/elfFile.hpp"
83 #include "utilities/exceptions.hpp"
84 #include "utilities/macros.hpp"
85 #if INCLUDE_CDS
86 #include "prims/cdsoffsets.hpp"
87 #endif // INCLUDE_CDS
88 #if INCLUDE_G1GC
89 #include "gc/g1/g1Arguments.hpp"
90 #include "gc/g1/g1CollectedHeap.inline.hpp"
91 #include "gc/g1/g1ConcurrentMark.hpp"
92 #include "gc/g1/g1ConcurrentMarkThread.hpp"
93 #include "gc/g1/heapRegionRemSet.hpp"
94 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
95 #endif // INCLUDE_G1GC
460
461 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
462 if (UseG1GC) {
463 G1CollectedHeap* g1h = G1CollectedHeap::heap();
464 size_t nr = g1h->num_free_regions();
465 return (jlong)nr;
466 }
467 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1NumFreeRegions: G1 GC is not enabled");
468 WB_END
469
470 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
471 if (UseG1GC) {
472 G1CollectedHeap* g1h = G1CollectedHeap::heap();
473 return g1h->concurrent_mark()->cm_thread()->during_cycle();
474 }
475 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled");
476 WB_END
477
478 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
479 if (UseG1GC) {
480 if (AsyncDeflateIdleMonitors) {
481 // AsyncDeflateIdleMonitors needs to know when System.gc() or
482 // the equivalent is called so any special clean up can be done
483 // at a safepoint, e.g., TestHumongousClassLoader.java.
484 ObjectSynchronizer::set_is_special_deflation_requested(true);
485 }
486 G1CollectedHeap* g1h = G1CollectedHeap::heap();
487 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
488 g1h->collect(GCCause::_wb_conc_mark);
489 return true;
490 }
491 return false;
492 }
493 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
494 WB_END
495
496 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
497 if (UseG1GC) {
498 return (jint)HeapRegion::GrainBytes;
499 }
500 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
501 WB_END
502
503 #endif // INCLUDE_G1GC
504
505 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1437
1438 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1439 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1440 WhiteBox::compilation_locked = false;
1441 mo.notify_all();
1442 WB_END
1443
1444 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1445 // Force a code cache sweep and block until it finished
1446 NMethodSweeper::force_sweep();
1447 WB_END
1448
1449 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1450 ResourceMark rm(THREAD);
1451 int len;
1452 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1453 return (StringTable::lookup(name, len) != NULL);
1454 WB_END
1455
1456 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1457 if (AsyncDeflateIdleMonitors) {
1458 // AsyncDeflateIdleMonitors needs to know when System.gc() or
1459 // the equivalent is called so any special clean up can be done
1460 // at a safepoint, e.g., TestHumongousClassLoader.java.
1461 ObjectSynchronizer::set_is_special_deflation_requested(true);
1462 }
1463 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1464 Universe::heap()->collect(GCCause::_wb_full_gc);
1465 #if INCLUDE_G1GC
1466 if (UseG1GC) {
1467 // Needs to be cleared explicitly for G1
1468 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1469 }
1470 #endif // INCLUDE_G1GC
1471 WB_END
1472
1473 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1474 Universe::heap()->collect(GCCause::_wb_young_gc);
1475 WB_END
1476
1477 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1478 // static+volatile in order to force the read to happen
1479 // (not be eliminated by the compiler)
1480 static char c;
1481 static volatile char* p;
1482
|