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/atomic.hpp"
63 #include "runtime/deoptimization.hpp"
64 #include "runtime/fieldDescriptor.inline.hpp"
65 #include "runtime/flags/jvmFlag.hpp"
66 #include "runtime/frame.inline.hpp"
67 #include "runtime/handles.inline.hpp"
68 #include "runtime/handshake.hpp"
69 #include "runtime/interfaceSupport.inline.hpp"
70 #include "runtime/javaCalls.hpp"
71 #include "runtime/jniHandles.inline.hpp"
72 #include "runtime/os.hpp"
73 #include "runtime/sweeper.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 G1CollectedHeap* g1h = G1CollectedHeap::heap();
467 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
468 g1h->collect(GCCause::_wb_conc_mark);
469 return true;
470 }
471 return false;
472 }
473 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
474 WB_END
475
476 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
477 if (UseG1GC) {
478 return (jint)HeapRegion::GrainBytes;
479 }
480 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
481 WB_END
482
483 #endif // INCLUDE_G1GC
484
485 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1402
1403 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1404 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1405 WhiteBox::compilation_locked = false;
1406 mo.notify_all();
1407 WB_END
1408
1409 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1410 // Force a code cache sweep and block until it finished
1411 NMethodSweeper::force_sweep();
1412 WB_END
1413
1414 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1415 ResourceMark rm(THREAD);
1416 int len;
1417 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1418 return (StringTable::lookup(name, len) != NULL);
1419 WB_END
1420
1421 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1422 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1423 Universe::heap()->collect(GCCause::_wb_full_gc);
1424 #if INCLUDE_G1GC
1425 if (UseG1GC) {
1426 // Needs to be cleared explicitly for G1
1427 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1428 }
1429 #endif // INCLUDE_G1GC
1430 WB_END
1431
1432 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1433 Universe::heap()->collect(GCCause::_wb_young_gc);
1434 WB_END
1435
1436 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1437 // static+volatile in order to force the read to happen
1438 // (not be eliminated by the compiler)
1439 static char c;
1440 static volatile char* p;
1441
|
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/atomic.hpp"
63 #include "runtime/deoptimization.hpp"
64 #include "runtime/fieldDescriptor.inline.hpp"
65 #include "runtime/flags/jvmFlag.hpp"
66 #include "runtime/frame.inline.hpp"
67 #include "runtime/handles.inline.hpp"
68 #include "runtime/handshake.hpp"
69 #include "runtime/interfaceSupport.inline.hpp"
70 #include "runtime/javaCalls.hpp"
71 #include "runtime/jniHandles.inline.hpp"
72 #include "runtime/os.hpp"
73 #include "runtime/sweeper.hpp"
74 #include "runtime/synchronizer.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
447
448 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
449 if (UseG1GC) {
450 G1CollectedHeap* g1h = G1CollectedHeap::heap();
451 size_t nr = g1h->num_free_regions();
452 return (jlong)nr;
453 }
454 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1NumFreeRegions: G1 GC is not enabled");
455 WB_END
456
457 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
458 if (UseG1GC) {
459 G1CollectedHeap* g1h = G1CollectedHeap::heap();
460 return g1h->concurrent_mark()->cm_thread()->during_cycle();
461 }
462 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled");
463 WB_END
464
465 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
466 if (UseG1GC) {
467 if (AsyncDeflateIdleMonitors) {
468 // AsyncDeflateIdleMonitors needs to know when System.gc() or
469 // the equivalent is called so any special clean up can be done
470 // at a safepoint, e.g., TestHumongousClassLoader.java.
471 ObjectSynchronizer::set_is_special_deflation_requested(true);
472 }
473 G1CollectedHeap* g1h = G1CollectedHeap::heap();
474 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
475 g1h->collect(GCCause::_wb_conc_mark);
476 return true;
477 }
478 return false;
479 }
480 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
481 WB_END
482
483 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
484 if (UseG1GC) {
485 return (jint)HeapRegion::GrainBytes;
486 }
487 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
488 WB_END
489
490 #endif // INCLUDE_G1GC
491
492 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1409
1410 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1411 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1412 WhiteBox::compilation_locked = false;
1413 mo.notify_all();
1414 WB_END
1415
1416 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1417 // Force a code cache sweep and block until it finished
1418 NMethodSweeper::force_sweep();
1419 WB_END
1420
1421 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1422 ResourceMark rm(THREAD);
1423 int len;
1424 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1425 return (StringTable::lookup(name, len) != NULL);
1426 WB_END
1427
1428 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1429 if (AsyncDeflateIdleMonitors) {
1430 // AsyncDeflateIdleMonitors needs to know when System.gc() or
1431 // the equivalent is called so any special clean up can be done
1432 // at a safepoint, e.g., TestHumongousClassLoader.java.
1433 ObjectSynchronizer::set_is_special_deflation_requested(true);
1434 }
1435 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1436 Universe::heap()->collect(GCCause::_wb_full_gc);
1437 #if INCLUDE_G1GC
1438 if (UseG1GC) {
1439 // Needs to be cleared explicitly for G1
1440 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1441 }
1442 #endif // INCLUDE_G1GC
1443 WB_END
1444
1445 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1446 Universe::heap()->collect(GCCause::_wb_young_gc);
1447 WB_END
1448
1449 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1450 // static+volatile in order to force the read to happen
1451 // (not be eliminated by the compiler)
1452 static char c;
1453 static volatile char* p;
1454
|