1 /* |
1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
77 // These are protected by "_m". |
77 // These are protected by "_m". |
78 BitMap _coarse_map; |
78 BitMap _coarse_map; |
79 size_t _n_coarse_entries; |
79 size_t _n_coarse_entries; |
80 static jint _n_coarsenings; |
80 static jint _n_coarsenings; |
81 |
81 |
82 PosParPRT** _fine_grain_regions; |
82 PerRegionTable** _fine_grain_regions; |
83 size_t _n_fine_entries; |
83 size_t _n_fine_entries; |
84 |
84 |
85 #define SAMPLE_FOR_EVICTION 1 |
85 // Used to sample a subset of the fine grain PRTs to determine which |
86 #if SAMPLE_FOR_EVICTION |
86 // PRT to evict and coarsen. |
87 size_t _fine_eviction_start; |
87 size_t _fine_eviction_start; |
88 static size_t _fine_eviction_stride; |
88 static size_t _fine_eviction_stride; |
89 static size_t _fine_eviction_sample_size; |
89 static size_t _fine_eviction_sample_size; |
90 #endif |
|
91 |
90 |
92 SparsePRT _sparse_table; |
91 SparsePRT _sparse_table; |
93 |
92 |
94 // These are static after init. |
93 // These are static after init. |
95 static size_t _max_fine_entries; |
94 static size_t _max_fine_entries; |
96 static size_t _mod_max_fine_entries_mask; |
95 static size_t _mod_max_fine_entries_mask; |
97 |
96 |
98 // Requires "prt" to be the first element of the bucket list appropriate |
97 // Requires "prt" to be the first element of the bucket list appropriate |
99 // for "hr". If this list contains an entry for "hr", return it, |
98 // for "hr". If this list contains an entry for "hr", return it, |
100 // otherwise return "NULL". |
99 // otherwise return "NULL". |
101 PosParPRT* find_region_table(size_t ind, HeapRegion* hr) const; |
100 PerRegionTable* find_region_table(size_t ind, HeapRegion* hr) const; |
102 |
101 |
103 // Find, delete, and return a candidate PosParPRT, if any exists, |
102 // Find, delete, and return a candidate PerRegionTable, if any exists, |
104 // adding the deleted region to the coarse bitmap. Requires the caller |
103 // adding the deleted region to the coarse bitmap. Requires the caller |
105 // to hold _m, and the fine-grain table to be full. |
104 // to hold _m, and the fine-grain table to be full. |
106 PosParPRT* delete_region_table(); |
105 PerRegionTable* delete_region_table(); |
107 |
106 |
108 // If a PRT for "hr" is in the bucket list indicated by "ind" (which must |
107 // If a PRT for "hr" is in the bucket list indicated by "ind" (which must |
109 // be the correct index for "hr"), delete it and return true; else return |
108 // be the correct index for "hr"), delete it and return true; else return |
110 // false. |
109 // false. |
111 bool del_single_region_table(size_t ind, HeapRegion* hr); |
110 bool del_single_region_table(size_t ind, HeapRegion* hr); |
112 |
111 |
113 static jint _cache_probes; |
|
114 static jint _cache_hits; |
|
115 |
|
116 // Indexed by thread X heap region, to minimize thread contention. |
112 // Indexed by thread X heap region, to minimize thread contention. |
117 static int** _from_card_cache; |
113 static int** _from_card_cache; |
118 static size_t _from_card_cache_max_regions; |
114 static size_t _from_card_cache_max_regions; |
119 static size_t _from_card_cache_mem_size; |
115 static size_t _from_card_cache_mem_size; |
120 |
116 |
124 HeapRegion* hr() const { return _hr; } |
120 HeapRegion* hr() const { return _hr; } |
125 |
121 |
126 // For now. Could "expand" some tables in the future, so that this made |
122 // For now. Could "expand" some tables in the future, so that this made |
127 // sense. |
123 // sense. |
128 void add_reference(OopOrNarrowOopStar from, int tid); |
124 void add_reference(OopOrNarrowOopStar from, int tid); |
129 |
|
130 void add_reference(OopOrNarrowOopStar from) { |
|
131 return add_reference(from, 0); |
|
132 } |
|
133 |
125 |
134 // Removes any entries shown by the given bitmaps to contain only dead |
126 // Removes any entries shown by the given bitmaps to contain only dead |
135 // objects. |
127 // objects. |
136 void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm); |
128 void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm); |
137 |
129 |
231 return _other_regions.occ_sparse(); |
223 return _other_regions.occ_sparse(); |
232 } |
224 } |
233 |
225 |
234 static jint n_coarsenings() { return OtherRegionsTable::n_coarsenings(); } |
226 static jint n_coarsenings() { return OtherRegionsTable::n_coarsenings(); } |
235 |
227 |
236 /* Used in the sequential case. Returns "true" iff this addition causes |
228 // Used in the sequential case. |
237 the size limit to be reached. */ |
|
238 void add_reference(OopOrNarrowOopStar from) { |
229 void add_reference(OopOrNarrowOopStar from) { |
239 _other_regions.add_reference(from); |
230 _other_regions.add_reference(from, 0); |
240 } |
231 } |
241 |
232 |
242 /* Used in the parallel case. Returns "true" iff this addition causes |
233 // Used in the parallel case. |
243 the size limit to be reached. */ |
|
244 void add_reference(OopOrNarrowOopStar from, int tid) { |
234 void add_reference(OopOrNarrowOopStar from, int tid) { |
245 _other_regions.add_reference(from, tid); |
235 _other_regions.add_reference(from, tid); |
246 } |
236 } |
247 |
237 |
248 // Removes any entries shown by the given bitmaps to contain only dead |
238 // Removes any entries shown by the given bitmaps to contain only dead |
250 void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm); |
240 void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm); |
251 |
241 |
252 // The region is being reclaimed; clear its remset, and any mention of |
242 // The region is being reclaimed; clear its remset, and any mention of |
253 // entries for this region in other remsets. |
243 // entries for this region in other remsets. |
254 void clear(); |
244 void clear(); |
255 |
|
256 // Forget any entries due to pointers from "from_hr". |
|
257 void clear_incoming_entry(HeapRegion* from_hr) { |
|
258 _other_regions.clear_incoming_entry(from_hr); |
|
259 } |
|
260 |
|
261 #if 0 |
|
262 virtual void cleanup() = 0; |
|
263 #endif |
|
264 |
245 |
265 // Attempt to claim the region. Returns true iff this call caused an |
246 // Attempt to claim the region. Returns true iff this call caused an |
266 // atomic transition from Unclaimed to Claimed. |
247 // atomic transition from Unclaimed to Claimed. |
267 bool claim_iter(); |
248 bool claim_iter(); |
268 // Sets the iteration state to "complete". |
249 // Sets the iteration state to "complete". |
320 return _other_regions.contains_reference(from); |
295 return _other_regions.contains_reference(from); |
321 } |
296 } |
322 void print() const; |
297 void print() const; |
323 |
298 |
324 // Called during a stop-world phase to perform any deferred cleanups. |
299 // Called during a stop-world phase to perform any deferred cleanups. |
325 // The second version may be called by parallel threads after then finish |
|
326 // collection work. |
|
327 static void cleanup(); |
300 static void cleanup(); |
328 static void par_cleanup(); |
|
329 |
301 |
330 // Declare the heap size (in # of regions) to the HeapRegionRemSet(s). |
302 // Declare the heap size (in # of regions) to the HeapRegionRemSet(s). |
331 // (Uses it to initialize from_card_cache). |
303 // (Uses it to initialize from_card_cache). |
332 static void init_heap(uint max_regions) { |
304 static void init_heap(uint max_regions) { |
333 OtherRegionsTable::init_from_card_cache((size_t) max_regions); |
305 OtherRegionsTable::init_from_card_cache((size_t) max_regions); |
365 // The region over which we're iterating. |
337 // The region over which we're iterating. |
366 const HeapRegionRemSet* _hrrs; |
338 const HeapRegionRemSet* _hrrs; |
367 |
339 |
368 // Local caching of HRRS fields. |
340 // Local caching of HRRS fields. |
369 const BitMap* _coarse_map; |
341 const BitMap* _coarse_map; |
370 PosParPRT** _fine_grain_regions; |
342 PerRegionTable** _fine_grain_regions; |
371 |
343 |
372 G1BlockOffsetSharedArray* _bosa; |
344 G1BlockOffsetSharedArray* _bosa; |
373 G1CollectedHeap* _g1h; |
345 G1CollectedHeap* _g1h; |
374 |
346 |
375 // The number yielded since initialization. |
347 // The number yielded since initialization. |