< prev index next >

src/hotspot/share/gc/shared/space.cpp

Print this page

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/vmClasses.hpp"
 27 #include "classfile/vmSymbols.hpp"
 28 #include "gc/shared/collectedHeap.inline.hpp"
 29 #include "gc/shared/genCollectedHeap.hpp"

 30 #include "gc/shared/space.hpp"
 31 #include "gc/shared/space.inline.hpp"
 32 #include "gc/shared/spaceDecorator.inline.hpp"
 33 #include "memory/iterator.inline.hpp"
 34 #include "memory/universe.hpp"
 35 #include "oops/oop.inline.hpp"
 36 #include "runtime/atomic.hpp"
 37 #include "runtime/java.hpp"
 38 #include "runtime/prefetch.inline.hpp"
 39 #include "runtime/safepoint.hpp"
 40 #include "utilities/align.hpp"
 41 #include "utilities/copy.hpp"
 42 #include "utilities/globalDefinitions.hpp"
 43 #include "utilities/macros.hpp"
 44 #if INCLUDE_SERIALGC
 45 #include "gc/serial/serialBlockOffsetTable.inline.hpp"
 46 #include "gc/serial/defNewGeneration.hpp"
 47 #endif
 48 
 49 HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,

227 }
228 void ContiguousSpace::check_mangled_unused_area(HeapWord* limit) {
229   mangler()->check_mangled_unused_area(limit);
230 }
231 
232 void ContiguousSpace::check_mangled_unused_area_complete() {
233   mangler()->check_mangled_unused_area_complete();
234 }
235 
236 // Mangled only the unused space that has not previously
237 // been mangled and that has not been allocated since being
238 // mangled.
239 void ContiguousSpace::mangle_unused_area() {
240   mangler()->mangle_unused_area();
241 }
242 void ContiguousSpace::mangle_unused_area_complete() {
243   mangler()->mangle_unused_area_complete();
244 }
245 #endif  // NOT_PRODUCT
246 
247 
248 HeapWord* ContiguousSpace::forward(oop q, size_t size,
249                                     CompactPoint* cp, HeapWord* compact_top) {
250   // q is alive
251   // First check if we should switch compaction space
252   assert(this == cp->space, "'this' should be current compaction space.");
253   size_t compaction_max_size = pointer_delta(end(), compact_top);
254   while (size > compaction_max_size) {
255     // switch to next compaction space
256     cp->space->set_compaction_top(compact_top);
257     cp->space = cp->space->next_compaction_space();
258     if (cp->space == nullptr) {
259       cp->gen = GenCollectedHeap::heap()->young_gen();
260       assert(cp->gen != nullptr, "compaction must succeed");
261       cp->space = cp->gen->first_compaction_space();
262       assert(cp->space != nullptr, "generation must have a first compaction space");
263     }
264     compact_top = cp->space->bottom();
265     cp->space->set_compaction_top(compact_top);
266     cp->space->initialize_threshold();
267     compaction_max_size = pointer_delta(cp->space->end(), compact_top);
268   }
269 
270   // store the forwarding pointer into the mark word
271   if (cast_from_oop<HeapWord*>(q) != compact_top) {
272     q->forward_to(cast_to_oop(compact_top));
273     assert(q->is_gc_marked(), "encoding the pointer should preserve the mark");
274   } else {
275     // if the object isn't moving we can just set the mark to the default
276     // mark and handle it specially later on.
277     q->init_mark();
278     assert(!q->is_forwarded(), "should not be forwarded");
279   }
280 
281   compact_top += size;
282 
283   // We need to update the offset table so that the beginnings of objects can be
284   // found during scavenge.  Note that we are updating the offset table based on
285   // where the object will be once the compaction phase finishes.
286   cp->space->alloc_block(compact_top - size, compact_top);
287   return compact_top;
288 }
289 
290 #if INCLUDE_SERIALGC
291 
292 void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {

293   // Compute the new addresses for the live objects and store it in the mark
294   // Used by universe::mark_sweep_phase2()
295 
296   // We're sure to be here before any objects are compacted into this
297   // space, so this is a good time to initialize this:
298   set_compaction_top(bottom());
299 
300   if (cp->space == nullptr) {
301     assert(cp->gen != nullptr, "need a generation");
302     assert(cp->gen->first_compaction_space() == this, "just checking");
303     cp->space = cp->gen->first_compaction_space();
304     cp->space->initialize_threshold();
305     cp->space->set_compaction_top(cp->space->bottom());
306   }
307 
308   HeapWord* compact_top = cp->space->compaction_top(); // This is where we are currently compacting to.
309 
310   DeadSpacer dead_spacer(this);
311 
312   HeapWord*  end_of_live = bottom();  // One byte beyond the last byte of the last live object.
313   HeapWord*  first_dead = nullptr; // The first dead object.
314 
315   const intx interval = PrefetchScanIntervalInBytes;
316 
317   HeapWord* cur_obj = bottom();
318   HeapWord* scan_limit = top();
319 
320   while (cur_obj < scan_limit) {
321     if (cast_to_oop(cur_obj)->is_gc_marked()) {
322       // prefetch beyond cur_obj
323       Prefetch::write(cur_obj, interval);
324       size_t size = cast_to_oop(cur_obj)->size();
325       compact_top = cp->space->forward(cast_to_oop(cur_obj), size, cp, compact_top);
326       cur_obj += size;
327       end_of_live = cur_obj;
328     } else {
329       // run over all the contiguous dead objects
330       HeapWord* end = cur_obj;
331       do {
332         // prefetch beyond end
333         Prefetch::write(end, interval);
334         end += cast_to_oop(end)->size();
335       } while (end < scan_limit && !cast_to_oop(end)->is_gc_marked());
336 
337       // see if we might want to pretend this object is alive so that
338       // we don't have to compact quite as often.
339       if (cur_obj == compact_top && dead_spacer.insert_deadspace(cur_obj, end)) {
340         oop obj = cast_to_oop(cur_obj);
341         compact_top = cp->space->forward(obj, obj->size(), cp, compact_top);
342         end_of_live = end;
343       } else {
344         // otherwise, it really is a free region.
345 
346         // cur_obj is a pointer to a dead object. Use this dead memory to store a pointer to the next live object.
347         *(HeapWord**)cur_obj = end;
348 
349         // see if this is the first dead region.
350         if (first_dead == nullptr) {
351           first_dead = cur_obj;
352         }
353       }
354 
355       // move on to the next object
356       cur_obj = end;
357     }
358   }
359 
360   assert(cur_obj == scan_limit, "just checking");
361   _end_of_live = end_of_live;
362   if (first_dead != nullptr) {
363     _first_dead = first_dead;
364   } else {
365     _first_dead = end_of_live;
366   }
367 
368   // save the compaction_top of the compaction space.
369   cp->space->set_compaction_top(compact_top);
370 }
371 
372 void ContiguousSpace::adjust_pointers() {









373   // Check first is there is any work to do.
374   if (used() == 0) {
375     return;   // Nothing to do.
376   }
377 
378   // adjust all the interior pointers to point at the new locations of objects
379   // Used by MarkSweep::mark_sweep_phase3()
380 
381   HeapWord* cur_obj = bottom();
382   HeapWord* const end_of_live = _end_of_live;  // Established by prepare_for_compaction().
383   HeapWord* const first_dead = _first_dead;    // Established by prepare_for_compaction().
384 
385   assert(first_dead <= end_of_live, "Stands to reason, no?");
386 
387   const intx interval = PrefetchScanIntervalInBytes;
388 
389   debug_only(HeapWord* prev_obj = nullptr);
390   while (cur_obj < end_of_live) {
391     Prefetch::write(cur_obj, interval);
392     if (cur_obj < first_dead || cast_to_oop(cur_obj)->is_gc_marked()) {
393       // cur_obj is alive
394       // point all the oops to the new location
395       size_t size = MarkSweep::adjust_pointers(cast_to_oop(cur_obj));
396       debug_only(prev_obj = cur_obj);
397       cur_obj += size;
398     } else {
399       debug_only(prev_obj = cur_obj);
400       // cur_obj is not a live object, instead it points at the next live object
401       cur_obj = *(HeapWord**)cur_obj;
402       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));
403     }
404   }
405 
406   assert(cur_obj == end_of_live, "just checking");
407 }
408 
409 void ContiguousSpace::compact() {









410   // Copy all live objects to their new location
411   // Used by MarkSweep::mark_sweep_phase4()
412 
413   verify_up_to_first_dead(this);
414 
415   HeapWord* const start = bottom();
416   HeapWord* const end_of_live = _end_of_live;
417 
418   assert(_first_dead <= end_of_live, "Invariant. _first_dead: " PTR_FORMAT " <= end_of_live: " PTR_FORMAT, p2i(_first_dead), p2i(end_of_live));
419   if (_first_dead == end_of_live && (start == end_of_live || !cast_to_oop(start)->is_gc_marked())) {
420     // Nothing to compact. The space is either empty or all live object should be left in place.
421     clear_empty_region(this);
422     return;
423   }
424 
425   const intx scan_interval = PrefetchScanIntervalInBytes;
426   const intx copy_interval = PrefetchCopyIntervalInBytes;
427 
428   assert(start < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(start), p2i(end_of_live));
429   HeapWord* cur_obj = start;
430   if (_first_dead > cur_obj && !cast_to_oop(cur_obj)->is_gc_marked()) {
431     // All object before _first_dead can be skipped. They should not be moved.
432     // A pointer to the first live object is stored at the memory location for _first_dead.
433     cur_obj = *(HeapWord**)(_first_dead);
434   }
435 
436   debug_only(HeapWord* prev_obj = nullptr);
437   while (cur_obj < end_of_live) {
438     if (!cast_to_oop(cur_obj)->is_forwarded()) {
439       debug_only(prev_obj = cur_obj);
440       // The first word of the dead object contains a pointer to the next live object or end of space.
441       cur_obj = *(HeapWord**)cur_obj;
442       assert(cur_obj > prev_obj, "we should be moving forward through memory");
443     } else {
444       // prefetch beyond q
445       Prefetch::read(cur_obj, scan_interval);
446 
447       // size and destination
448       size_t size = cast_to_oop(cur_obj)->size();
449       HeapWord* compaction_top = cast_from_oop<HeapWord*>(cast_to_oop(cur_obj)->forwardee());
450 
451       // prefetch beyond compaction_top
452       Prefetch::write(compaction_top, copy_interval);
453 
454       // copy object and reinit its mark
455       assert(cur_obj != compaction_top, "everything in this pass should be moving");
456       Copy::aligned_conjoint_words(cur_obj, compaction_top, size);
457       oop new_obj = cast_to_oop(compaction_top);
458 
459       ContinuationGCSupport::transform_stack_chunk(new_obj);
460 
461       new_obj->init_mark();
462       assert(new_obj->klass() != nullptr, "should have a class");
463 
464       debug_only(prev_obj = cur_obj);
465       cur_obj += size;
466     }
467   }
468 
469   clear_empty_region(this);
470 }
471 








