< prev index next >

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

Print this page




  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP
  26 
  27 #include "gc/shared/markBitMap.hpp"
  28 #include "gc/shared/softRefPolicy.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "gc/shenandoah/shenandoahAsserts.hpp"
  31 #include "gc/shenandoah/shenandoahAllocRequest.hpp"
  32 #include "gc/shenandoah/shenandoahLock.hpp"
  33 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
  34 #include "gc/shenandoah/shenandoahSharedVariables.hpp"

  35 #include "services/memoryManager.hpp"
  36 
  37 class ConcurrentGCTimer;
  38 class ReferenceProcessor;
  39 class ShenandoahAllocTracker;
  40 class ShenandoahCollectorPolicy;
  41 class ShenandoahControlThread;
  42 class ShenandoahGCSession;
  43 class ShenandoahGCStateResetter;
  44 class ShenandoahHeuristics;
  45 class ShenandoahMarkingContext;
  46 class ShenandoahMarkCompact;
  47 class ShenandoahMode;
  48 class ShenandoahPhaseTimings;
  49 class ShenandoahHeap;
  50 class ShenandoahHeapRegion;
  51 class ShenandoahHeapRegionClosure;
  52 class ShenandoahCollectionSet;
  53 class ShenandoahFreeSet;
  54 class ShenandoahConcurrentMark;


 254 
 255     // Heap is under traversal collection
 256     TRAVERSAL_BITPOS  = 4
 257   };
 258 
 259   enum GCState {
 260     STABLE        = 0,
 261     HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS,
 262     MARKING       = 1 << MARKING_BITPOS,
 263     EVACUATION    = 1 << EVACUATION_BITPOS,
 264     UPDATEREFS    = 1 << UPDATEREFS_BITPOS,
 265     TRAVERSAL     = 1 << TRAVERSAL_BITPOS
 266   };
 267 
 268 private:
 269   ShenandoahSharedBitmap _gc_state;
 270   ShenandoahSharedFlag   _degenerated_gc_in_progress;
 271   ShenandoahSharedFlag   _full_gc_in_progress;
 272   ShenandoahSharedFlag   _full_gc_move_in_progress;
 273   ShenandoahSharedFlag   _progress_last_gc;

 274 
 275   void set_gc_state_all_threads(char state);
 276   void set_gc_state_mask(uint mask, bool value);
 277 
 278 public:
 279   char gc_state() const;
 280   static address gc_state_addr();
 281 
 282   void set_concurrent_mark_in_progress(bool in_progress);
 283   void set_evacuation_in_progress(bool in_progress);
 284   void set_update_refs_in_progress(bool in_progress);
 285   void set_degenerated_gc_in_progress(bool in_progress);
 286   void set_full_gc_in_progress(bool in_progress);
 287   void set_full_gc_move_in_progress(bool in_progress);
 288   void set_concurrent_traversal_in_progress(bool in_progress);
 289   void set_has_forwarded_objects(bool cond);

 290 
 291   inline bool is_stable() const;
 292   inline bool is_idle() const;
 293   inline bool is_concurrent_mark_in_progress() const;
 294   inline bool is_update_refs_in_progress() const;
 295   inline bool is_evacuation_in_progress() const;
 296   inline bool is_degenerated_gc_in_progress() const;
 297   inline bool is_full_gc_in_progress() const;
 298   inline bool is_full_gc_move_in_progress() const;
 299   inline bool is_concurrent_traversal_in_progress() const;
 300   inline bool has_forwarded_objects() const;
 301   inline bool is_gc_in_progress_mask(uint mask) const;


 302 
 303 // ---------- GC cancellation and degeneration machinery
 304 //
 305 // Cancelled GC flag is used to notify concurrent phases that they should terminate.
 306 //
 307 public:
 308   enum ShenandoahDegenPoint {
 309     _degenerated_unset,
 310     _degenerated_traversal,
 311     _degenerated_outside_cycle,
 312     _degenerated_mark,
 313     _degenerated_evac,
 314     _degenerated_updaterefs,
 315     _DEGENERATED_LIMIT
 316   };
 317 
 318   static const char* degen_point_to_string(ShenandoahDegenPoint point) {
 319     switch (point) {
 320       case _degenerated_unset:
 321         return "<UNSET>";


 494   GCTimer* gc_timer() const;
 495 
 496 // ---------- Reference processing
 497 //
 498 private:
 499   AlwaysTrueClosure    _subject_to_discovery;
 500   ReferenceProcessor*  _ref_processor;
 501   ShenandoahSharedFlag _process_references;
 502 
 503   void ref_processing_init();
 504 
 505 public:
 506   ReferenceProcessor* ref_processor() { return _ref_processor; }
 507   void set_process_references(bool pr);
 508   bool process_references() const;
 509 
 510 // ---------- Class Unloading
 511 //
 512 private:
 513   ShenandoahSharedFlag _unload_classes;

 514 
 515 public:
 516   void set_unload_classes(bool uc);
 517   bool unload_classes() const;
 518 
 519   // Perform STW class unloading and weak root cleaning
 520   void parallel_cleaning(bool full_gc);
 521 
 522 private:
 523   void stw_unload_classes(bool full_gc);
 524   void stw_process_weak_roots(bool full_gc);
 525 






 526 // ---------- Generic interface hooks
 527 // Minor things that super-interface expects us to implement to play nice with
 528 // the rest of runtime. Some of the things here are not required to be implemented,
 529 // and can be stubbed out.
 530 //
 531 public:
 532   AdaptiveSizePolicy* size_policy() shenandoah_not_implemented_return(NULL);
 533   bool is_maximal_no_gc() const shenandoah_not_implemented_return(false);
 534 
 535   bool is_in(const void* p) const;
 536 
 537   MemRegion reserved_region() const { return _reserved; }
 538   bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }
 539 
 540   void collect(GCCause::Cause cause);
 541   void do_full_collection(bool clear_all_soft_refs);
 542 
 543   // Used for parsing heap during error printing
 544   HeapWord* block_start(const void* addr) const;
 545   bool block_is_obj(const HeapWord* addr) const;
 546   bool print_location(outputStream* st, void* addr) const;
 547 
 548   // Used for native heap walkers: heap dumpers, mostly
 549   void object_iterate(ObjectClosure* cl);
 550   void safe_object_iterate(ObjectClosure* cl);
 551 
 552   // Used by RMI
 553   jlong millis_since_last_gc();
 554 
 555 // ---------- Safepoint interface hooks
 556 //
 557 public:
 558   void safepoint_synchronize_begin();
 559   void safepoint_synchronize_end();
 560 
 561 // ---------- Code roots handling hooks
 562 //
 563 public:
 564   void register_nmethod(nmethod* nm);
 565   void unregister_nmethod(nmethod* nm);
 566   void flush_nmethod(nmethod* nm) {}
 567   void verify_nmethod(nmethod* nm) {}
 568 
 569 // ---------- Pinning hooks
 570 //
 571 public:
 572   // Shenandoah supports per-object (per-region) pinning
 573   bool supports_object_pinning() const { return true; }
 574 
 575   oop pin_object(JavaThread* thread, oop obj);
 576   void unpin_object(JavaThread* thread, oop obj);
 577 
 578   void sync_pinned_region_status();
 579   void assert_pinned_region_status() NOT_DEBUG_RETURN;
 580 
 581 // ---------- Allocation support
 582 //
 583 private:
 584   HeapWord* allocate_memory_under_lock(ShenandoahAllocRequest& request, bool& in_new_region);
 585   inline HeapWord* allocate_from_gclab(Thread* thread, size_t size);
 586   HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size);




  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP
  26 
  27 #include "gc/shared/markBitMap.hpp"
  28 #include "gc/shared/softRefPolicy.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "gc/shenandoah/shenandoahAsserts.hpp"
  31 #include "gc/shenandoah/shenandoahAllocRequest.hpp"
  32 #include "gc/shenandoah/shenandoahLock.hpp"
  33 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
  34 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
  35 #include "gc/shenandoah/shenandoahUnload.hpp"
  36 #include "services/memoryManager.hpp"
  37 
  38 class ConcurrentGCTimer;
  39 class ReferenceProcessor;
  40 class ShenandoahAllocTracker;
  41 class ShenandoahCollectorPolicy;
  42 class ShenandoahControlThread;
  43 class ShenandoahGCSession;
  44 class ShenandoahGCStateResetter;
  45 class ShenandoahHeuristics;
  46 class ShenandoahMarkingContext;
  47 class ShenandoahMarkCompact;
  48 class ShenandoahMode;
  49 class ShenandoahPhaseTimings;
  50 class ShenandoahHeap;
  51 class ShenandoahHeapRegion;
  52 class ShenandoahHeapRegionClosure;
  53 class ShenandoahCollectionSet;
  54 class ShenandoahFreeSet;
  55 class ShenandoahConcurrentMark;


 255 
 256     // Heap is under traversal collection
 257     TRAVERSAL_BITPOS  = 4
 258   };
 259 
 260   enum GCState {
 261     STABLE        = 0,
 262     HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS,
 263     MARKING       = 1 << MARKING_BITPOS,
 264     EVACUATION    = 1 << EVACUATION_BITPOS,
 265     UPDATEREFS    = 1 << UPDATEREFS_BITPOS,
 266     TRAVERSAL     = 1 << TRAVERSAL_BITPOS
 267   };
 268 
 269 private:
 270   ShenandoahSharedBitmap _gc_state;
 271   ShenandoahSharedFlag   _degenerated_gc_in_progress;
 272   ShenandoahSharedFlag   _full_gc_in_progress;
 273   ShenandoahSharedFlag   _full_gc_move_in_progress;
 274   ShenandoahSharedFlag   _progress_last_gc;
 275   ShenandoahSharedFlag   _concurrent_root_in_progress;
 276 
 277   void set_gc_state_all_threads(char state);
 278   void set_gc_state_mask(uint mask, bool value);
 279 
 280 public:
 281   char gc_state() const;
 282   static address gc_state_addr();
 283 
 284   void set_concurrent_mark_in_progress(bool in_progress);
 285   void set_evacuation_in_progress(bool in_progress);
 286   void set_update_refs_in_progress(bool in_progress);
 287   void set_degenerated_gc_in_progress(bool in_progress);
 288   void set_full_gc_in_progress(bool in_progress);
 289   void set_full_gc_move_in_progress(bool in_progress);
 290   void set_concurrent_traversal_in_progress(bool in_progress);
 291   void set_has_forwarded_objects(bool cond);
 292   void set_concurrent_root_in_progress(bool cond);
 293 
 294   inline bool is_stable() const;
 295   inline bool is_idle() const;
 296   inline bool is_concurrent_mark_in_progress() const;
 297   inline bool is_update_refs_in_progress() const;
 298   inline bool is_evacuation_in_progress() const;
 299   inline bool is_degenerated_gc_in_progress() const;
 300   inline bool is_full_gc_in_progress() const;
 301   inline bool is_full_gc_move_in_progress() const;
 302   inline bool is_concurrent_traversal_in_progress() const;
 303   inline bool has_forwarded_objects() const;
 304   inline bool is_gc_in_progress_mask(uint mask) const;
 305   inline bool is_stw_gc_in_progress() const;
 306   inline bool is_concurrent_root_in_progress() const;
 307 
 308 // ---------- GC cancellation and degeneration machinery
 309 //
 310 // Cancelled GC flag is used to notify concurrent phases that they should terminate.
 311 //
 312 public:
 313   enum ShenandoahDegenPoint {
 314     _degenerated_unset,
 315     _degenerated_traversal,
 316     _degenerated_outside_cycle,
 317     _degenerated_mark,
 318     _degenerated_evac,
 319     _degenerated_updaterefs,
 320     _DEGENERATED_LIMIT
 321   };
 322 
 323   static const char* degen_point_to_string(ShenandoahDegenPoint point) {
 324     switch (point) {
 325       case _degenerated_unset:
 326         return "<UNSET>";


 499   GCTimer* gc_timer() const;
 500 
 501 // ---------- Reference processing
 502 //
 503 private:
 504   AlwaysTrueClosure    _subject_to_discovery;
 505   ReferenceProcessor*  _ref_processor;
 506   ShenandoahSharedFlag _process_references;
 507 
 508   void ref_processing_init();
 509 
 510 public:
 511   ReferenceProcessor* ref_processor() { return _ref_processor; }
 512   void set_process_references(bool pr);
 513   bool process_references() const;
 514 
 515 // ---------- Class Unloading
 516 //
 517 private:
 518   ShenandoahSharedFlag _unload_classes;
 519   ShenandoahUnload     _unloader;
 520 
 521 public:
 522   void set_unload_classes(bool uc);
 523   bool unload_classes() const;
 524 
 525   // Perform STW class unloading and weak root cleaning
 526   void parallel_cleaning(bool full_gc);
 527 
 528 private:
 529   void stw_unload_classes(bool full_gc);
 530   void stw_process_weak_roots(bool full_gc);
 531 
 532   // Prepare concurrent root processing
 533   void prepare_concurrent_roots();
 534   // Prepare and finish concurrent unloading
 535   void prepare_concurrent_unloading();
 536   void finish_concurrent_unloading();
 537 
 538 // ---------- Generic interface hooks
 539 // Minor things that super-interface expects us to implement to play nice with
 540 // the rest of runtime. Some of the things here are not required to be implemented,
 541 // and can be stubbed out.
 542 //
 543 public:
 544   AdaptiveSizePolicy* size_policy() shenandoah_not_implemented_return(NULL);
 545   bool is_maximal_no_gc() const shenandoah_not_implemented_return(false);
 546 
 547   bool is_in(const void* p) const;
 548 
 549   MemRegion reserved_region() const { return _reserved; }
 550   bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }
 551 
 552   void collect(GCCause::Cause cause);
 553   void do_full_collection(bool clear_all_soft_refs);
 554 
 555   // Used for parsing heap during error printing
 556   HeapWord* block_start(const void* addr) const;
 557   bool block_is_obj(const HeapWord* addr) const;
 558   bool print_location(outputStream* st, void* addr) const;
 559 
 560   // Used for native heap walkers: heap dumpers, mostly
 561   void object_iterate(ObjectClosure* cl);
 562   void safe_object_iterate(ObjectClosure* cl);
 563 
 564   // Used by RMI
 565   jlong millis_since_last_gc();
 566 
 567 // ---------- Safepoint interface hooks
 568 //
 569 public:
 570   void safepoint_synchronize_begin();
 571   void safepoint_synchronize_end();
 572 
 573 // ---------- Code roots handling hooks
 574 //
 575 public:
 576   void register_nmethod(nmethod* nm);
 577   void unregister_nmethod(nmethod* nm);
 578   void flush_nmethod(nmethod* nm);
 579   void verify_nmethod(nmethod* nm) {}
 580 
 581 // ---------- Pinning hooks
 582 //
 583 public:
 584   // Shenandoah supports per-object (per-region) pinning
 585   bool supports_object_pinning() const { return true; }
 586 
 587   oop pin_object(JavaThread* thread, oop obj);
 588   void unpin_object(JavaThread* thread, oop obj);
 589 
 590   void sync_pinned_region_status();
 591   void assert_pinned_region_status() NOT_DEBUG_RETURN;
 592 
 593 // ---------- Allocation support
 594 //
 595 private:
 596   HeapWord* allocate_memory_under_lock(ShenandoahAllocRequest& request, bool& in_new_region);
 597   inline HeapWord* allocate_from_gclab(Thread* thread, size_t size);
 598   HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size);


< prev index next >