< prev index next >

src/share/vm/gc/shared/space.inline.hpp

Print this page

        

*** 181,247 **** template <class SpaceType> inline void CompactibleSpace::scan_and_adjust_pointers(SpaceType* space) { // adjust all the interior pointers to point at the new locations of objects // Used by MarkSweep::mark_sweep_phase3() ! HeapWord* q = space->bottom(); ! HeapWord* t = space->_end_of_live; // Established by "prepare_for_compaction". ! assert(space->_first_dead <= space->_end_of_live, "Stands to reason, no?"); ! if (q < t && space->_first_dead > q && !oop(q)->is_gc_marked()) { // 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* end = space->_first_dead; ! while (q < end) { ! // I originally tried to conjoin "block_start(q) == q" to the // assertion below, but that doesn't work, because you can't // accurately traverse previous objects to get to the current one // after their pointers have been // updated, until the actual compaction is done. dld, 4/00 ! assert(space->block_is_obj(q), "should be at block boundaries, and should be looking at objs"); // point all the oops to the new location ! size_t size = MarkSweep::adjust_pointers(oop(q)); size = space->adjust_obj_size(size); ! q += size; } ! if (space->_first_dead == t) { ! q = t; } else { // The first dead object is no longer an object. At that memory address, // there is a pointer to the first live object that the previous phase found. ! q = *((HeapWord**)(space->_first_dead)); } } const intx interval = PrefetchScanIntervalInBytes; ! debug_only(HeapWord* prev_q = NULL); ! while (q < t) { ! // prefetch beyond q ! Prefetch::write(q, interval); ! if (oop(q)->is_gc_marked()) { ! // q is alive // point all the oops to the new location ! size_t size = MarkSweep::adjust_pointers(oop(q)); size = space->adjust_obj_size(size); ! debug_only(prev_q = q); ! q += size; } else { ! debug_only(prev_q = q); ! // q is not a live object, instead it points at the next live object ! q = *(HeapWord**)q; ! assert(q > prev_q, "we should be moving forward through memory, q: " PTR_FORMAT ", prev_q: " PTR_FORMAT, p2i(q), p2i(prev_q)); } } ! assert(q == t, "just checking"); } template <class SpaceType> inline void CompactibleSpace::scan_and_compact(SpaceType* space) { // Copy all live objects to their new location --- 181,246 ---- template <class SpaceType> inline void CompactibleSpace::scan_and_adjust_pointers(SpaceType* space) { // adjust all the interior pointers to point at the new locations of objects // Used by MarkSweep::mark_sweep_phase3() ! HeapWord* cur_obj = space->bottom(); ! HeapWord* const end_of_live = space->_end_of_live; // Established by "scan_and_forward". ! HeapWord* const first_dead = space->_first_dead; // Established by "scan_and_forward". ! assert(first_dead <= end_of_live, "Stands to reason, no?"); ! if (cur_obj < end_of_live && first_dead > cur_obj && !oop(cur_obj)->is_gc_marked()) { // 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. ! while (cur_obj < first_dead) { ! // I originally tried to conjoin "block_start(cur_obj) == cur_obj" to the // assertion below, but that doesn't work, because you can't // accurately traverse previous objects to get to the current one // after their pointers have been // updated, until the actual compaction is done. dld, 4/00 ! assert(space->block_is_obj(cur_obj), "should be at block boundaries, and should be looking at objs"); // point all the oops to the new location ! size_t size = MarkSweep::adjust_pointers(oop(cur_obj)); size = space->adjust_obj_size(size); ! cur_obj += size; } ! if (first_dead == end_of_live) { ! cur_obj = end_of_live; } else { // The first dead object is no longer an object. At that memory address, // there is a pointer to the first live object that the previous phase found. ! cur_obj = *(HeapWord**)first_dead; } } const intx interval = PrefetchScanIntervalInBytes; ! debug_only(HeapWord* prev_obj = NULL); ! while (cur_obj < end_of_live) { ! Prefetch::write(cur_obj, interval); ! if (oop(cur_obj)->is_gc_marked()) { ! // cur_obj is alive // point all the oops to the new location ! size_t size = MarkSweep::adjust_pointers(oop(cur_obj)); size = space->adjust_obj_size(size); ! debug_only(prev_obj = cur_obj); ! cur_obj += size; } else { ! debug_only(prev_obj = cur_obj); ! // cur_obj is not a live object, instead it points at the next live object ! cur_obj = *(HeapWord**)cur_obj; ! assert(cur_obj > prev_obj, "we should be moving forward through memory, cur_obj: " PTR_FORMAT ", prev_obj: " PTR_FORMAT, p2i(cur_obj), p2i(prev_obj)); } } ! assert(cur_obj == end_of_live, "just checking"); } template <class SpaceType> inline void CompactibleSpace::scan_and_compact(SpaceType* space) { // Copy all live objects to their new location
< prev index next >