267 }
268
269 void PSMarkSweepDecorator::adjust_pointers() {
270 // adjust all the interior pointers to point at the new locations of objects
271 // Used by MarkSweep::mark_sweep_phase3()
272
273 HeapWord* q = space()->bottom();
274 HeapWord* t = _end_of_live; // Established by "prepare_for_compaction".
275
276 assert(_first_dead <= _end_of_live, "Stands to reason, no?");
277
278 if (q < t && _first_dead > q &&
279 !oop(q)->is_gc_marked()) {
280 // we have a chunk of the space which hasn't moved and we've
281 // reinitialized the mark word during the previous pass, so we can't
282 // use is_gc_marked for the traversal.
283 HeapWord* end = _first_dead;
284
285 while (q < end) {
286 // point all the oops to the new location
287 size_t size = oop(q)->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
288 q += size;
289 }
290
291 if (_first_dead == t) {
292 q = t;
293 } else {
294 // The first dead object should contain a pointer to the first live object
295 q = *(HeapWord**)_first_dead;
296 }
297 }
298 const intx interval = PrefetchScanIntervalInBytes;
299
300 debug_only(HeapWord* prev_q = NULL);
301 while (q < t) {
302 // prefetch beyond q
303 Prefetch::write(q, interval);
304 if (oop(q)->is_gc_marked()) {
305 // q is alive
306 // point all the oops to the new location
307 size_t size = oop(q)->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
308 debug_only(prev_q = q);
309 q += size;
310 } else {
311 debug_only(prev_q = q);
312 // The first dead object is no longer an object. At that memory address,
313 // there is a pointer to the first live object that the previous phase found.
314 q = *(HeapWord**)q;
315 assert(q > prev_q, "we should be moving forward through memory, q: " PTR_FORMAT ", prev_q: " PTR_FORMAT, p2i(q), p2i(prev_q));
316 }
317 }
318
319 assert(q == t, "just checking");
320 }
321
322 void PSMarkSweepDecorator::compact(bool mangle_free_space ) {
323 // Copy all live objects to their new location
324 // Used by MarkSweep::mark_sweep_phase4()
325
326 HeapWord* q = space()->bottom();
327 HeapWord* const t = _end_of_live;
|
267 }
268
269 void PSMarkSweepDecorator::adjust_pointers() {
270 // adjust all the interior pointers to point at the new locations of objects
271 // Used by MarkSweep::mark_sweep_phase3()
272
273 HeapWord* q = space()->bottom();
274 HeapWord* t = _end_of_live; // Established by "prepare_for_compaction".
275
276 assert(_first_dead <= _end_of_live, "Stands to reason, no?");
277
278 if (q < t && _first_dead > q &&
279 !oop(q)->is_gc_marked()) {
280 // we have a chunk of the space which hasn't moved and we've
281 // reinitialized the mark word during the previous pass, so we can't
282 // use is_gc_marked for the traversal.
283 HeapWord* end = _first_dead;
284
285 while (q < end) {
286 // point all the oops to the new location
287 size_t size = MarkSweep::adjust_pointers(oop(q));
288 q += size;
289 }
290
291 if (_first_dead == t) {
292 q = t;
293 } else {
294 // The first dead object should contain a pointer to the first live object
295 q = *(HeapWord**)_first_dead;
296 }
297 }
298 const intx interval = PrefetchScanIntervalInBytes;
299
300 debug_only(HeapWord* prev_q = NULL);
301 while (q < t) {
302 // prefetch beyond q
303 Prefetch::write(q, interval);
304 if (oop(q)->is_gc_marked()) {
305 // q is alive
306 // point all the oops to the new location
307 size_t size = MarkSweep::adjust_pointers(oop(q));
308 debug_only(prev_q = q);
309 q += size;
310 } else {
311 debug_only(prev_q = q);
312 // The first dead object is no longer an object. At that memory address,
313 // there is a pointer to the first live object that the previous phase found.
314 q = *(HeapWord**)q;
315 assert(q > prev_q, "we should be moving forward through memory, q: " PTR_FORMAT ", prev_q: " PTR_FORMAT, p2i(q), p2i(prev_q));
316 }
317 }
318
319 assert(q == t, "just checking");
320 }
321
322 void PSMarkSweepDecorator::compact(bool mangle_free_space ) {
323 // Copy all live objects to their new location
324 // Used by MarkSweep::mark_sweep_phase4()
325
326 HeapWord* q = space()->bottom();
327 HeapWord* const t = _end_of_live;
|