提交 34fb9b2d 编写于 作者: T tschatzl

8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list...

8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
Summary: Instead of using a simple sizeof(), ask the PerRegionTable class about its size when iterating over the free list.
Reviewed-by: jwilhelm, brutisso
上级 1d7067ff
......@@ -242,11 +242,13 @@ public:
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;
......@@ -1149,6 +1151,19 @@ HeapRegionRemSet::finish_cleanup_task(HRRSCleanupTask* hrrs_cleanup_task) {
}
#ifndef PRODUCT
void PerRegionTable::test_fl_mem_size() {
PerRegionTable* dummy = alloc(NULL);
free(dummy);
guarantee(dummy->mem_size() == fl_mem_size(), "fl_mem_size() does not return the correct element size");
// try to reset the state
_free_list = NULL;
delete dummy;
}
void HeapRegionRemSet::test_prt() {
PerRegionTable::test_fl_mem_size();
}
void HeapRegionRemSet::test() {
os::sleep(Thread::current(), (jlong)5000, false);
G1CollectedHeap* g1h = G1CollectedHeap::heap();
......
......@@ -338,6 +338,7 @@ public:
// Run unit tests.
#ifndef PRODUCT
static void test_prt();
static void test();
#endif
};
......
......@@ -5015,6 +5015,9 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) {
#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"
......@@ -5034,6 +5037,9 @@ void execute_internal_vm_tests() {
run_unit_test(AltHashing::test_alt_hash());
#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");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册