src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
changeset 54766 1321f8cf9de5
parent 54687 df2b3565f343
child 54780 f8d182aedc92
equal deleted inserted replaced
54765:cc6053cbd811 54766:1321f8cf9de5
    31 #include "gc/shared/parallelCleaning.hpp"
    31 #include "gc/shared/parallelCleaning.hpp"
    32 #include "gc/shared/plab.hpp"
    32 #include "gc/shared/plab.hpp"
    33 
    33 
    34 #include "gc/shenandoah/shenandoahAllocTracker.hpp"
    34 #include "gc/shenandoah/shenandoahAllocTracker.hpp"
    35 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
    35 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
    36 #include "gc/shenandoah/shenandoahBrooksPointer.hpp"
    36 #include "gc/shenandoah/shenandoahForwarding.hpp"
    37 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
    37 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
    38 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
    38 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
    39 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
    39 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
    40 #include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
    40 #include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
    41 #include "gc/shenandoah/shenandoahControlThread.hpp"
    41 #include "gc/shenandoah/shenandoahControlThread.hpp"
   131     }
   131     }
   132   }
   132   }
   133 };
   133 };
   134 
   134 
   135 jint ShenandoahHeap::initialize() {
   135 jint ShenandoahHeap::initialize() {
   136   ShenandoahBrooksPointer::initial_checks();
   136   ShenandoahForwarding::initial_checks();
   137 
   137 
   138   initialize_heuristics();
   138   initialize_heuristics();
   139 
   139 
   140   //
   140   //
   141   // Figure out heap sizing
   141   // Figure out heap sizing
   859 class ShenandoahMemAllocator : public MemAllocator {
   859 class ShenandoahMemAllocator : public MemAllocator {
   860 private:
   860 private:
   861   MemAllocator& _initializer;
   861   MemAllocator& _initializer;
   862 public:
   862 public:
   863   ShenandoahMemAllocator(MemAllocator& initializer, Klass* klass, size_t word_size, Thread* thread) :
   863   ShenandoahMemAllocator(MemAllocator& initializer, Klass* klass, size_t word_size, Thread* thread) :
   864   MemAllocator(klass, word_size + ShenandoahBrooksPointer::word_size(), thread),
   864   MemAllocator(klass, word_size + ShenandoahForwarding::word_size(), thread),
   865     _initializer(initializer) {}
   865     _initializer(initializer) {}
   866 
   866 
   867 protected:
   867 protected:
   868   virtual HeapWord* mem_allocate(Allocation& allocation) const {
   868   virtual HeapWord* mem_allocate(Allocation& allocation) const {
   869     HeapWord* result = MemAllocator::mem_allocate(allocation);
   869     HeapWord* result = MemAllocator::mem_allocate(allocation);
   870     // Initialize brooks-pointer
   870     // Initialize brooks-pointer
   871     if (result != NULL) {
   871     if (result != NULL) {
   872       result += ShenandoahBrooksPointer::word_size();
   872       result += ShenandoahForwarding::word_size();
   873       ShenandoahBrooksPointer::initialize(oop(result));
   873       ShenandoahForwarding::initialize(oop(result));
   874       assert(! ShenandoahHeap::heap()->in_collection_set(result), "never allocate in targetted region");
   874       assert(! ShenandoahHeap::heap()->in_collection_set(result), "never allocate in targetted region");
   875     }
   875     }
   876     return result;
   876     return result;
   877   }
   877   }
   878 
   878 
   945   HeapWord* obj = tlab_post_allocation_setup(start);
   945   HeapWord* obj = tlab_post_allocation_setup(start);
   946   CollectedHeap::fill_with_object(obj, end);
   946   CollectedHeap::fill_with_object(obj, end);
   947 }
   947 }
   948 
   948 
   949 size_t ShenandoahHeap::min_dummy_object_size() const {
   949 size_t ShenandoahHeap::min_dummy_object_size() const {
   950   return CollectedHeap::min_dummy_object_size() + ShenandoahBrooksPointer::word_size();
   950   return CollectedHeap::min_dummy_object_size() + ShenandoahForwarding::word_size();
   951 }
   951 }
   952 
   952 
   953 class ShenandoahConcurrentEvacuateRegionObjectClosure : public ObjectClosure {
   953 class ShenandoahConcurrentEvacuateRegionObjectClosure : public ObjectClosure {
   954 private:
   954 private:
   955   ShenandoahHeap* const _heap;
   955   ShenandoahHeap* const _heap;
  1038 }
  1038 }
  1039 
  1039 
  1040 void ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) {
  1040 void ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) {
  1041   assert(start->is_humongous_start(), "reclaim regions starting with the first one");
  1041   assert(start->is_humongous_start(), "reclaim regions starting with the first one");
  1042 
  1042 
  1043   oop humongous_obj = oop(start->bottom() + ShenandoahBrooksPointer::word_size());
  1043   oop humongous_obj = oop(start->bottom() + ShenandoahForwarding::word_size());
  1044   size_t size = humongous_obj->size() + ShenandoahBrooksPointer::word_size();
  1044   size_t size = humongous_obj->size() + ShenandoahForwarding::word_size();
  1045   size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
  1045   size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
  1046   size_t index = start->region_number() + required_regions - 1;
  1046   size_t index = start->region_number() + required_regions - 1;
  1047 
  1047 
  1048   assert(!start->has_live(), "liveness must be zero");
  1048   assert(!start->has_live(), "liveness must be zero");
  1049 
  1049 
  1852   set_gc_state_mask(EVACUATION, in_progress);
  1852   set_gc_state_mask(EVACUATION, in_progress);
  1853 }
  1853 }
  1854 
  1854 
  1855 HeapWord* ShenandoahHeap::tlab_post_allocation_setup(HeapWord* obj) {
  1855 HeapWord* ShenandoahHeap::tlab_post_allocation_setup(HeapWord* obj) {
  1856   // Initialize Brooks pointer for the next object
  1856   // Initialize Brooks pointer for the next object
  1857   HeapWord* result = obj + ShenandoahBrooksPointer::word_size();
  1857   HeapWord* result = obj + ShenandoahForwarding::word_size();
  1858   ShenandoahBrooksPointer::initialize(oop(result));
  1858   ShenandoahForwarding::initialize(oop(result));
  1859   return result;
  1859   return result;
  1860 }
  1860 }
  1861 
  1861 
  1862 void ShenandoahHeap::ref_processing_init() {
  1862 void ShenandoahHeap::ref_processing_init() {
  1863   assert(_max_workers > 0, "Sanity");
  1863   assert(_max_workers > 0, "Sanity");
  2822     }
  2822     }
  2823   }
  2823   }
  2824 }
  2824 }
  2825 
  2825 
  2826 size_t ShenandoahHeap::obj_size(oop obj) const {
  2826 size_t ShenandoahHeap::obj_size(oop obj) const {
  2827   return CollectedHeap::obj_size(obj) + ShenandoahBrooksPointer::word_size();
  2827   return CollectedHeap::obj_size(obj) + ShenandoahForwarding::word_size();
  2828 }
  2828 }
  2829 
  2829 
  2830 ptrdiff_t ShenandoahHeap::cell_header_size() const {
  2830 ptrdiff_t ShenandoahHeap::cell_header_size() const {
  2831   return ShenandoahBrooksPointer::byte_size();
  2831   return ShenandoahForwarding::byte_size();
  2832 }
  2832 }