56 #include "oops/objArrayKlass.hpp"
57 #include "oops/objArrayOop.inline.hpp"
58 #include "oops/oop.inline.hpp"
59 #include "oops/typeArrayOop.inline.hpp"
60 #include "prims/resolvedMethodTable.hpp"
61 #include "prims/wbtestmethods/parserTests.hpp"
62 #include "prims/whitebox.inline.hpp"
63 #include "runtime/arguments.hpp"
64 #include "runtime/atomic.hpp"
65 #include "runtime/deoptimization.hpp"
66 #include "runtime/fieldDescriptor.inline.hpp"
67 #include "runtime/flags/jvmFlag.hpp"
68 #include "runtime/frame.inline.hpp"
69 #include "runtime/handles.inline.hpp"
70 #include "runtime/handshake.hpp"
71 #include "runtime/interfaceSupport.inline.hpp"
72 #include "runtime/javaCalls.hpp"
73 #include "runtime/jniHandles.inline.hpp"
74 #include "runtime/os.hpp"
75 #include "runtime/sweeper.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 G1CollectedHeap* g1h = G1CollectedHeap::heap();
481 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
482 g1h->collect(GCCause::_wb_conc_mark);
483 return true;
484 }
485 return false;
486 }
487 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
488 WB_END
489
490 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
491 if (UseG1GC) {
492 return (jint)HeapRegion::GrainBytes;
493 }
494 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
495 WB_END
496
497 #endif // INCLUDE_G1GC
498
499 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1431
1432 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1433 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1434 WhiteBox::compilation_locked = false;
1435 mo.notify_all();
1436 WB_END
1437
1438 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1439 // Force a code cache sweep and block until it finished
1440 NMethodSweeper::force_sweep();
1441 WB_END
1442
1443 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1444 ResourceMark rm(THREAD);
1445 int len;
1446 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1447 return (StringTable::lookup(name, len) != NULL);
1448 WB_END
1449
1450 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1451 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1452 Universe::heap()->collect(GCCause::_wb_full_gc);
1453 #if INCLUDE_G1GC
1454 if (UseG1GC) {
1455 // Needs to be cleared explicitly for G1
1456 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1457 }
1458 #endif // INCLUDE_G1GC
1459 WB_END
1460
1461 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1462 Universe::heap()->collect(GCCause::_wb_young_gc);
1463 WB_END
1464
1465 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1466 // static+volatile in order to force the read to happen
1467 // (not be eliminated by the compiler)
1468 static char c;
1469 static volatile char* p;
1470
1780 WB_ENTRY(void, WB_AssertSpecialLock(JNIEnv* env, jobject o, jboolean allowVMBlock, jboolean safepointCheck))
1781 // Create a special lock violating condition in value
1782 Mutex::SafepointCheckRequired sfpt_check_required = safepointCheck ?
1783 Mutex::_safepoint_check_always :
1784 Mutex::_safepoint_check_never;
1785 Mutex::SafepointCheckFlag safepoint_check = safepointCheck ?
1786 Monitor::_safepoint_check_flag :
1787 Monitor::_no_safepoint_check_flag;
1788
1789 MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", allowVMBlock, sfpt_check_required), safepoint_check);
1790 // If the lock above succeeds, try to safepoint to test the NSV implied with this special lock.
1791 ThreadBlockInVM tbivm(JavaThread::current());
1792 WB_END
1793
1794 WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj))
1795 oop obj_oop = JNIHandles::resolve(obj);
1796 return (jboolean) obj_oop->mark().has_monitor();
1797 WB_END
1798
1799 WB_ENTRY(void, WB_ForceSafepoint(JNIEnv* env, jobject wb))
1800 VM_ForceSafepoint force_safepoint_op;
1801 VMThread::execute(&force_safepoint_op);
1802 WB_END
1803
1804 WB_ENTRY(jlong, WB_GetConstantPool(JNIEnv* env, jobject wb, jclass klass))
1805 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1806 return (jlong) ik->constants();
1807 WB_END
1808
1809 WB_ENTRY(jint, WB_GetConstantPoolCacheIndexTag(JNIEnv* env, jobject wb))
1810 return ConstantPool::CPCACHE_INDEX_TAG;
1811 WB_END
1812
1813 WB_ENTRY(jint, WB_GetConstantPoolCacheLength(JNIEnv* env, jobject wb, jclass klass))
1814 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1815 ConstantPool* cp = ik->constants();
1816 if (cp->cache() == NULL) {
1817 return -1;
1818 }
1819 return cp->cache()->length();
|
56 #include "oops/objArrayKlass.hpp"
57 #include "oops/objArrayOop.inline.hpp"
58 #include "oops/oop.inline.hpp"
59 #include "oops/typeArrayOop.inline.hpp"
60 #include "prims/resolvedMethodTable.hpp"
61 #include "prims/wbtestmethods/parserTests.hpp"
62 #include "prims/whitebox.inline.hpp"
63 #include "runtime/arguments.hpp"
64 #include "runtime/atomic.hpp"
65 #include "runtime/deoptimization.hpp"
66 #include "runtime/fieldDescriptor.inline.hpp"
67 #include "runtime/flags/jvmFlag.hpp"
68 #include "runtime/frame.inline.hpp"
69 #include "runtime/handles.inline.hpp"
70 #include "runtime/handshake.hpp"
71 #include "runtime/interfaceSupport.inline.hpp"
72 #include "runtime/javaCalls.hpp"
73 #include "runtime/jniHandles.inline.hpp"
74 #include "runtime/os.hpp"
75 #include "runtime/sweeper.hpp"
76 #include "runtime/synchronizer.hpp"
77 #include "runtime/thread.hpp"
78 #include "runtime/threadSMR.hpp"
79 #include "runtime/vm_version.hpp"
80 #include "services/memoryService.hpp"
81 #include "utilities/align.hpp"
82 #include "utilities/debug.hpp"
83 #include "utilities/elfFile.hpp"
84 #include "utilities/exceptions.hpp"
85 #include "utilities/macros.hpp"
86 #if INCLUDE_CDS
87 #include "prims/cdsoffsets.hpp"
88 #endif // INCLUDE_CDS
89 #if INCLUDE_G1GC
90 #include "gc/g1/g1Arguments.hpp"
91 #include "gc/g1/g1CollectedHeap.inline.hpp"
92 #include "gc/g1/g1ConcurrentMark.hpp"
93 #include "gc/g1/g1ConcurrentMarkThread.hpp"
94 #include "gc/g1/heapRegionRemSet.hpp"
95 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
96 #endif // INCLUDE_G1GC
461
462 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
463 if (UseG1GC) {
464 G1CollectedHeap* g1h = G1CollectedHeap::heap();
465 size_t nr = g1h->num_free_regions();
466 return (jlong)nr;
467 }
468 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1NumFreeRegions: G1 GC is not enabled");
469 WB_END
470
471 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
472 if (UseG1GC) {
473 G1CollectedHeap* g1h = G1CollectedHeap::heap();
474 return g1h->concurrent_mark()->cm_thread()->during_cycle();
475 }
476 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled");
477 WB_END
478
479 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
480 if (UseG1GC) {
481 if (AsyncDeflateIdleMonitors) {
482 // AsyncDeflateIdleMonitors needs to know when System.gc() or
483 // the equivalent is called so any special clean up can be done
484 // at a safepoint, e.g., TestHumongousClassLoader.java.
485 ObjectSynchronizer::set_is_special_deflation_requested(true);
486 }
487 G1CollectedHeap* g1h = G1CollectedHeap::heap();
488 if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
489 g1h->collect(GCCause::_wb_conc_mark);
490 return true;
491 }
492 return false;
493 }
494 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
495 WB_END
496
497 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
498 if (UseG1GC) {
499 return (jint)HeapRegion::GrainBytes;
500 }
501 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
502 WB_END
503
504 #endif // INCLUDE_G1GC
505
506 #if INCLUDE_G1GC || INCLUDE_PARALLELGC
1438
1439 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1440 MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1441 WhiteBox::compilation_locked = false;
1442 mo.notify_all();
1443 WB_END
1444
1445 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1446 // Force a code cache sweep and block until it finished
1447 NMethodSweeper::force_sweep();
1448 WB_END
1449
1450 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1451 ResourceMark rm(THREAD);
1452 int len;
1453 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1454 return (StringTable::lookup(name, len) != NULL);
1455 WB_END
1456
1457 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1458 if (AsyncDeflateIdleMonitors) {
1459 // AsyncDeflateIdleMonitors needs to know when System.gc() or
1460 // the equivalent is called so any special clean up can be done
1461 // at a safepoint, e.g., TestHumongousClassLoader.java.
1462 ObjectSynchronizer::set_is_special_deflation_requested(true);
1463 }
1464 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1465 Universe::heap()->collect(GCCause::_wb_full_gc);
1466 #if INCLUDE_G1GC
1467 if (UseG1GC) {
1468 // Needs to be cleared explicitly for G1
1469 Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1470 }
1471 #endif // INCLUDE_G1GC
1472 WB_END
1473
1474 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1475 Universe::heap()->collect(GCCause::_wb_young_gc);
1476 WB_END
1477
1478 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1479 // static+volatile in order to force the read to happen
1480 // (not be eliminated by the compiler)
1481 static char c;
1482 static volatile char* p;
1483
1793 WB_ENTRY(void, WB_AssertSpecialLock(JNIEnv* env, jobject o, jboolean allowVMBlock, jboolean safepointCheck))
1794 // Create a special lock violating condition in value
1795 Mutex::SafepointCheckRequired sfpt_check_required = safepointCheck ?
1796 Mutex::_safepoint_check_always :
1797 Mutex::_safepoint_check_never;
1798 Mutex::SafepointCheckFlag safepoint_check = safepointCheck ?
1799 Monitor::_safepoint_check_flag :
1800 Monitor::_no_safepoint_check_flag;
1801
1802 MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", allowVMBlock, sfpt_check_required), safepoint_check);
1803 // If the lock above succeeds, try to safepoint to test the NSV implied with this special lock.
1804 ThreadBlockInVM tbivm(JavaThread::current());
1805 WB_END
1806
1807 WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj))
1808 oop obj_oop = JNIHandles::resolve(obj);
1809 return (jboolean) obj_oop->mark().has_monitor();
1810 WB_END
1811
1812 WB_ENTRY(void, WB_ForceSafepoint(JNIEnv* env, jobject wb))
1813 if (AsyncDeflateIdleMonitors) {
1814 // AsyncDeflateIdleMonitors needs to know when System.gc() or
1815 // the equivalent is called so any special clean up can be done
1816 // at a safepoint, e.g., TestRTMTotalCountIncrRate.java or
1817 // TestUseRTMForStackLocks.java.
1818 ObjectSynchronizer::set_is_special_deflation_requested(true);
1819 }
1820 VM_ForceSafepoint force_safepoint_op;
1821 VMThread::execute(&force_safepoint_op);
1822 WB_END
1823
1824 WB_ENTRY(jlong, WB_GetConstantPool(JNIEnv* env, jobject wb, jclass klass))
1825 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1826 return (jlong) ik->constants();
1827 WB_END
1828
1829 WB_ENTRY(jint, WB_GetConstantPoolCacheIndexTag(JNIEnv* env, jobject wb))
1830 return ConstantPool::CPCACHE_INDEX_TAG;
1831 WB_END
1832
1833 WB_ENTRY(jint, WB_GetConstantPoolCacheLength(JNIEnv* env, jobject wb, jclass klass))
1834 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1835 ConstantPool* cp = ik->constants();
1836 if (cp->cache() == NULL) {
1837 return -1;
1838 }
1839 return cp->cache()->length();
|