< prev index next >

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

Print this page

 723   template <class T>
 724   inline void do_oop_work(T* p) {
 725     T o = RawAccess<>::oop_load(p);
 726     if (!CompressedOops::is_null(o)) {
 727       oop obj = CompressedOops::decode_not_null(o);
 728       assert(_ctx->is_marked(obj), "must be marked");
 729       if (obj->is_forwarded()) {
 730         oop forw = obj->forwardee();
 731         RawAccess<IS_NOT_NULL>::oop_store(p, forw);
 732       }
 733     }
 734   }
 735 
 736 public:
 737   ShenandoahAdjustPointersClosure() :
 738     _heap(ShenandoahHeap::heap()),
 739     _ctx(ShenandoahHeap::heap()->complete_marking_context()) {}
 740 
 741   void do_oop(oop* p)       { do_oop_work(p); }
 742   void do_oop(narrowOop* p) { do_oop_work(p); }


 743 };
 744 
 745 class ShenandoahAdjustPointersObjectClosure : public ObjectClosure {
 746 private:
 747   ShenandoahHeap* const _heap;
 748   ShenandoahAdjustPointersClosure _cl;
 749 
 750 public:
 751   ShenandoahAdjustPointersObjectClosure() :
 752     _heap(ShenandoahHeap::heap()) {
 753   }
 754   void do_object(oop p) {
 755     assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
 756     p->oop_iterate(&_cl);
 757   }
 758 };
 759 
 760 class ShenandoahAdjustPointersTask : public WorkerTask {
 761 private:
 762   ShenandoahHeap*          const _heap;

 821 
 822   ShenandoahAdjustPointersTask adjust_pointers_task;
 823   workers->run_task(&adjust_pointers_task);
 824 }
 825 
 826 class ShenandoahCompactObjectsClosure : public ObjectClosure {
 827 private:
 828   ShenandoahHeap* const _heap;
 829   uint            const _worker_id;
 830 
 831 public:
 832   ShenandoahCompactObjectsClosure(uint worker_id) :
 833     _heap(ShenandoahHeap::heap()), _worker_id(worker_id) {}
 834 
 835   void do_object(oop p) {
 836     assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
 837     size_t size = (size_t)p->size();
 838     if (p->is_forwarded()) {
 839       HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
 840       HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
 841       Copy::aligned_conjoint_words(compact_from, compact_to, size);
 842       oop new_obj = cast_to_oop(compact_to);
 843       new_obj->init_mark();
 844     }
 845   }
 846 };
 847 
 848 class ShenandoahCompactObjectsTask : public WorkerTask {
 849 private:
 850   ShenandoahHeap* const _heap;
 851   ShenandoahHeapRegionSet** const _worker_slices;
 852 
 853 public:
 854   ShenandoahCompactObjectsTask(ShenandoahHeapRegionSet** worker_slices) :
 855     WorkerTask("Shenandoah Compact Objects"),
 856     _heap(ShenandoahHeap::heap()),
 857     _worker_slices(worker_slices) {
 858   }
 859 
 860   void work(uint worker_id) {
 861     ShenandoahParallelWorkerSession worker_session(worker_id);

 934   ShenandoahHeap* heap = ShenandoahHeap::heap();
 935 
 936   for (size_t c = heap->num_regions(); c > 0; c--) {
 937     ShenandoahHeapRegion* r = heap->get_region(c - 1);
 938     if (r->is_humongous_start()) {
 939       oop old_obj = cast_to_oop(r->bottom());
 940       if (!old_obj->is_forwarded()) {
 941         // No need to move the object, it stays at the same slot
 942         continue;
 943       }
 944       size_t words_size = old_obj->size();
 945       size_t num_regions = ShenandoahHeapRegion::required_regions(words_size * HeapWordSize);
 946 
 947       size_t old_start = r->index();
 948       size_t old_end   = old_start + num_regions - 1;
 949       size_t new_start = heap->heap_region_index_containing(old_obj->forwardee());
 950       size_t new_end   = new_start + num_regions - 1;
 951       assert(old_start != new_start, "must be real move");
 952       assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->index());
 953 
 954       Copy::aligned_conjoint_words(heap->get_region(old_start)->bottom(),
 955                                    heap->get_region(new_start)->bottom(),
 956                                    words_size);
 957 
 958       oop new_obj = cast_to_oop(heap->get_region(new_start)->bottom());
 959       new_obj->init_mark();
 960 
 961       {
 962         for (size_t c = old_start; c <= old_end; c++) {
 963           ShenandoahHeapRegion* r = heap->get_region(c);
 964           r->make_regular_bypass();
 965           r->set_top(r->bottom());
 966         }
 967 
 968         for (size_t c = new_start; c <= new_end; c++) {
 969           ShenandoahHeapRegion* r = heap->get_region(c);
 970           if (c == new_start) {
 971             r->make_humongous_start_bypass();
 972           } else {
 973             r->make_humongous_cont_bypass();
 974           }
 975 
 976           // Trailing region may be non-full, record the remainder there

 723   template <class T>
 724   inline void do_oop_work(T* p) {
 725     T o = RawAccess<>::oop_load(p);
 726     if (!CompressedOops::is_null(o)) {
 727       oop obj = CompressedOops::decode_not_null(o);
 728       assert(_ctx->is_marked(obj), "must be marked");
 729       if (obj->is_forwarded()) {
 730         oop forw = obj->forwardee();
 731         RawAccess<IS_NOT_NULL>::oop_store(p, forw);
 732       }
 733     }
 734   }
 735 
 736 public:
 737   ShenandoahAdjustPointersClosure() :
 738     _heap(ShenandoahHeap::heap()),
 739     _ctx(ShenandoahHeap::heap()->complete_marking_context()) {}
 740 
 741   void do_oop(oop* p)       { do_oop_work(p); }
 742   void do_oop(narrowOop* p) { do_oop_work(p); }
 743   void do_method(Method* m) {}
 744   void do_nmethod(nmethod* nm) {}
 745 };
 746 
 747 class ShenandoahAdjustPointersObjectClosure : public ObjectClosure {
 748 private:
 749   ShenandoahHeap* const _heap;
 750   ShenandoahAdjustPointersClosure _cl;
 751 
 752 public:
 753   ShenandoahAdjustPointersObjectClosure() :
 754     _heap(ShenandoahHeap::heap()) {
 755   }
 756   void do_object(oop p) {
 757     assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
 758     p->oop_iterate(&_cl);
 759   }
 760 };
 761 
 762 class ShenandoahAdjustPointersTask : public WorkerTask {
 763 private:
 764   ShenandoahHeap*          const _heap;

 823 
 824   ShenandoahAdjustPointersTask adjust_pointers_task;
 825   workers->run_task(&adjust_pointers_task);
 826 }
 827 
 828 class ShenandoahCompactObjectsClosure : public ObjectClosure {
 829 private:
 830   ShenandoahHeap* const _heap;
 831   uint            const _worker_id;
 832 
 833 public:
 834   ShenandoahCompactObjectsClosure(uint worker_id) :
 835     _heap(ShenandoahHeap::heap()), _worker_id(worker_id) {}
 836 
 837   void do_object(oop p) {
 838     assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
 839     size_t size = (size_t)p->size();
 840     if (p->is_forwarded()) {
 841       HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
 842       HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
 843       p->copy_conjoint(compact_to, size);
 844       oop new_obj = cast_to_oop(compact_to);
 845       new_obj->init_mark();
 846     }
 847   }
 848 };
 849 
 850 class ShenandoahCompactObjectsTask : public WorkerTask {
 851 private:
 852   ShenandoahHeap* const _heap;
 853   ShenandoahHeapRegionSet** const _worker_slices;
 854 
 855 public:
 856   ShenandoahCompactObjectsTask(ShenandoahHeapRegionSet** worker_slices) :
 857     WorkerTask("Shenandoah Compact Objects"),
 858     _heap(ShenandoahHeap::heap()),
 859     _worker_slices(worker_slices) {
 860   }
 861 
 862   void work(uint worker_id) {
 863     ShenandoahParallelWorkerSession worker_session(worker_id);

 936   ShenandoahHeap* heap = ShenandoahHeap::heap();
 937 
 938   for (size_t c = heap->num_regions(); c > 0; c--) {
 939     ShenandoahHeapRegion* r = heap->get_region(c - 1);
 940     if (r->is_humongous_start()) {
 941       oop old_obj = cast_to_oop(r->bottom());
 942       if (!old_obj->is_forwarded()) {
 943         // No need to move the object, it stays at the same slot
 944         continue;
 945       }
 946       size_t words_size = old_obj->size();
 947       size_t num_regions = ShenandoahHeapRegion::required_regions(words_size * HeapWordSize);
 948 
 949       size_t old_start = r->index();
 950       size_t old_end   = old_start + num_regions - 1;
 951       size_t new_start = heap->heap_region_index_containing(old_obj->forwardee());
 952       size_t new_end   = new_start + num_regions - 1;
 953       assert(old_start != new_start, "must be real move");
 954       assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->index());
 955 
 956       old_obj->copy_conjoint(heap->get_region(new_start)->bottom(),
 957                              words_size);

 958 
 959       oop new_obj = cast_to_oop(heap->get_region(new_start)->bottom());
 960       new_obj->init_mark();
 961 
 962       {
 963         for (size_t c = old_start; c <= old_end; c++) {
 964           ShenandoahHeapRegion* r = heap->get_region(c);
 965           r->make_regular_bypass();
 966           r->set_top(r->bottom());
 967         }
 968 
 969         for (size_t c = new_start; c <= new_end; c++) {
 970           ShenandoahHeapRegion* r = heap->get_region(c);
 971           if (c == new_start) {
 972             r->make_humongous_start_bypass();
 973           } else {
 974             r->make_humongous_cont_bypass();
 975           }
 976 
 977           // Trailing region may be non-full, record the remainder there
< prev index next >