< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp

Print this page
*** 26,10 ***
--- 26,11 ---
  
  #include "compiler/oopMap.hpp"
  #include "gc/shared/continuationGCSupport.hpp"
  #include "gc/shared/gcTraceTime.inline.hpp"
  #include "gc/shared/preservedMarks.inline.hpp"
+ #include "gc/shared/slidingForwarding.inline.hpp"
  #include "gc/shared/tlab_globals.hpp"
  #include "gc/shared/workerThread.hpp"
  #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
  #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  #include "gc/shenandoah/shenandoahConcurrentGC.hpp"

*** 226,19 ***
--- 227,23 ---
    {
      // The rest of code performs region moves, where region status is undefined
      // until all phases run together.
      ShenandoahHeapLocker lock(heap->lock());
  
+     SlidingForwarding::begin();
+ 
      phase2_calculate_target_addresses(worker_slices);
  
      OrderAccess::fence();
  
      phase3_update_references();
  
      phase4_compact_objects(worker_slices);
  
      phase5_epilog();
+ 
+     SlidingForwarding::end();
    }
  
    // Resize metaspace
    MetaspaceGC::compute_new_size();
  

*** 367,11 ***
      // Object fits into current region, record new location, if object does not move:
      assert(_compact_point + obj_size <= _to_region->end(), "must fit");
      shenandoah_assert_not_forwarded(nullptr, p);
      if (_compact_point != cast_from_oop<HeapWord*>(p)) {
        _preserved_marks->push_if_necessary(p, p->mark());
!       p->forward_to(cast_to_oop(_compact_point));
      }
      _compact_point += obj_size;
    }
  };
  
--- 372,11 ---
      // Object fits into current region, record new location, if object does not move:
      assert(_compact_point + obj_size <= _to_region->end(), "must fit");
      shenandoah_assert_not_forwarded(nullptr, p);
      if (_compact_point != cast_from_oop<HeapWord*>(p)) {
        _preserved_marks->push_if_necessary(p, p->mark());
!       SlidingForwarding::forward_to(p, cast_to_oop(_compact_point));
      }
      _compact_point += obj_size;
    }
  };
  

*** 490,11 ***
        size_t start = to_end - num_regions;
  
        if (start >= to_begin && start != r->index()) {
          // Fits into current window, and the move is non-trivial. Record the move then, and continue scan.
          _preserved_marks->get(0)->push_if_necessary(old_obj, old_obj->mark());
!         old_obj->forward_to(cast_to_oop(heap->get_region(start)->bottom()));
          to_end = start;
          continue;
        }
      }
  
--- 495,11 ---
        size_t start = to_end - num_regions;
  
        if (start >= to_begin && start != r->index()) {
          // Fits into current window, and the move is non-trivial. Record the move then, and continue scan.
          _preserved_marks->get(0)->push_if_necessary(old_obj, old_obj->mark());
!         SlidingForwarding::forward_to(old_obj, cast_to_oop(heap->get_region(start)->bottom()));
          to_end = start;
          continue;
        }
      }
  

*** 750,12 ***
    inline void do_oop_work(T* p) {
      T o = RawAccess<>::oop_load(p);
      if (!CompressedOops::is_null(o)) {
        oop obj = CompressedOops::decode_not_null(o);
        assert(_ctx->is_marked(obj), "must be marked");
!       if (obj->is_forwarded()) {
!         oop forw = obj->forwardee();
          RawAccess<IS_NOT_NULL>::oop_store(p, forw);
        }
      }
    }
  
--- 755,12 ---
    inline void do_oop_work(T* p) {
      T o = RawAccess<>::oop_load(p);
      if (!CompressedOops::is_null(o)) {
        oop obj = CompressedOops::decode_not_null(o);
        assert(_ctx->is_marked(obj), "must be marked");
!       if (SlidingForwarding::is_forwarded(obj)) {
!         oop forw = SlidingForwarding::forwardee(obj);
          RawAccess<IS_NOT_NULL>::oop_store(p, forw);
        }
      }
    }
  

*** 861,13 ***
      _heap(ShenandoahHeap::heap()), _worker_id(worker_id) {}
  
    void do_object(oop p) {
      assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
      size_t size = p->size();
!     if (p->is_forwarded()) {
        HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
!       HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
        assert(compact_from != compact_to, "Forwarded object should move");
        Copy::aligned_conjoint_words(compact_from, compact_to, size);
        oop new_obj = cast_to_oop(compact_to);
  
        ContinuationGCSupport::relativize_stack_chunk(new_obj);
--- 866,13 ---
      _heap(ShenandoahHeap::heap()), _worker_id(worker_id) {}
  
    void do_object(oop p) {
      assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
      size_t size = p->size();
!     if (SlidingForwarding::is_forwarded(p)) {
        HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
!       HeapWord* compact_to = cast_from_oop<HeapWord*>(SlidingForwarding::forwardee(p));
        assert(compact_from != compact_to, "Forwarded object should move");
        Copy::aligned_conjoint_words(compact_from, compact_to, size);
        oop new_obj = cast_to_oop(compact_to);
  
        ContinuationGCSupport::relativize_stack_chunk(new_obj);

*** 969,20 ***
  
    for (size_t c = heap->num_regions(); c > 0; c--) {
      ShenandoahHeapRegion* r = heap->get_region(c - 1);
      if (r->is_humongous_start()) {
        oop old_obj = cast_to_oop(r->bottom());
!       if (!old_obj->is_forwarded()) {
          // No need to move the object, it stays at the same slot
          continue;
        }
        size_t words_size = old_obj->size();
        size_t num_regions = ShenandoahHeapRegion::required_regions(words_size * HeapWordSize);
  
        size_t old_start = r->index();
        size_t old_end   = old_start + num_regions - 1;
!       size_t new_start = heap->heap_region_index_containing(old_obj->forwardee());
        size_t new_end   = new_start + num_regions - 1;
        assert(old_start != new_start, "must be real move");
        assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->index());
  
        Copy::aligned_conjoint_words(r->bottom(), heap->get_region(new_start)->bottom(), words_size);
--- 974,20 ---
  
    for (size_t c = heap->num_regions(); c > 0; c--) {
      ShenandoahHeapRegion* r = heap->get_region(c - 1);
      if (r->is_humongous_start()) {
        oop old_obj = cast_to_oop(r->bottom());
!       if (SlidingForwarding::is_not_forwarded(old_obj)) {
          // No need to move the object, it stays at the same slot
          continue;
        }
        size_t words_size = old_obj->size();
        size_t num_regions = ShenandoahHeapRegion::required_regions(words_size * HeapWordSize);
  
        size_t old_start = r->index();
        size_t old_end   = old_start + num_regions - 1;
!       size_t new_start = heap->heap_region_index_containing(SlidingForwarding::forwardee(old_obj));
        size_t new_end   = new_start + num_regions - 1;
        assert(old_start != new_start, "must be real move");
        assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->index());
  
        Copy::aligned_conjoint_words(r->bottom(), heap->get_region(new_start)->bottom(), words_size);
< prev index next >