39 #include "utilities/growableArray.hpp"
40
41 class PerRegionTable: public CHeapObj<mtGC> {
42 friend class OtherRegionsTable;
43 friend class HeapRegionRemSetIterator;
44
45 HeapRegion* _hr;
46 CHeapBitMap _bm;
47 jint _occupied;
48
49 // next pointer for free/allocated 'all' list
50 PerRegionTable* _next;
51
52 // prev pointer for the allocated 'all' list
53 PerRegionTable* _prev;
54
55 // next pointer in collision list
56 PerRegionTable * _collision_list_next;
57
58 // Global free list of PRTs
59 static PerRegionTable* _free_list;
60
61 protected:
62 // We need access in order to union things into the base table.
63 BitMap* bm() { return &_bm; }
64
65 void recount_occupied() {
66 _occupied = (jint) bm()->count_one_bits();
67 }
68
69 PerRegionTable(HeapRegion* hr) :
70 _hr(hr),
71 _occupied(0),
72 _bm(HeapRegion::CardsPerRegion),
73 _collision_list_next(NULL), _next(NULL), _prev(NULL)
74 {}
75
76 void add_card_work(CardIdx_t from_card, bool par) {
77 if (!_bm.at(from_card)) {
78 if (par) {
79 if (_bm.par_at_put(from_card, 1)) {
232 _collision_list_next = next;
233 }
234
235 PerRegionTable** collision_list_next_addr() {
236 return &_collision_list_next;
237 }
238
239 static size_t fl_mem_size() {
240 PerRegionTable* cur = _free_list;
241 size_t res = 0;
242 while (cur != NULL) {
243 res += cur->mem_size();
244 cur = cur->next();
245 }
246 return res;
247 }
248
249 static void test_fl_mem_size();
250 };
251
252 PerRegionTable* PerRegionTable::_free_list = NULL;
253
254 size_t OtherRegionsTable::_max_fine_entries = 0;
255 size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0;
256 size_t OtherRegionsTable::_fine_eviction_stride = 0;
257 size_t OtherRegionsTable::_fine_eviction_sample_size = 0;
258
259 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
260 _g1h(G1CollectedHeap::heap()),
261 _hr(hr), _m(m),
262 _coarse_map(G1CollectedHeap::heap()->max_regions()),
263 _fine_grain_regions(NULL),
264 _first_all_fine_prts(NULL), _last_all_fine_prts(NULL),
265 _n_fine_entries(0), _n_coarse_entries(0),
266 _fine_eviction_start(0),
267 _sparse_table(hr)
268 {
269 typedef PerRegionTable* PerRegionTablePtr;
270
271 if (_max_fine_entries == 0) {
272 assert(_mod_max_fine_entries_mask == 0, "Both or none.");
|
39 #include "utilities/growableArray.hpp"
40
41 class PerRegionTable: public CHeapObj<mtGC> {
42 friend class OtherRegionsTable;
43 friend class HeapRegionRemSetIterator;
44
45 HeapRegion* _hr;
46 CHeapBitMap _bm;
47 jint _occupied;
48
49 // next pointer for free/allocated 'all' list
50 PerRegionTable* _next;
51
52 // prev pointer for the allocated 'all' list
53 PerRegionTable* _prev;
54
55 // next pointer in collision list
56 PerRegionTable * _collision_list_next;
57
58 // Global free list of PRTs
59 static PerRegionTable* volatile _free_list;
60
61 protected:
62 // We need access in order to union things into the base table.
63 BitMap* bm() { return &_bm; }
64
65 void recount_occupied() {
66 _occupied = (jint) bm()->count_one_bits();
67 }
68
69 PerRegionTable(HeapRegion* hr) :
70 _hr(hr),
71 _occupied(0),
72 _bm(HeapRegion::CardsPerRegion),
73 _collision_list_next(NULL), _next(NULL), _prev(NULL)
74 {}
75
76 void add_card_work(CardIdx_t from_card, bool par) {
77 if (!_bm.at(from_card)) {
78 if (par) {
79 if (_bm.par_at_put(from_card, 1)) {
232 _collision_list_next = next;
233 }
234
235 PerRegionTable** collision_list_next_addr() {
236 return &_collision_list_next;
237 }
238
239 static size_t fl_mem_size() {
240 PerRegionTable* cur = _free_list;
241 size_t res = 0;
242 while (cur != NULL) {
243 res += cur->mem_size();
244 cur = cur->next();
245 }
246 return res;
247 }
248
249 static void test_fl_mem_size();
250 };
251
252 PerRegionTable* volatile PerRegionTable::_free_list = NULL;
253
254 size_t OtherRegionsTable::_max_fine_entries = 0;
255 size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0;
256 size_t OtherRegionsTable::_fine_eviction_stride = 0;
257 size_t OtherRegionsTable::_fine_eviction_sample_size = 0;
258
259 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
260 _g1h(G1CollectedHeap::heap()),
261 _hr(hr), _m(m),
262 _coarse_map(G1CollectedHeap::heap()->max_regions()),
263 _fine_grain_regions(NULL),
264 _first_all_fine_prts(NULL), _last_all_fine_prts(NULL),
265 _n_fine_entries(0), _n_coarse_entries(0),
266 _fine_eviction_start(0),
267 _sparse_table(hr)
268 {
269 typedef PerRegionTable* PerRegionTablePtr;
270
271 if (_max_fine_entries == 0) {
272 assert(_mod_max_fine_entries_mask == 0, "Both or none.");
|