149
150 inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMap* const prev_bitmap) const {
151 assert(ClassUnloadingWithConcurrentMark,
152 "All blocks should be objects if class unloading isn't used, so this method should not be called. "
153 "HR: [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ") "
154 "addr: " PTR_FORMAT,
155 p2i(bottom()), p2i(top()), p2i(end()), p2i(addr));
156
157 // Old regions' dead objects may have dead classes
158 // We need to find the next live object using the bitmap
159 HeapWord* next = prev_bitmap->get_next_marked_addr(addr, prev_top_at_mark_start());
160
161 assert(next > addr, "must get the next live object");
162 return pointer_delta(next, addr);
163 }
164
165 inline bool HeapRegion::is_obj_dead(const oop obj, const G1CMBitMap* const prev_bitmap) const {
166 assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(obj));
167 return !obj_allocated_since_prev_marking(obj) &&
168 !prev_bitmap->is_marked(obj) &&
169 !is_open_archive();
170 }
171
172 inline size_t HeapRegion::block_size(const HeapWord *addr) const {
173 if (addr == top()) {
174 return pointer_delta(end(), addr);
175 }
176
177 if (block_is_obj(addr)) {
178 return oop(addr)->size();
179 }
180
181 return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prev_mark_bitmap());
182 }
183
184 inline void HeapRegion::complete_compaction() {
185 // Reset space and bot after compaction is complete if needed.
186 reset_after_compaction();
187 if (is_empty()) {
188 reset_bot();
189 }
333 {
334 assert(cur <= start,
335 "cur: " PTR_FORMAT ", start: " PTR_FORMAT, p2i(cur), p2i(start));
336 HeapWord* next = cur + block_size(cur);
337 assert(start < next,
338 "start: " PTR_FORMAT ", next: " PTR_FORMAT, p2i(start), p2i(next));
339 }
340 #endif
341
342 const G1CMBitMap* const bitmap = g1h->concurrent_mark()->prev_mark_bitmap();
343 while (true) {
344 oop obj = oop(cur);
345 assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
346 assert(obj->klass_or_null() != NULL,
347 "Unparsable heap at " PTR_FORMAT, p2i(cur));
348
349 size_t size;
350 bool is_dead = is_obj_dead_with_size(obj, bitmap, &size);
351 bool is_precise = false;
352
353 cur += size;
354 if (!is_dead) {
355 // Process live object's references.
356
357 // Non-objArrays are usually marked imprecise at the object
358 // start, in which case we need to iterate over them in full.
359 // objArrays are precisely marked, but can still be iterated
360 // over in full if completely covered.
361 if (!obj->is_objArray() || (cast_from_oop<HeapWord*>(obj) >= start && cur <= end)) {
362 obj->oop_iterate(cl);
363 } else {
364 obj->oop_iterate(cl, mr);
365 is_precise = true;
366 }
367 }
368 if (cur >= end) {
369 return is_precise ? end : cur;
370 }
371 }
372 }
|
149
150 inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMap* const prev_bitmap) const {
151 assert(ClassUnloadingWithConcurrentMark,
152 "All blocks should be objects if class unloading isn't used, so this method should not be called. "
153 "HR: [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ") "
154 "addr: " PTR_FORMAT,
155 p2i(bottom()), p2i(top()), p2i(end()), p2i(addr));
156
157 // Old regions' dead objects may have dead classes
158 // We need to find the next live object using the bitmap
159 HeapWord* next = prev_bitmap->get_next_marked_addr(addr, prev_top_at_mark_start());
160
161 assert(next > addr, "must get the next live object");
162 return pointer_delta(next, addr);
163 }
164
165 inline bool HeapRegion::is_obj_dead(const oop obj, const G1CMBitMap* const prev_bitmap) const {
166 assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(obj));
167 return !obj_allocated_since_prev_marking(obj) &&
168 !prev_bitmap->is_marked(obj) &&
169 !is_closed_archive();
170
171 // return !(obj_allocated_since_prev_marking(obj) || prev_bitmap->is_marked(obj) || is_closed_archive());
172 }
173
174 inline size_t HeapRegion::block_size(const HeapWord *addr) const {
175 if (addr == top()) {
176 return pointer_delta(end(), addr);
177 }
178
179 if (block_is_obj(addr)) {
180 return oop(addr)->size();
181 }
182
183 return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prev_mark_bitmap());
184 }
185
186 inline void HeapRegion::complete_compaction() {
187 // Reset space and bot after compaction is complete if needed.
188 reset_after_compaction();
189 if (is_empty()) {
190 reset_bot();
191 }
335 {
336 assert(cur <= start,
337 "cur: " PTR_FORMAT ", start: " PTR_FORMAT, p2i(cur), p2i(start));
338 HeapWord* next = cur + block_size(cur);
339 assert(start < next,
340 "start: " PTR_FORMAT ", next: " PTR_FORMAT, p2i(start), p2i(next));
341 }
342 #endif
343
344 const G1CMBitMap* const bitmap = g1h->concurrent_mark()->prev_mark_bitmap();
345 while (true) {
346 oop obj = oop(cur);
347 assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
348 assert(obj->klass_or_null() != NULL,
349 "Unparsable heap at " PTR_FORMAT, p2i(cur));
350
351 size_t size;
352 bool is_dead = is_obj_dead_with_size(obj, bitmap, &size);
353 bool is_precise = false;
354
355 if (is_open_archive()) {
356 log_debug(gc)("seq_iter " PTR_FORMAT " dead %d", p2i(obj), is_dead);
357 }
358
359 cur += size;
360 if (!is_dead) {
361 // Process live object's references.
362
363 // Non-objArrays are usually marked imprecise at the object
364 // start, in which case we need to iterate over them in full.
365 // objArrays are precisely marked, but can still be iterated
366 // over in full if completely covered.
367 if (!obj->is_objArray() || (cast_from_oop<HeapWord*>(obj) >= start && cur <= end)) {
368 obj->oop_iterate(cl);
369 } else {
370 obj->oop_iterate(cl, mr);
371 is_precise = true;
372 }
373 }
374 if (cur >= end) {
375 return is_precise ? end : cur;
376 }
377 }
378 }
|