65 |
65 |
66 // Start filtering what we add to the remembered set. If the object is |
66 // Start filtering what we add to the remembered set. If the object is |
67 // not considered dead, either because it is marked (in the mark bitmap) |
67 // not considered dead, either because it is marked (in the mark bitmap) |
68 // or it was allocated after marking finished, then we add it. Otherwise |
68 // or it was allocated after marking finished, then we add it. Otherwise |
69 // we can safely ignore the object. |
69 // we can safely ignore the object. |
70 if (!g1h->is_obj_dead(oop(cur), _hr)) { |
70 if (!g1h->is_obj_dead(oop(cur))) { |
71 oop_size = oop(cur)->oop_iterate_size(_rs_scan, mr); |
71 oop_size = oop(cur)->oop_iterate_size(_rs_scan, mr); |
72 } else { |
72 } else { |
73 oop_size = _hr->block_size(cur); |
73 oop_size = _hr->block_size(cur); |
74 } |
74 } |
75 |
75 |
79 oop cur_oop = oop(cur); |
79 oop cur_oop = oop(cur); |
80 oop_size = _hr->block_size(cur); |
80 oop_size = _hr->block_size(cur); |
81 HeapWord* next_obj = cur + oop_size; |
81 HeapWord* next_obj = cur + oop_size; |
82 while (next_obj < top) { |
82 while (next_obj < top) { |
83 // Keep filtering the remembered set. |
83 // Keep filtering the remembered set. |
84 if (!g1h->is_obj_dead(cur_oop, _hr)) { |
84 if (!g1h->is_obj_dead(cur_oop)) { |
85 // Bottom lies entirely below top, so we can call the |
85 // Bottom lies entirely below top, so we can call the |
86 // non-memRegion version of oop_iterate below. |
86 // non-memRegion version of oop_iterate below. |
87 cur_oop->oop_iterate(_rs_scan); |
87 cur_oop->oop_iterate(_rs_scan); |
88 } |
88 } |
89 cur = next_obj; |
89 cur = next_obj; |
159 init_top_at_mark_start(); |
159 init_top_at_mark_start(); |
160 } |
160 } |
161 |
161 |
162 void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) { |
162 void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) { |
163 assert(_humongous_start_region == NULL, |
163 assert(_humongous_start_region == NULL, |
164 "we should have already filtered out humongous regions"); |
|
165 assert(_end == orig_end(), |
|
166 "we should have already filtered out humongous regions"); |
164 "we should have already filtered out humongous regions"); |
167 assert(!in_collection_set(), |
165 assert(!in_collection_set(), |
168 "Should not clear heap region %u in the collection set", hrm_index()); |
166 "Should not clear heap region %u in the collection set", hrm_index()); |
169 |
167 |
170 set_allocation_context(AllocationContext::system()); |
168 set_allocation_context(AllocationContext::system()); |
211 double region_elapsed_time_ms = |
209 double region_elapsed_time_ms = |
212 g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */); |
210 g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */); |
213 _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; |
211 _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; |
214 } |
212 } |
215 |
213 |
216 void HeapRegion::set_starts_humongous(HeapWord* new_top, HeapWord* new_end) { |
214 void HeapRegion::set_starts_humongous(HeapWord* obj_top) { |
217 assert(!is_humongous(), "sanity / pre-condition"); |
215 assert(!is_humongous(), "sanity / pre-condition"); |
218 assert(end() == orig_end(), |
|
219 "Should be normal before the humongous object allocation"); |
|
220 assert(top() == bottom(), "should be empty"); |
216 assert(top() == bottom(), "should be empty"); |
221 assert(bottom() <= new_top && new_top <= new_end, "pre-condition"); |
|
222 |
217 |
223 _type.set_starts_humongous(); |
218 _type.set_starts_humongous(); |
224 _humongous_start_region = this; |
219 _humongous_start_region = this; |
225 |
220 |
226 set_end(new_end); |
221 _offsets.set_for_starts_humongous(obj_top); |
227 _offsets.set_for_starts_humongous(new_top); |
|
228 } |
222 } |
229 |
223 |
230 void HeapRegion::set_continues_humongous(HeapRegion* first_hr) { |
224 void HeapRegion::set_continues_humongous(HeapRegion* first_hr) { |
231 assert(!is_humongous(), "sanity / pre-condition"); |
225 assert(!is_humongous(), "sanity / pre-condition"); |
232 assert(end() == orig_end(), |
|
233 "Should be normal before the humongous object allocation"); |
|
234 assert(top() == bottom(), "should be empty"); |
226 assert(top() == bottom(), "should be empty"); |
235 assert(first_hr->is_starts_humongous(), "pre-condition"); |
227 assert(first_hr->is_starts_humongous(), "pre-condition"); |
236 |
228 |
237 _type.set_continues_humongous(); |
229 _type.set_continues_humongous(); |
238 _humongous_start_region = first_hr; |
230 _humongous_start_region = first_hr; |
239 } |
231 } |
240 |
232 |
241 void HeapRegion::clear_humongous() { |
233 void HeapRegion::clear_humongous() { |
242 assert(is_humongous(), "pre-condition"); |
234 assert(is_humongous(), "pre-condition"); |
243 |
|
244 if (is_starts_humongous()) { |
|
245 assert(top() <= end(), "pre-condition"); |
|
246 set_end(orig_end()); |
|
247 if (top() > end()) { |
|
248 // at least one "continues humongous" region after it |
|
249 set_top(end()); |
|
250 } |
|
251 } else { |
|
252 // continues humongous |
|
253 assert(end() == orig_end(), "sanity"); |
|
254 } |
|
255 |
235 |
256 assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); |
236 assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); |
257 _humongous_start_region = NULL; |
237 _humongous_start_region = NULL; |
258 } |
238 } |
259 |
239 |
288 G1OffsetTableContigSpace::initialize(mr, clear_space, mangle_space); |
268 G1OffsetTableContigSpace::initialize(mr, clear_space, mangle_space); |
289 |
269 |
290 hr_clear(false /*par*/, false /*clear_space*/); |
270 hr_clear(false /*par*/, false /*clear_space*/); |
291 set_top(bottom()); |
271 set_top(bottom()); |
292 record_timestamp(); |
272 record_timestamp(); |
293 |
|
294 assert(mr.end() == orig_end(), |
|
295 "Given region end address " PTR_FORMAT " should match exactly " |
|
296 "bottom plus one region size, i.e. " PTR_FORMAT, |
|
297 p2i(mr.end()), p2i(orig_end())); |
|
298 } |
273 } |
299 |
274 |
300 CompactibleSpace* HeapRegion::next_compaction_space() const { |
275 CompactibleSpace* HeapRegion::next_compaction_space() const { |
301 return G1CollectedHeap::heap()->next_compaction_region(this); |
276 return G1CollectedHeap::heap()->next_compaction_region(this); |
302 } |
277 } |
830 |
805 |
831 if (!is_young() && !is_empty()) { |
806 if (!is_young() && !is_empty()) { |
832 _offsets.verify(); |
807 _offsets.verify(); |
833 } |
808 } |
834 |
809 |
835 if (p != top()) { |
810 if (is_region_humongous) { |
|
811 oop obj = oop(this->humongous_start_region()->bottom()); |
|
812 if ((HeapWord*)obj > bottom() || (HeapWord*)obj + obj->size() < bottom()) { |
|
813 gclog_or_tty->print_cr("this humongous region is not part of its' humongous object " PTR_FORMAT, p2i(obj)); |
|
814 } |
|
815 } |
|
816 |
|
817 if (!is_region_humongous && p != top()) { |
836 gclog_or_tty->print_cr("end of last object " PTR_FORMAT " " |
818 gclog_or_tty->print_cr("end of last object " PTR_FORMAT " " |
837 "does not match top " PTR_FORMAT, p2i(p), p2i(top())); |
819 "does not match top " PTR_FORMAT, p2i(p), p2i(top())); |
838 *failures = true; |
820 *failures = true; |
839 return; |
821 return; |
840 } |
822 } |
841 |
823 |
842 HeapWord* the_end = end(); |
824 HeapWord* the_end = end(); |
843 assert(p == top(), "it should still hold"); |
|
844 // Do some extra BOT consistency checking for addresses in the |
825 // Do some extra BOT consistency checking for addresses in the |
845 // range [top, end). BOT look-ups in this range should yield |
826 // range [top, end). BOT look-ups in this range should yield |
846 // top. No point in doing that if top == end (there's nothing there). |
827 // top. No point in doing that if top == end (there's nothing there). |
847 if (p < the_end) { |
828 if (p < the_end) { |
848 // Look up top |
829 // Look up top |