< prev index next >
src/share/vm/gc/shared/space.inline.hpp
Print this page
*** 250,313 ****
template <class SpaceType>
inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
// Copy all live objects to their new location
// Used by MarkSweep::mark_sweep_phase4()
! HeapWord* q = space->bottom();
! HeapWord* const t = space->_end_of_live;
! debug_only(HeapWord* prev_q = NULL);
! if (q < t && space->_first_dead > q && !oop(q)->is_gc_marked()) {
#ifdef ASSERT // Debug only
// we have a chunk of the space which hasn't moved and we've reinitialized
// the mark word during the previous pass, so we can't use is_gc_marked for
// the traversal.
HeapWord* const end = space->_first_dead;
! while (q < end) {
! size_t size = space->obj_size(q);
! assert(!oop(q)->is_gc_marked(), "should be unmarked (special dense prefix handling)");
! prev_q = q;
! q += size;
}
#endif
! if (space->_first_dead == t) {
! q = t;
} else {
// $$$ Funky
! q = (HeapWord*) oop(space->_first_dead)->mark()->decode_pointer();
}
}
const intx scan_interval = PrefetchScanIntervalInBytes;
const intx copy_interval = PrefetchCopyIntervalInBytes;
! while (q < t) {
! if (!oop(q)->is_gc_marked()) {
// mark is pointer to next marked oop
! debug_only(prev_q = q);
! q = (HeapWord*) oop(q)->mark()->decode_pointer();
! assert(q > prev_q, "we should be moving forward through memory");
} else {
// prefetch beyond q
! Prefetch::read(q, scan_interval);
// size and destination
! size_t size = space->obj_size(q);
! HeapWord* compaction_top = (HeapWord*)oop(q)->forwardee();
// prefetch beyond compaction_top
Prefetch::write(compaction_top, copy_interval);
// copy object and reinit its mark
! assert(q != compaction_top, "everything in this pass should be moving");
! Copy::aligned_conjoint_words(q, compaction_top, size);
oop(compaction_top)->init_mark();
assert(oop(compaction_top)->klass() != NULL, "should have a class");
! debug_only(prev_q = q);
! q += size;
}
}
// Let's remember if we were empty before we did the compaction.
bool was_empty = space->used_region().is_empty();
--- 250,313 ----
template <class SpaceType>
inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
// Copy all live objects to their new location
// Used by MarkSweep::mark_sweep_phase4()
! HeapWord* cur_obj = space->bottom();
! HeapWord* const end_of_live = space->_end_of_live;
! debug_only(HeapWord* prev_obj = NULL);
! if (cur_obj < end_of_live && space->_first_dead > cur_obj && !oop(cur_obj)->is_gc_marked()) {
#ifdef ASSERT // Debug only
// we have a chunk of the space which hasn't moved and we've reinitialized
// the mark word during the previous pass, so we can't use is_gc_marked for
// the traversal.
HeapWord* const end = space->_first_dead;
! while (cur_obj < end) {
! size_t size = space->obj_size(cur_obj);
! assert(!oop(cur_obj)->is_gc_marked(), "should be unmarked (special dense prefix handling)");
! prev_obj = cur_obj;
! cur_obj += size;
}
#endif
! if (space->_first_dead == end_of_live) {
! cur_obj = end_of_live;
} else {
// $$$ Funky
! cur_obj = (HeapWord*) oop(space->_first_dead)->mark()->decode_pointer();
}
}
const intx scan_interval = PrefetchScanIntervalInBytes;
const intx copy_interval = PrefetchCopyIntervalInBytes;
! while (cur_obj < end_of_live) {
! if (!oop(cur_obj)->is_gc_marked()) {
// mark is pointer to next marked oop
! debug_only(prev_obj = cur_obj);
! cur_obj = (HeapWord*) oop(cur_obj)->mark()->decode_pointer();
! assert(cur_obj > prev_obj, "we should be moving forward through memory");
} else {
// prefetch beyond q
! Prefetch::read(cur_obj, scan_interval);
// size and destination
! size_t size = space->obj_size(cur_obj);
! HeapWord* compaction_top = (HeapWord*)oop(cur_obj)->forwardee();
// prefetch beyond compaction_top
Prefetch::write(compaction_top, copy_interval);
// copy object and reinit its mark
! assert(cur_obj != compaction_top, "everything in this pass should be moving");
! Copy::aligned_conjoint_words(cur_obj, compaction_top, size);
oop(compaction_top)->init_mark();
assert(oop(compaction_top)->klass() != NULL, "should have a class");
! debug_only(prev_obj = cur_obj);
! cur_obj += size;
}
}
// Let's remember if we were empty before we did the compaction.
bool was_empty = space->used_region().is_empty();
< prev index next >