--- old/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp 2013-05-16 22:06:33.065628392 +0200 +++ new/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp 2013-05-16 22:06:32.997594395 +0200 @@ -242,11 +242,13 @@ PerRegionTable* cur = _free_list; size_t res = 0; while (cur != NULL) { - res += sizeof(PerRegionTable); + res += cur->mem_size(); cur = cur->next(); } return res; } + + static void test_fl_mem_size(); }; PerRegionTable* PerRegionTable::_free_list = NULL; @@ -1147,6 +1149,18 @@ } #ifndef PRODUCT +void PerRegionTable::test_fl_mem_size() { + if (!UseG1GC) return; + + PerRegionTable* dummy = alloc(NULL); + free(dummy); + guarantee(dummy->mem_size() == fl_mem_size(), "fl_mem_size() does not return the correct element size"); +} + +void HeapRegionRemSet::test_prt() { + PerRegionTable::test_fl_mem_size(); +} + void HeapRegionRemSet::test() { os::sleep(Thread::current(), (jlong)5000, false); G1CollectedHeap* g1h = G1CollectedHeap::heap(); --- old/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp 2013-05-16 22:06:33.325758383 +0200 +++ new/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp 2013-05-16 22:06:33.277734384 +0200 @@ -338,6 +338,7 @@ // Run unit tests. #ifndef PRODUCT + static void test_prt(); static void test(); #endif }; --- old/src/share/vm/prims/jni.cpp 2013-05-16 22:06:33.593892373 +0200 +++ new/src/share/vm/prims/jni.cpp 2013-05-16 22:06:33.533862374 +0200 @@ -5015,6 +5015,9 @@ #ifndef PRODUCT #include "gc_interface/collectedHeap.hpp" +#if INCLUDE_ALL_GCS +#include "gc_implementation/g1/heapRegionRemSet.hpp" +#endif #include "utilities/quickSort.hpp" #if INCLUDE_VM_STRUCTS #include "runtime/vmStructs.hpp" @@ -5035,6 +5038,9 @@ #if INCLUDE_VM_STRUCTS run_unit_test(VMStructs::test()); #endif +#if INCLUDE_ALL_GCS + run_unit_test(HeapRegionRemSet::test_prt()); +#endif tty->print_cr("All internal VM tests passed"); } }