< prev index next >

src/share/vm/gc/shenandoah/shenandoahHeap.hpp

Print this page
rev 14453 : Remove secondary marking bitmap.


 118     CANCELLED,
 119 
 120     // GC has not been cancelled and must not be cancelled. At least
 121     // one worker thread checks for pending safepoint and may suspend
 122     // if a safepoint is pending.
 123     NOT_CANCELLED
 124 
 125   };
 126 
 127 public:
 128   enum ShenandoahCancelCause {
 129     _oom_evacuation,
 130     _vm_stop,
 131   };
 132 private:
 133   ShenandoahHeapLock _lock;
 134   ShenandoahCollectorPolicy* _shenandoah_policy;
 135   size_t _bitmap_size;
 136   size_t _bitmap_words_per_region;
 137   MemRegion _heap_region;
 138   MemRegion _bitmap0_region;
 139   MemRegion _bitmap1_region;
 140 
 141   // Sortable array of regions
 142   ShenandoahHeapRegionSet* _ordered_regions;
 143   ShenandoahFreeSet* _free_regions;
 144   ShenandoahCollectionSet* _collection_set;
 145 
 146   ShenandoahConcurrentMark* _scm;
 147   ShenandoahPartialGC* _partial_gc;
 148   ShenandoahVerifier*  _verifier;
 149 
 150   ShenandoahConcurrentThread* _concurrent_gc_thread;
 151 
 152   ShenandoahMonitoringSupport* _monitoring_support;
 153 
 154   ShenandoahPhaseTimings*      _phase_timings;
 155   ShenandoahAllocTracker*      _alloc_tracker;
 156 
 157   size_t _num_regions;
 158   size_t _initial_size;
 159 
 160   uint _max_workers;
 161   ShenandoahWorkGang* _workers;
 162   ShenandoahWorkGang* _safepoint_workers;
 163 
 164   volatile size_t _used;
 165   volatile size_t _committed;
 166 
 167   MarkBitMap _verification_bit_map;
 168   MarkBitMap _mark_bit_map0;
 169   MarkBitMap _mark_bit_map1;
 170   MarkBitMap* _complete_mark_bit_map;
 171   MarkBitMap* _next_mark_bit_map;
 172 
 173   HeapWord** _complete_top_at_mark_starts;
 174   HeapWord** _complete_top_at_mark_starts_base;
 175 
 176   HeapWord** _next_top_at_mark_starts;
 177   HeapWord** _next_top_at_mark_starts_base;
 178 
 179   volatile jbyte _cancelled_concgc;
 180 
 181   size_t _bytes_allocated_since_cm;
 182   size_t _bytes_allocated_during_cm;
 183   size_t _allocated_last_gc;
 184   size_t _used_start_gc;
 185 
 186   char _concurrent_mark_in_progress;
 187 
 188   bool _full_gc_in_progress;
 189   bool _update_refs_in_progress;
 190   bool _concurrent_partial_in_progress;
 191 
 192   unsigned int _evacuation_in_progress;
 193   bool _need_update_refs;
 194   bool _need_reset_bitmaps;
 195 
 196   ReferenceProcessor* _ref_processor;
 197 
 198   ShenandoahForwardedIsAliveClosure _forwarded_is_alive;
 199   ShenandoahIsAliveClosure _is_alive;
 200 
 201   ConcurrentGCTimer* _gc_timer;
 202 
 203   // See allocate_memory()
 204   volatile jbyte _heap_lock;
 205 
 206   ShenandoahConnectionMatrix* _connection_matrix;
 207 
 208 #ifdef ASSERT
 209   Thread* volatile _heap_lock_owner;
 210   int     _heap_expansion_count;
 211 #endif
 212 
 213 public:
 214   ShenandoahHeap(ShenandoahCollectorPolicy* policy);


 328 
 329   void set_full_gc_in_progress(bool in_progress);
 330   bool is_full_gc_in_progress() const;
 331 
 332   void set_update_refs_in_progress(bool in_progress);
 333   bool is_update_refs_in_progress() const;
 334   static address update_refs_in_progress_addr();
 335 
 336   inline bool need_update_refs() const;
 337   void set_need_update_refs(bool update_refs);
 338 
 339   inline bool region_in_collection_set(size_t region_index) const;
 340 
 341   // Mainly there to avoid accidentally calling the templated
 342   // method below with ShenandoahHeapRegion* which would be *wrong*.
 343   inline bool in_collection_set(ShenandoahHeapRegion* r) const;
 344 
 345   template <class T>
 346   inline bool in_collection_set(T obj) const;
 347 
 348   inline bool allocated_after_next_mark_start(HeapWord* addr) const;
 349   void set_next_top_at_mark_start(HeapWord* region_base, HeapWord* addr);
 350   HeapWord* next_top_at_mark_start(HeapWord* region_base);
 351 
 352   inline bool allocated_after_complete_mark_start(HeapWord* addr) const;
 353   void set_complete_top_at_mark_start(HeapWord* region_base, HeapWord* addr);
 354   HeapWord* complete_top_at_mark_start(HeapWord* region_base);
 355 
 356   // Evacuates object src. Returns the evacuated object if this thread
 357   // succeeded, otherwise rolls back the evacuation and returns the
 358   // evacuated object by the competing thread. 'succeeded' is an out
 359   // param and set to true if this thread succeeded, otherwise to false.
 360   inline oop  evacuate_object(oop src, Thread* thread, bool& evacuated);
 361   inline bool cancelled_concgc() const;
 362   inline bool check_cancelled_concgc_and_yield(bool sts_active = true);
 363   inline bool try_cancel_concgc();
 364   inline void clear_cancelled_concgc();
 365 
 366   ShenandoahHeapRegionSet* regions() const { return _ordered_regions;}
 367   ShenandoahFreeSet* free_regions() const  { return _free_regions; }
 368   ShenandoahCollectionSet* collection_set() const { return _collection_set; }
 369   void clear_free_regions();
 370   void add_free_region(ShenandoahHeapRegion* r);
 371 
 372   ShenandoahConnectionMatrix* connection_matrix() const;
 373 
 374   void increase_used(size_t bytes);
 375   void decrease_used(size_t bytes);
 376 
 377   void set_used(size_t bytes);
 378 
 379   void increase_committed(size_t bytes);
 380   void decrease_committed(size_t bytes);
 381 
 382   void handle_heap_shrinkage();
 383 
 384   size_t garbage();
 385 
 386   void reset_next_mark_bitmap(WorkGang* gang);
 387   void reset_complete_mark_bitmap(WorkGang* gang);





 388 
 389   MarkBitMap* complete_mark_bit_map();
 390   MarkBitMap* next_mark_bit_map();
 391   inline bool is_marked_complete(oop obj) const;
 392   inline bool mark_next(oop obj) const;
 393   inline bool is_marked_next(oop obj) const;
 394   bool is_next_bitmap_clear();
 395   bool is_next_bitmap_clear_range(HeapWord* start, HeapWord* end);
 396   bool is_complete_bitmap_clear_range(HeapWord* start, HeapWord* end);
 397 
 398   bool commit_bitmaps(ShenandoahHeapRegion* r);
 399   bool uncommit_bitmaps(ShenandoahHeapRegion* r);
 400 
 401   template <class T>
 402   inline oop update_oop_ref_not_null(T* p, oop obj);
 403 
 404   template <class T>
 405   inline oop maybe_update_oop_ref_not_null(T* p, oop obj);
 406 
 407   void print_heap_regions_on(outputStream* st) const;
 408 
 409   size_t bytes_allocated_since_cm();
 410   void set_bytes_allocated_since_cm(size_t bytes);
 411 
 412   size_t trash_humongous_region_at(ShenandoahHeapRegion *r);
 413 
 414   ShenandoahMonitoringSupport* monitoring_support();
 415   ShenandoahConcurrentMark* concurrentMark() { return _scm;}
 416   ShenandoahPartialGC* partial_gc();


 442   inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit);
 443 
 444   template<class T>
 445   inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit);
 446 
 447 public:
 448   template<class T>
 449   inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl);
 450 
 451   template<class T>
 452   inline void marked_object_safe_iterate(ShenandoahHeapRegion* region, T* cl);
 453 
 454   template<class T>
 455   inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl);
 456 
 457   template<class T>
 458   inline void marked_object_oop_safe_iterate(ShenandoahHeapRegion* region, T* cl);
 459 
 460   GCTimer* gc_timer() const;
 461 
 462   void swap_mark_bitmaps();
 463 
 464   void cancel_concgc(GCCause::Cause cause);
 465   void cancel_concgc(ShenandoahCancelCause cause);
 466 
 467   ShenandoahHeapLock* lock() { return &_lock; }
 468   void assert_heaplock_owned_by_current_thread() PRODUCT_RETURN;
 469   void assert_heaplock_not_owned_by_current_thread() PRODUCT_RETURN;
 470   void assert_heaplock_or_safepoint() PRODUCT_RETURN;
 471 
 472 public:
 473   typedef enum {
 474     _alloc_shared,      // Allocate common, outside of TLAB
 475     _alloc_shared_gc,   // Allocate common, outside of GCLAB
 476     _alloc_tlab,        // Allocate TLAB
 477     _alloc_gclab,       // Allocate GCLAB
 478     _ALLOC_LIMIT,
 479   } AllocType;
 480 
 481   static const char* alloc_type_to_string(AllocType type) {
 482     switch (type) {
 483       case _alloc_shared:


 486         return "Shared GC";
 487       case _alloc_tlab:
 488         return "TLAB";
 489       case _alloc_gclab:
 490         return "GCLAB";
 491       default:
 492         ShouldNotReachHere();
 493         return "";
 494     }
 495   }
 496 private:
 497   HeapWord* allocate_new_lab(size_t word_size, AllocType type);
 498   HeapWord* allocate_memory_under_lock(size_t word_size, AllocType type, bool &new_region);
 499   HeapWord* allocate_memory(size_t word_size, AllocType type);
 500   // Shenandoah functionality.
 501   inline HeapWord* allocate_from_gclab(Thread* thread, size_t size);
 502   HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size);
 503   HeapWord* allocate_new_gclab(size_t word_size);
 504 
 505   template<class T>
 506   inline void do_marked_object(MarkBitMap* bitmap, T* cl, oop obj);
 507 
 508   ShenandoahConcurrentThread* concurrent_thread() { return _concurrent_gc_thread; }
 509 
 510   inline bool mark_next_no_checks(oop obj) const;
 511 
 512 public:
 513   inline oop atomic_compare_exchange_oop(oop n, narrowOop* addr, oop c);
 514   inline oop atomic_compare_exchange_oop(oop n, oop* addr, oop c);
 515 
 516 private:
 517   void ref_processing_init();
 518 
 519   GCTracer* tracer();
 520 
 521   void set_concurrent_mark_in_progress(bool in_progress);
 522 
 523   void oom_during_evacuation();
 524 
 525   HeapWord* allocate_large_memory(size_t word_size);
 526 
 527   const char* cancel_cause_to_string(ShenandoahCancelCause cause);
 528 
 529 private:
 530   size_t* _recycled_regions;
 531 
 532   uint64_t _alloc_seq_at_last_gc_start;
 533   uint64_t _alloc_seq_at_last_gc_end;
 534   size_t _used_at_last_gc;
 535 
 536 public:
 537   void recycle_trash_assist(size_t limit);
 538   void recycle_trash();
 539 
 540   uint64_t alloc_seq_at_last_gc_end()   const { return _alloc_seq_at_last_gc_end;  }
 541   uint64_t alloc_seq_at_last_gc_start() const { return _alloc_seq_at_last_gc_start;}
 542   size_t used_at_last_gc()              const { return _used_at_last_gc;}
 543 
 544   void set_alloc_seq_gc_start();
 545   void set_alloc_seq_gc_end();
 546 
 547   void set_used_at_last_gc() {_used_at_last_gc = used();}


 548 };
 549 
 550 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAP_HPP


 118     CANCELLED,
 119 
 120     // GC has not been cancelled and must not be cancelled. At least
 121     // one worker thread checks for pending safepoint and may suspend
 122     // if a safepoint is pending.
 123     NOT_CANCELLED
 124 
 125   };
 126 
 127 public:
 128   enum ShenandoahCancelCause {
 129     _oom_evacuation,
 130     _vm_stop,
 131   };
 132 private:
 133   ShenandoahHeapLock _lock;
 134   ShenandoahCollectorPolicy* _shenandoah_policy;
 135   size_t _bitmap_size;
 136   size_t _bitmap_words_per_region;
 137   MemRegion _heap_region;
 138   MemRegion _bitmap_region;
 139   MemRegion _aux_bitmap_region;
 140 
 141   // Sortable array of regions
 142   ShenandoahHeapRegionSet* _ordered_regions;
 143   ShenandoahFreeSet* _free_regions;
 144   ShenandoahCollectionSet* _collection_set;
 145 
 146   ShenandoahConcurrentMark* _scm;
 147   ShenandoahPartialGC* _partial_gc;
 148   ShenandoahVerifier*  _verifier;
 149 
 150   ShenandoahConcurrentThread* _concurrent_gc_thread;
 151 
 152   ShenandoahMonitoringSupport* _monitoring_support;
 153 
 154   ShenandoahPhaseTimings*      _phase_timings;
 155   ShenandoahAllocTracker*      _alloc_tracker;
 156 
 157   size_t _num_regions;
 158   size_t _initial_size;
 159 
 160   uint _max_workers;
 161   ShenandoahWorkGang* _workers;
 162   ShenandoahWorkGang* _safepoint_workers;
 163 
 164   volatile size_t _used;
 165   volatile size_t _committed;
 166 
 167   MarkBitMap _verification_bit_map;
 168   MarkBitMap _aux_bit_map;
 169   MarkBitMap _mark_bit_map;
 170   bool _bitmap_valid;

 171 
 172   HeapWord** _top_at_mark_starts;
 173   HeapWord** _top_at_mark_starts_base;



 174 
 175   volatile jbyte _cancelled_concgc;
 176 
 177   size_t _bytes_allocated_since_cm;
 178   size_t _bytes_allocated_during_cm;
 179   size_t _allocated_last_gc;
 180   size_t _used_start_gc;
 181 
 182   char _concurrent_mark_in_progress;
 183 
 184   bool _full_gc_in_progress;
 185   bool _update_refs_in_progress;
 186   bool _concurrent_partial_in_progress;
 187 
 188   unsigned int _evacuation_in_progress;
 189   bool _need_update_refs;
 190   bool _need_reset_bitmap;
 191 
 192   ReferenceProcessor* _ref_processor;
 193 
 194   ShenandoahForwardedIsAliveClosure _forwarded_is_alive;
 195   ShenandoahIsAliveClosure _is_alive;
 196 
 197   ConcurrentGCTimer* _gc_timer;
 198 
 199   // See allocate_memory()
 200   volatile jbyte _heap_lock;
 201 
 202   ShenandoahConnectionMatrix* _connection_matrix;
 203 
 204 #ifdef ASSERT
 205   Thread* volatile _heap_lock_owner;
 206   int     _heap_expansion_count;
 207 #endif
 208 
 209 public:
 210   ShenandoahHeap(ShenandoahCollectorPolicy* policy);


 324 
 325   void set_full_gc_in_progress(bool in_progress);
 326   bool is_full_gc_in_progress() const;
 327 
 328   void set_update_refs_in_progress(bool in_progress);
 329   bool is_update_refs_in_progress() const;
 330   static address update_refs_in_progress_addr();
 331 
 332   inline bool need_update_refs() const;
 333   void set_need_update_refs(bool update_refs);
 334 
 335   inline bool region_in_collection_set(size_t region_index) const;
 336 
 337   // Mainly there to avoid accidentally calling the templated
 338   // method below with ShenandoahHeapRegion* which would be *wrong*.
 339   inline bool in_collection_set(ShenandoahHeapRegion* r) const;
 340 
 341   template <class T>
 342   inline bool in_collection_set(T obj) const;
 343 
 344   inline bool allocated_after_mark_start(HeapWord* addr) const;
 345   void set_top_at_mark_start(HeapWord* region_base, HeapWord* addr);
 346   HeapWord* top_at_mark_start(HeapWord* region_base);




 347 
 348   // Evacuates object src. Returns the evacuated object if this thread
 349   // succeeded, otherwise rolls back the evacuation and returns the
 350   // evacuated object by the competing thread. 'succeeded' is an out
 351   // param and set to true if this thread succeeded, otherwise to false.
 352   inline oop  evacuate_object(oop src, Thread* thread, bool& evacuated);
 353   inline bool cancelled_concgc() const;
 354   inline bool check_cancelled_concgc_and_yield(bool sts_active = true);
 355   inline bool try_cancel_concgc();
 356   inline void clear_cancelled_concgc();
 357 
 358   ShenandoahHeapRegionSet* regions() const { return _ordered_regions;}
 359   ShenandoahFreeSet* free_regions() const  { return _free_regions; }
 360   ShenandoahCollectionSet* collection_set() const { return _collection_set; }
 361   void clear_free_regions();
 362   void add_free_region(ShenandoahHeapRegion* r);
 363 
 364   ShenandoahConnectionMatrix* connection_matrix() const;
 365 
 366   void increase_used(size_t bytes);
 367   void decrease_used(size_t bytes);
 368 
 369   void set_used(size_t bytes);
 370 
 371   void increase_committed(size_t bytes);
 372   void decrease_committed(size_t bytes);
 373 
 374   void handle_heap_shrinkage();
 375 
 376   size_t garbage();
 377 
 378   void reset_mark_bitmap(WorkGang* gang);
 379 
 380   MarkBitMap* mark_bit_map();
 381   inline bool is_marked(oop obj) const;
 382   inline bool mark(oop obj);
 383   bool is_bitmap_clear();
 384   bool is_bitmap_clear_range(HeapWord* start, HeapWord* end);
 385 
 386   bool is_bitmap_valid() const { return _bitmap_valid; }
 387   void set_bitmap_valid(bool valid) { _bitmap_valid = valid; }






 388 
 389   bool commit_bitmaps(ShenandoahHeapRegion* r);
 390   bool uncommit_bitmaps(ShenandoahHeapRegion* r);
 391 
 392   template <class T>
 393   inline oop update_oop_ref_not_null(T* p, oop obj);
 394 
 395   template <class T>
 396   inline oop maybe_update_oop_ref_not_null(T* p, oop obj);
 397 
 398   void print_heap_regions_on(outputStream* st) const;
 399 
 400   size_t bytes_allocated_since_cm();
 401   void set_bytes_allocated_since_cm(size_t bytes);
 402 
 403   size_t trash_humongous_region_at(ShenandoahHeapRegion *r);
 404 
 405   ShenandoahMonitoringSupport* monitoring_support();
 406   ShenandoahConcurrentMark* concurrentMark() { return _scm;}
 407   ShenandoahPartialGC* partial_gc();


 433   inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit);
 434 
 435   template<class T>
 436   inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit);
 437 
 438 public:
 439   template<class T>
 440   inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl);
 441 
 442   template<class T>
 443   inline void marked_object_safe_iterate(ShenandoahHeapRegion* region, T* cl);
 444 
 445   template<class T>
 446   inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl);
 447 
 448   template<class T>
 449   inline void marked_object_oop_safe_iterate(ShenandoahHeapRegion* region, T* cl);
 450 
 451   GCTimer* gc_timer() const;
 452 


 453   void cancel_concgc(GCCause::Cause cause);
 454   void cancel_concgc(ShenandoahCancelCause cause);
 455 
 456   ShenandoahHeapLock* lock() { return &_lock; }
 457   void assert_heaplock_owned_by_current_thread() PRODUCT_RETURN;
 458   void assert_heaplock_not_owned_by_current_thread() PRODUCT_RETURN;
 459   void assert_heaplock_or_safepoint() PRODUCT_RETURN;
 460 
 461 public:
 462   typedef enum {
 463     _alloc_shared,      // Allocate common, outside of TLAB
 464     _alloc_shared_gc,   // Allocate common, outside of GCLAB
 465     _alloc_tlab,        // Allocate TLAB
 466     _alloc_gclab,       // Allocate GCLAB
 467     _ALLOC_LIMIT,
 468   } AllocType;
 469 
 470   static const char* alloc_type_to_string(AllocType type) {
 471     switch (type) {
 472       case _alloc_shared:


 475         return "Shared GC";
 476       case _alloc_tlab:
 477         return "TLAB";
 478       case _alloc_gclab:
 479         return "GCLAB";
 480       default:
 481         ShouldNotReachHere();
 482         return "";
 483     }
 484   }
 485 private:
 486   HeapWord* allocate_new_lab(size_t word_size, AllocType type);
 487   HeapWord* allocate_memory_under_lock(size_t word_size, AllocType type, bool &new_region);
 488   HeapWord* allocate_memory(size_t word_size, AllocType type);
 489   // Shenandoah functionality.
 490   inline HeapWord* allocate_from_gclab(Thread* thread, size_t size);
 491   HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size);
 492   HeapWord* allocate_new_gclab(size_t word_size);
 493 
 494   template<class T>
 495   inline void do_marked_object(T* cl, oop obj);
 496 
 497   ShenandoahConcurrentThread* concurrent_thread() { return _concurrent_gc_thread; }
 498 
 499   inline bool mark_no_checks(oop obj);
 500 
 501 public:
 502   inline oop atomic_compare_exchange_oop(oop n, narrowOop* addr, oop c);
 503   inline oop atomic_compare_exchange_oop(oop n, oop* addr, oop c);
 504 
 505 private:
 506   void ref_processing_init();
 507 
 508   GCTracer* tracer();
 509 
 510   void set_concurrent_mark_in_progress(bool in_progress);
 511 
 512   void oom_during_evacuation();
 513 
 514   HeapWord* allocate_large_memory(size_t word_size);
 515 
 516   const char* cancel_cause_to_string(ShenandoahCancelCause cause);
 517 
 518 private:
 519   size_t* _recycled_regions;
 520 
 521   uint64_t _alloc_seq_at_last_gc_start;
 522   uint64_t _alloc_seq_at_last_gc_end;
 523   size_t _used_at_last_gc;
 524 
 525 public:
 526   void recycle_trash_assist(size_t limit);
 527   void recycle_trash();
 528 
 529   uint64_t alloc_seq_at_last_gc_end()   const { return _alloc_seq_at_last_gc_end;  }
 530   uint64_t alloc_seq_at_last_gc_start() const { return _alloc_seq_at_last_gc_start;}
 531   size_t used_at_last_gc()              const { return _used_at_last_gc;}
 532 
 533   void set_alloc_seq_gc_start();
 534   void set_alloc_seq_gc_end();
 535 
 536   void set_used_at_last_gc() {_used_at_last_gc = used();}
 537 
 538   void make_tlabs_parsable(bool retire_tlabs) /* override */;
 539 };
 540 
 541 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAP_HPP
< prev index next >