equal
deleted
inserted
replaced
74 class OtherRegionsTable { |
74 class OtherRegionsTable { |
75 friend class HeapRegionRemSetIterator; |
75 friend class HeapRegionRemSetIterator; |
76 |
76 |
77 G1CollectedHeap* _g1h; |
77 G1CollectedHeap* _g1h; |
78 Mutex* _m; |
78 Mutex* _m; |
79 HeapRegion* _hr; |
|
80 |
79 |
81 // These are protected by "_m". |
80 // These are protected by "_m". |
82 CHeapBitMap _coarse_map; |
81 CHeapBitMap _coarse_map; |
83 size_t _n_coarse_entries; |
82 size_t _n_coarse_entries; |
84 static jint _n_coarsenings; |
83 static jint _n_coarsenings; |
122 void unlink_from_all(PerRegionTable * prt); |
121 void unlink_from_all(PerRegionTable * prt); |
123 |
122 |
124 bool contains_reference_locked(OopOrNarrowOopStar from) const; |
123 bool contains_reference_locked(OopOrNarrowOopStar from) const; |
125 |
124 |
126 public: |
125 public: |
127 // Clear the from_card_cache entries for this region. |
126 // Create a new remembered set. The given mutex is used to ensure consistency. |
128 void clear_fcc(); |
127 OtherRegionsTable(Mutex* m); |
129 // Create a new remembered set for the given heap region. The given mutex should |
|
130 // be used to ensure consistency. |
|
131 OtherRegionsTable(HeapRegion* hr, Mutex* m); |
|
132 |
128 |
133 // Returns the card index of the given within_region pointer relative to the bottom |
129 // Returns the card index of the given within_region pointer relative to the bottom |
134 // of the given heap region. |
130 // of the given heap region. |
135 static CardIdx_t card_within_region(OopOrNarrowOopStar within_region, HeapRegion* hr); |
131 static CardIdx_t card_within_region(OopOrNarrowOopStar within_region, HeapRegion* hr); |
136 // Adds the reference from "from to this remembered set. |
132 // Adds the reference from "from to this remembered set. |
180 |
176 |
181 Mutex _m; |
177 Mutex _m; |
182 |
178 |
183 OtherRegionsTable _other_regions; |
179 OtherRegionsTable _other_regions; |
184 |
180 |
|
181 HeapRegion* _hr; |
|
182 |
|
183 void clear_fcc(); |
|
184 |
185 public: |
185 public: |
186 HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr); |
186 HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr); |
187 |
187 |
188 static void setup_remset_size(); |
188 static void setup_remset_size(); |
189 |
189 |
241 void set_state_empty() { |
241 void set_state_empty() { |
242 guarantee(SafepointSynchronize::is_at_safepoint() || !is_tracked(), "Should only set to Untracked during safepoint but is %s.", get_state_str()); |
242 guarantee(SafepointSynchronize::is_at_safepoint() || !is_tracked(), "Should only set to Untracked during safepoint but is %s.", get_state_str()); |
243 if (_state == Untracked) { |
243 if (_state == Untracked) { |
244 return; |
244 return; |
245 } |
245 } |
246 _other_regions.clear_fcc(); |
246 clear_fcc(); |
247 _state = Untracked; |
247 _state = Untracked; |
248 } |
248 } |
249 |
249 |
250 void set_state_updating() { |
250 void set_state_updating() { |
251 guarantee(SafepointSynchronize::is_at_safepoint() && !is_tracked(), "Should only set to Updating from Untracked during safepoint but is %s", get_state_str()); |
251 guarantee(SafepointSynchronize::is_at_safepoint() && !is_tracked(), "Should only set to Updating from Untracked during safepoint but is %s", get_state_str()); |
252 _other_regions.clear_fcc(); |
252 clear_fcc(); |
253 _state = Updating; |
253 _state = Updating; |
254 } |
254 } |
255 |
255 |
256 void set_state_complete() { |
256 void set_state_complete() { |
257 _other_regions.clear_fcc(); |
257 clear_fcc(); |
258 _state = Complete; |
258 _state = Complete; |
259 } |
259 } |
260 |
260 |
261 // Used in the sequential case. |
261 // Used in the sequential case. |
262 void add_reference(OopOrNarrowOopStar from) { |
262 void add_reference(OopOrNarrowOopStar from) { |
267 void add_reference(OopOrNarrowOopStar from, uint tid) { |
267 void add_reference(OopOrNarrowOopStar from, uint tid) { |
268 RemSetState state = _state; |
268 RemSetState state = _state; |
269 if (state == Untracked) { |
269 if (state == Untracked) { |
270 return; |
270 return; |
271 } |
271 } |
|
272 |
|
273 uint cur_idx = _hr->hrm_index(); |
|
274 uintptr_t from_card = uintptr_t(from) >> CardTable::card_shift; |
|
275 |
|
276 if (G1FromCardCache::contains_or_replace(tid, cur_idx, from_card)) { |
|
277 assert(contains_reference(from), "We just found " PTR_FORMAT " in the FromCardCache", p2i(from)); |
|
278 return; |
|
279 } |
|
280 |
272 _other_regions.add_reference(from, tid); |
281 _other_regions.add_reference(from, tid); |
273 } |
282 } |
274 |
283 |
275 // The region is being reclaimed; clear its remset, and any mention of |
284 // The region is being reclaimed; clear its remset, and any mention of |
276 // entries for this region in other remsets. |
285 // entries for this region in other remsets. |