472 #endif // INCLUDE_SERIALGC
473 
474 void Space::print_short() const { print_short_on(tty); }
475 
476 void Space::print_short_on(outputStream* st) const {
477   st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K,
478               (int) ((double) used() * 100 / capacity()));
479 }
480 
481 void Space::print() const { print_on(tty); }
482 
483 void Space::print_on(outputStream* st) const {
484   print_short_on(st);
485   st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ")",
486                 p2i(bottom()), p2i(end()));
487 }
488 
489 void ContiguousSpace::print_on(outputStream* st) const {
490   print_short_on(st);
491   st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")",

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/vmClasses.hpp"
 27 #include "classfile/vmSymbols.hpp"
 28 #include "gc/shared/collectedHeap.inline.hpp"
 29 #include "gc/shared/genCollectedHeap.hpp"
 30 #include "gc/shared/slidingForwarding.inline.hpp"
 31 #include "gc/shared/space.hpp"
 32 #include "gc/shared/space.inline.hpp"
 33 #include "gc/shared/spaceDecorator.inline.hpp"
 34 #include "memory/iterator.inline.hpp"
 35 #include "memory/universe.hpp"
 36 #include "oops/oop.inline.hpp"
 37 #include "runtime/atomic.hpp"
 38 #include "runtime/java.hpp"
 39 #include "runtime/prefetch.inline.hpp"
 40 #include "runtime/safepoint.hpp"
 41 #include "utilities/align.hpp"
 42 #include "utilities/copy.hpp"
 43 #include "utilities/globalDefinitions.hpp"
 44 #include "utilities/macros.hpp"
 45 #if INCLUDE_SERIALGC
 46 #include "gc/serial/serialBlockOffsetTable.inline.hpp"
 47 #include "gc/serial/defNewGeneration.hpp"
 48 #endif
 49 
 50 HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,

228 }
229 void ContiguousSpace::check_mangled_unused_area(HeapWord* limit) {
230   mangler()->check_mangled_unused_area(limit);
231 }
232 
233 void ContiguousSpace::check_mangled_unused_area_complete() {
234   mangler()->check_mangled_unused_area_complete();
235 }
236 
237 // Mangled only the unused space that has not previously
238 // been mangled and that has not been allocated since being
239 // mangled.
240 void ContiguousSpace::mangle_unused_area() {
241   mangler()->mangle_unused_area();
242 }
243 void ContiguousSpace::mangle_unused_area_complete() {
244   mangler()->mangle_unused_area_complete();
245 }
246 #endif  // NOT_PRODUCT
247 
248 template <bool ALT_FWD>
249 HeapWord* ContiguousSpace::forward(oop q, size_t size,
250                                     CompactPoint* cp, HeapWord* compact_top) {
251   // q is alive
252   // First check if we should switch compaction space
253   assert(this == cp->space, "'this' should be current compaction space.");
254   size_t compaction_max_size = pointer_delta(end(), compact_top);
255   while (size > compaction_max_size) {
256     // switch to next compaction space
257     cp->space->set_compaction_top(compact_top);
258     cp->space = cp->space->next_compaction_space();
259     if (cp->space == nullptr) {
260       cp->gen = GenCollectedHeap::heap()->young_gen();
261       assert(cp->gen != nullptr, "compaction must succeed");
262       cp->space = cp->gen->first_compaction_space();
263       assert(cp->space != nullptr, "generation must have a first compaction space");
264     }
265     compact_top = cp->space->bottom();
266     cp->space->set_compaction_top(compact_top);
267     cp->space->initialize_threshold();
268     compaction_max_size = pointer_delta(cp->space->end(), compact_top);
269   }
270 
271   // store the forwarding pointer into the mark word
272   if (cast_from_oop<HeapWord*>(q) != compact_top) {
273     SlidingForwarding::forward_to<ALT_FWD>(q, cast_to_oop(compact_top));
274     assert(q->is_gc_marked(), "encoding the pointer should preserve the mark");
275   } else {
276     // if the object isn't moving we can just set the mark to the default
277     // mark and handle it specially later on.
278     q->init_mark();
279     assert(SlidingForwarding::is_not_forwarded(q), "should not be forwarded");
280   }
281 
282   compact_top += size;
283 
284   // We need to update the offset table so that the beginnings of objects can be
285   // found during scavenge.  Note that we are updating the offset table based on
286   // where the object will be once the compaction phase finishes.
287   cp->space->alloc_block(compact_top - size, compact_top);
288   return compact_top;
289 }
290 
291 #if INCLUDE_SERIALGC
292 
293 template <bool ALT_FWD>
294 void ContiguousSpace::prepare_for_compaction_impl(CompactPoint* cp) {
295   // Compute the new addresses for the live objects and store it in the mark
296   // Used by universe::mark_sweep_phase2()
297 
298   // We're sure to be here before any objects are compacted into this
299   // space, so this is a good time to initialize this:
300   set_compaction_top(bottom());
301 
302   if (cp->space == nullptr) {
303     assert(cp->gen != nullptr, "need a generation");
304     assert(cp->gen->first_compaction_space() == this, "just checking");
305     cp->space = cp->gen->first_compaction_space();
306     cp->space->initialize_threshold();
307     cp->space->set_compaction_top(cp->space->bottom());
308   }
309 
310   HeapWord* compact_top = cp->space->compaction_top(); // This is where we are currently compacting to.
311 
312   DeadSpacer dead_spacer(this);
313 
314   HeapWord*  end_of_live = bottom();  // One byte beyond the last byte of the last live object.
315   HeapWord*  first_dead = nullptr; // The first dead object.
316 
317   const intx interval = PrefetchScanIntervalInBytes;
318 
319   HeapWord* cur_obj = bottom();
320   HeapWord* scan_limit = top();
321 
322   while (cur_obj < scan_limit) {
323     if (cast_to_oop(cur_obj)->is_gc_marked()) {
324       // prefetch beyond cur_obj
325       Prefetch::write(cur_obj, interval);
326       size_t size = cast_to_oop(cur_obj)->size();
327       compact_top = cp->space->forward<ALT_FWD>(cast_to_oop(cur_obj), size, cp, compact_top);
328       cur_obj += size;
329       end_of_live = cur_obj;
330     } else {
331       // run over all the contiguous dead objects
332       HeapWord* end = cur_obj;
333       do {
334         // prefetch beyond end
335         Prefetch::write(end, interval);
336         end += cast_to_oop(end)->size();
337       } while (end < scan_limit && !cast_to_oop(end)->is_gc_marked());
338 
339       // see if we might want to pretend this object is alive so that
340       // we don't have to compact quite as often.
341       if (cur_obj == compact_top && dead_spacer.insert_deadspace(cur_obj, end)) {
342         oop obj = cast_to_oop(cur_obj);
343         compact_top = cp->space->forward<ALT_FWD>(obj, obj->size(), cp, compact_top);
344         end_of_live = end;
345       } else {
346         // otherwise, it really is a free region.
347 
348         // cur_obj is a pointer to a dead object. Use this dead memory to store a pointer to the next live object.
349         *(HeapWord**)cur_obj = end;
350 
351         // see if this is the first dead region.
352         if (first_dead == nullptr) {
353           first_dead = cur_obj;
354         }
355       }
356 
357       // move on to the next object
358       cur_obj = end;
359     }
360   }
361 
362   assert(cur_obj == scan_limit, "just checking");
363   _end_of_live = end_of_live;
364   if (first_dead != nullptr) {
365     _first_dead = first_dead;
366   } else {
367     _first_dead = end_of_live;
368   }
369 
370   // save the compaction_top of the compaction space.
371   cp->space->set_compaction_top(compact_top);
372 }
373 
374 void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
375   if (UseAltGCForwarding) {
376     prepare_for_compaction_impl<true>(cp);
377   } else {
378     prepare_for_compaction_impl<false>(cp);
379   }
380 }
381 
382 template <bool ALT_FWD>
383 void ContiguousSpace::adjust_pointers_impl() {
384   // Check first is there is any work to do.
385   if (used() == 0) {
386     return;   // Nothing to do.
387   }
388 
389   // adjust all the interior pointers to point at the new locations of objects
390   // Used by MarkSweep::mark_sweep_phase3()
391 
392   HeapWord* cur_obj = bottom();
393   HeapWord* const end_of_live = _end_of_live;  // Established by prepare_for_compaction().
394   HeapWord* const first_dead = _first_dead;    // Established by prepare_for_compaction().
395 
396   assert(first_dead <= end_of_live, "Stands to reason, no?");
397 
398   const intx interval = PrefetchScanIntervalInBytes;
399 
400   debug_only(HeapWord* prev_obj = nullptr);
401   while (cur_obj < end_of_live) {
402     Prefetch::write(cur_obj, interval);
403     if (cur_obj < first_dead || cast_to_oop(cur_obj)->is_gc_marked()) {
404       // cur_obj is alive
405       // point all the oops to the new location
406       size_t size = MarkSweep::adjust_pointers<ALT_FWD>(cast_to_oop(cur_obj));
407       debug_only(prev_obj = cur_obj);
408       cur_obj += size;
409     } else {
410       debug_only(prev_obj = cur_obj);
411       // cur_obj is not a live object, instead it points at the next live object
412       cur_obj = *(HeapWord**)cur_obj;
413       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));
414     }
415   }
416 
417   assert(cur_obj == end_of_live, "just checking");
418 }
419 
420 void ContiguousSpace::adjust_pointers() {
421   if (UseAltGCForwarding) {
422     adjust_pointers_impl<true>();
423   } else {
424     adjust_pointers_impl<false>();
425   }
426 }
427 
428 template <bool ALT_FWD>
429 void ContiguousSpace::compact_impl() {
430   // Copy all live objects to their new location
431   // Used by MarkSweep::mark_sweep_phase4()
432 
433   verify_up_to_first_dead(this);
434 
435   HeapWord* const start = bottom();
436   HeapWord* const end_of_live = _end_of_live;
437 
438   assert(_first_dead <= end_of_live, "Invariant. _first_dead: " PTR_FORMAT " <= end_of_live: " PTR_FORMAT, p2i(_first_dead), p2i(end_of_live));
439   if (_first_dead == end_of_live && (start == end_of_live || !cast_to_oop(start)->is_gc_marked())) {
440     // Nothing to compact. The space is either empty or all live object should be left in place.
441     clear_empty_region(this);
442     return;
443   }
444 
445   const intx scan_interval = PrefetchScanIntervalInBytes;
446   const intx copy_interval = PrefetchCopyIntervalInBytes;
447 
448   assert(start < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(start), p2i(end_of_live));
449   HeapWord* cur_obj = start;
450   if (_first_dead > cur_obj && !cast_to_oop(cur_obj)->is_gc_marked()) {
451     // All object before _first_dead can be skipped. They should not be moved.
452     // A pointer to the first live object is stored at the memory location for _first_dead.
453     cur_obj = *(HeapWord**)(_first_dead);
454   }
455 
456   debug_only(HeapWord* prev_obj = nullptr);
457   while (cur_obj < end_of_live) {
458     if (SlidingForwarding::is_not_forwarded(cast_to_oop(cur_obj))) {
459       debug_only(prev_obj = cur_obj);
460       // The first word of the dead object contains a pointer to the next live object or end of space.
461       cur_obj = *(HeapWord**)cur_obj;
462       assert(cur_obj > prev_obj, "we should be moving forward through memory");
463     } else {
464       // prefetch beyond q
465       Prefetch::read(cur_obj, scan_interval);
466 
467       // size and destination
468       size_t size = cast_to_oop(cur_obj)->size();
469       HeapWord* compaction_top = cast_from_oop<HeapWord*>(SlidingForwarding::forwardee<ALT_FWD>(cast_to_oop(cur_obj)));
470 
471       // prefetch beyond compaction_top
472       Prefetch::write(compaction_top, copy_interval);
473 
474       // copy object and reinit its mark
475       assert(cur_obj != compaction_top, "everything in this pass should be moving");
476       Copy::aligned_conjoint_words(cur_obj, compaction_top, size);
477       oop new_obj = cast_to_oop(compaction_top);
478 
479       ContinuationGCSupport::transform_stack_chunk(new_obj);
480 
481       new_obj->init_mark();
482       assert(new_obj->klass() != nullptr, "should have a class");
483 
484       debug_only(prev_obj = cur_obj);
485       cur_obj += size;
486     }
487   }
488 
489   clear_empty_region(this);
490 }
491 
492 void ContiguousSpace::compact() {
493   if (UseAltGCForwarding) {
494     compact_impl<true>();
495   } else {
496     compact_impl<false>();
497   }
498 }
499 
500 #endif // INCLUDE_SERIALGC
501 
502 void Space::print_short() const { print_short_on(tty); }
503 
504 void Space::print_short_on(outputStream* st) const {
505   st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K,
506               (int) ((double) used() * 100 / capacity()));
507 }
508 
509 void Space::print() const { print_on(tty); }
510 
511 void Space::print_on(outputStream* st) const {
512   print_short_on(st);
513   st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ")",
514                 p2i(bottom()), p2i(end()));
515 }
516 
517 void ContiguousSpace::print_on(outputStream* st) const {
518   print_short_on(st);
519   st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")",
< prev index next >