8073632: Make auxiliary data structures know their own translation factor
Summary: Auxiliary data structures should have knowledge of their own requirements for virtual memory reservations instead of getting these values directly from various places.
Reviewed-by: stefank, kbarrett
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Wed Apr 22 17:05:00 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Apr 27 10:04:26 2015 +0200
@@ -139,6 +139,11 @@
static size_t compute_size(size_t heap_size);
// Returns the amount of bytes on the heap between two marks in the bitmap.
static size_t mark_distance();
+ // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
+ // mark bitmap corresponds to. This is the same as the mark distance above.
+ static size_t heap_map_factor() {
+ return mark_distance();
+ }
CMBitMap() : CMBitMapRO(LogMinObjAlignment), _listener() { _listener.set_bitmap(this); }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp Wed Apr 22 17:05:00 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp Mon Apr 27 10:04:26 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -179,6 +179,11 @@
return ReservedSpace::allocation_align_size_up(number_of_slots);
}
+ // Returns how many bytes of the heap a single byte of the BOT corresponds to.
+ static size_t heap_map_factor() {
+ return N_bytes;
+ }
+
enum SomePublicConstants {
LogN = 9,
LogN_words = LogN - LogHeapWordSize,
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.cpp Wed Apr 22 17:05:00 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.cpp Mon Apr 27 10:04:26 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,17 @@
_counts->clear_range(mr);
}
+size_t G1CardCounts::compute_size(size_t mem_region_size_in_words) {
+ // We keep card counts for every card, so the size of the card counts table must
+ // be the same as the card table.
+ return G1SATBCardTableLoggingModRefBS::compute_size(mem_region_size_in_words);
+}
+
+size_t G1CardCounts::heap_map_factor() {
+ // See G1CardCounts::compute_size() why we reuse the card table value.
+ return G1SATBCardTableLoggingModRefBS::heap_map_factor();
+}
+
void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) {
if (has_count_table()) {
assert(from_card_num < to_card_num,
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp Wed Apr 22 17:05:00 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp Mon Apr 27 10:04:26 2015 +0200
@@ -101,6 +101,14 @@
public:
G1CardCounts(G1CollectedHeap* g1h);
+ // Return the number of slots needed for a card counts table
+ // that covers mem_region_words words.
+ static size_t compute_size(size_t mem_region_size_in_words);
+
+ // Returns how many bytes of the heap a single byte of the card counts table
+ // corresponds to.
+ static size_t heap_map_factor();
+
void initialize(G1RegionToSpaceMapper* mapper);
// Increments the refinement count for the given card.
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Apr 22 17:05:00 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Apr 27 10:04:26 2015 +0200
@@ -1890,24 +1890,24 @@
G1RegionToSpaceMapper* bot_storage =
create_aux_memory_mapper("Block offset table",
G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
- G1BlockOffsetSharedArray::N_bytes);
+ G1BlockOffsetSharedArray::heap_map_factor());
ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
G1RegionToSpaceMapper* cardtable_storage =
create_aux_memory_mapper("Card table",
G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize),
- G1BlockOffsetSharedArray::N_bytes);
+ G1SATBCardTableLoggingModRefBS::heap_map_factor());
G1RegionToSpaceMapper* card_counts_storage =
create_aux_memory_mapper("Card counts table",
- G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
- G1BlockOffsetSharedArray::N_bytes);
+ G1CardCounts::compute_size(g1_rs.size() / HeapWordSize),
+ G1CardCounts::heap_map_factor());
size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());
G1RegionToSpaceMapper* prev_bitmap_storage =
- create_aux_memory_mapper("Prev Bitmap", bitmap_size, CMBitMap::mark_distance());
+ create_aux_memory_mapper("Prev Bitmap", bitmap_size, CMBitMap::heap_map_factor());
G1RegionToSpaceMapper* next_bitmap_storage =
- create_aux_memory_mapper("Next Bitmap", bitmap_size, CMBitMap::mark_distance());
+ create_aux_memory_mapper("Next Bitmap", bitmap_size, CMBitMap::heap_map_factor());
_hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
g1_barrier_set()->initialize(cardtable_storage);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Wed Apr 22 17:05:00 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Mon Apr 27 10:04:26 2015 +0200
@@ -153,6 +153,11 @@
return ReservedSpace::allocation_align_size_up(number_of_slots);
}
+ // Returns how many bytes of the heap a single byte of the Card Table corresponds to.
+ static size_t heap_map_factor() {
+ return CardTableModRefBS::card_size;
+ }
+
G1SATBCardTableLoggingModRefBS(MemRegion whole_heap);
virtual void initialize() { }