mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 02:24:40 +02:00
8038423: G1: Decommit memory within heap
Allow G1 to decommit memory of arbitrary regions within the heap and their associated auxiliary data structures card table, BOT, hot card cache, and mark bitmaps. Reviewed-by: mgerdin, brutisso, jwilhelm
This commit is contained in:
parent
2617d54723
commit
100e51a339
32 changed files with 1322 additions and 579 deletions
|
@ -403,3 +403,41 @@ void HumongousRegionSetMtSafeChecker::check() {
|
|||
"master humongous set MT safety protocol outside a safepoint");
|
||||
}
|
||||
}
|
||||
|
||||
void FreeRegionList_test() {
|
||||
FreeRegionList l("test");
|
||||
|
||||
const uint num_regions_in_test = 5;
|
||||
// Create a fake heap. It does not need to be valid, as the HeapRegion constructor
|
||||
// does not access it.
|
||||
MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords);
|
||||
// Allocate a fake BOT because the HeapRegion constructor initializes
|
||||
// the BOT.
|
||||
size_t bot_size = G1BlockOffsetSharedArray::compute_size(heap.word_size());
|
||||
HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC);
|
||||
ReservedSpace bot_rs(G1BlockOffsetSharedArray::compute_size(heap.word_size()));
|
||||
G1RegionToSpaceMapper* bot_storage =
|
||||
G1RegionToSpaceMapper::create_mapper(bot_rs,
|
||||
os::vm_page_size(),
|
||||
HeapRegion::GrainBytes,
|
||||
G1BlockOffsetSharedArray::N_bytes,
|
||||
mtGC);
|
||||
G1BlockOffsetSharedArray oa(heap, bot_storage);
|
||||
bot_storage->commit_regions(0, num_regions_in_test);
|
||||
HeapRegion hr0(0, &oa, heap);
|
||||
HeapRegion hr1(1, &oa, heap);
|
||||
HeapRegion hr2(2, &oa, heap);
|
||||
HeapRegion hr3(3, &oa, heap);
|
||||
HeapRegion hr4(4, &oa, heap);
|
||||
l.add_ordered(&hr1);
|
||||
l.add_ordered(&hr0);
|
||||
l.add_ordered(&hr3);
|
||||
l.add_ordered(&hr4);
|
||||
l.add_ordered(&hr2);
|
||||
assert(l.length() == num_regions_in_test, "wrong length");
|
||||
l.verify_list();
|
||||
|
||||
bot_storage->uncommit_regions(0, num_regions_in_test);
|
||||
delete bot_storage;
|
||||
FREE_C_HEAP_ARRAY(HeapWord, bot_data, mtGC);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue