Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/whitebox.cpp @ 20357:4bfc44ba0d19
8055098: WB API should be extended to provide information about size and age of object.
Summary: Extend the WhiteBox API to provide information about the size and age of objects. Further add a mechanism to trigger a young GC.
Reviewed-by: tschatzl, sjohanss
Contributed-by: Leonid Mesnik <leonid.mesnik@oracle.com>
author | tschatzl |
---|---|
date | Thu, 21 Aug 2014 16:44:41 +0200 |
parents | 6701abbc4441 |
children | 833b0f92429a |
comparison
equal
deleted
inserted
replaced
20355:47e8e40b94d3 | 20357:4bfc44ba0d19 |
---|---|
41 #include "utilities/debug.hpp" | 41 #include "utilities/debug.hpp" |
42 #include "utilities/macros.hpp" | 42 #include "utilities/macros.hpp" |
43 #include "utilities/exceptions.hpp" | 43 #include "utilities/exceptions.hpp" |
44 | 44 |
45 #if INCLUDE_ALL_GCS | 45 #if INCLUDE_ALL_GCS |
46 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp" | |
46 #include "gc_implementation/g1/concurrentMark.hpp" | 47 #include "gc_implementation/g1/concurrentMark.hpp" |
47 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" | 48 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
48 #include "gc_implementation/g1/heapRegionRemSet.hpp" | 49 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
49 #endif // INCLUDE_ALL_GCS | 50 #endif // INCLUDE_ALL_GCS |
50 | 51 |
219 | 220 |
220 return wb_stress_virtual_space_resize((size_t) reserved_space_size, | 221 return wb_stress_virtual_space_resize((size_t) reserved_space_size, |
221 (size_t) magnitude, (size_t) iterations); | 222 (size_t) magnitude, (size_t) iterations); |
222 WB_END | 223 WB_END |
223 | 224 |
225 WB_ENTRY(jboolean, WB_isObjectInOldGen(JNIEnv* env, jobject o, jobject obj)) | |
226 oop p = JNIHandles::resolve(obj); | |
227 #if INCLUDE_ALL_GCS | |
228 if (UseG1GC) { | |
229 G1CollectedHeap* g1 = G1CollectedHeap::heap(); | |
230 const HeapRegion* hr = g1->heap_region_containing(p); | |
231 if (hr == NULL) { | |
232 return false; | |
233 } | |
234 return !(hr->is_young()); | |
235 } else if (UseParallelGC) { | |
236 ParallelScavengeHeap* psh = ParallelScavengeHeap::heap(); | |
237 return !psh->is_in_young(p); | |
238 } | |
239 #endif // INCLUDE_ALL_GCS | |
240 GenCollectedHeap* gch = GenCollectedHeap::heap(); | |
241 return !gch->is_in_young(p); | |
242 WB_END | |
243 | |
244 WB_ENTRY(jlong, WB_GetObjectSize(JNIEnv* env, jobject o, jobject obj)) | |
245 oop p = JNIHandles::resolve(obj); | |
246 return p->size() * HeapWordSize; | |
247 WB_END | |
248 | |
224 #if INCLUDE_ALL_GCS | 249 #if INCLUDE_ALL_GCS |
225 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) | 250 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) |
226 G1CollectedHeap* g1 = G1CollectedHeap::heap(); | 251 G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
227 oop result = JNIHandles::resolve(obj); | 252 oop result = JNIHandles::resolve(obj); |
228 const HeapRegion* hr = g1->heap_region_containing(result); | 253 const HeapRegion* hr = g1->heap_region_containing(result); |
666 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) | 691 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) |
667 Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true); | 692 Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true); |
668 Universe::heap()->collect(GCCause::_last_ditch_collection); | 693 Universe::heap()->collect(GCCause::_last_ditch_collection); |
669 WB_END | 694 WB_END |
670 | 695 |
696 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o)) | |
697 Universe::heap()->collect(GCCause::_wb_young_gc); | |
698 WB_END | |
671 | 699 |
672 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o)) | 700 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o)) |
673 // static+volatile in order to force the read to happen | 701 // static+volatile in order to force the read to happen |
674 // (not be eliminated by the compiler) | 702 // (not be eliminated by the compiler) |
675 static char c; | 703 static char c; |
809 | 837 |
810 #define CC (char*) | 838 #define CC (char*) |
811 | 839 |
812 static JNINativeMethod methods[] = { | 840 static JNINativeMethod methods[] = { |
813 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, | 841 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, |
842 {CC"getObjectSize", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize }, | |
843 {CC"isObjectInOldGen", CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen }, | |
814 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, | 844 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
815 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, | 845 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, |
816 {CC"parseCommandLine", | 846 {CC"parseCommandLine", |
817 CC"(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", | 847 CC"(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", |
818 (void*) &WB_ParseCommandLine | 848 (void*) &WB_ParseCommandLine |
883 (void*)&WB_GetDoubleVMFlag}, | 913 (void*)&WB_GetDoubleVMFlag}, |
884 {CC"getStringVMFlag", CC"(Ljava/lang/String;)Ljava/lang/String;", | 914 {CC"getStringVMFlag", CC"(Ljava/lang/String;)Ljava/lang/String;", |
885 (void*)&WB_GetStringVMFlag}, | 915 (void*)&WB_GetStringVMFlag}, |
886 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, | 916 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, |
887 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, | 917 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, |
918 {CC"youngGC", CC"()V", (void*)&WB_YoungGC }, | |
888 {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, | 919 {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, |
889 {CC"allocateMetaspace", | 920 {CC"allocateMetaspace", |
890 CC"(Ljava/lang/ClassLoader;J)J", (void*)&WB_AllocateMetaspace }, | 921 CC"(Ljava/lang/ClassLoader;J)J", (void*)&WB_AllocateMetaspace }, |
891 {CC"freeMetaspace", | 922 {CC"freeMetaspace", |
892 CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace }, | 923 CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace }, |