< prev index next >

src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp

Print this page




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP
  27 
  28 #include "gc_implementation/g1/g1AllocationContext.hpp"
  29 #include "gc_implementation/g1/g1Allocator.hpp"
  30 #include "gc_implementation/g1/concurrentMark.hpp"
  31 #include "gc_implementation/g1/evacuationInfo.hpp"
  32 #include "gc_implementation/g1/g1AllocRegion.hpp"
  33 #include "gc_implementation/g1/g1BiasedArray.hpp"
  34 #include "gc_implementation/g1/g1HRPrinter.hpp"
  35 #include "gc_implementation/g1/g1InCSetState.hpp"
  36 #include "gc_implementation/g1/g1MonitoringSupport.hpp"
  37 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
  38 #include "gc_implementation/g1/g1YCTypes.hpp"
  39 #include "gc_implementation/g1/heapRegionManager.hpp"
  40 #include "gc_implementation/g1/heapRegionSet.hpp"

  41 #include "gc_implementation/shared/hSpaceCounters.hpp"
  42 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
  43 #include "memory/barrierSet.hpp"
  44 #include "memory/memRegion.hpp"
  45 #include "memory/sharedHeap.hpp"
  46 #include "utilities/stack.hpp"
  47 
  48 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot.
  49 // It uses the "Garbage First" heap organization and algorithm, which
  50 // may combine concurrent marking with parallel, incremental compaction of
  51 // heap subsets that will yield large amounts of garbage.
  52 
  53 // Forward declarations
  54 class HeapRegion;
  55 class HRRSCleanupTask;
  56 class GenerationSpec;
  57 class OopsInHeapRegionClosure;
  58 class G1KlassScanClosure;
  59 class G1ScanHeapEvacClosure;
  60 class ObjectClosure;
  61 class SpaceClosure;
  62 class CompactibleSpaceClosure;
  63 class Space;
  64 class G1CollectorPolicy;
  65 class GenRemSet;
  66 class G1RemSet;
  67 class HeapRegionRemSetIterator;
  68 class ConcurrentMark;
  69 class ConcurrentMarkThread;
  70 class ConcurrentG1Refine;
  71 class ConcurrentGCTimer;
  72 class GenerationCounters;
  73 class STWGCTimer;
  74 class G1NewTracer;
  75 class G1OldTracer;
  76 class EvacuationFailedInfo;
  77 class nmethod;
  78 class Ticks;
  79 
  80 typedef OverflowTaskQueue<StarTask, mtGC>         RefToScanQueue;
  81 typedef GenericTaskQueueSet<RefToScanQueue, mtGC> RefToScanQueueSet;
  82 
  83 typedef int RegionIdx_t;   // needs to hold [ 0..max_regions() )
  84 typedef int CardIdx_t;     // needs to hold [ 0..CardsPerRegion )
  85 
  86 class YoungList : public CHeapObj<mtGC> {
  87 private:
  88   G1CollectedHeap* _g1h;
  89 
  90   HeapRegion* _head;
  91 
  92   HeapRegion* _survivor_head;
  93   HeapRegion* _survivor_tail;
  94 
  95   HeapRegion* _curr;
  96 
  97   uint        _length;
  98   uint        _survivor_length;


 359   // called at the end of a GC and artificially expands the heap by
 360   // allocating a number of dead regions. This way we can induce very
 361   // frequent marking cycles and stress the cleanup / concurrent
 362   // cleanup code more (as all the regions that will be allocated by
 363   // this method will be found dead by the marking cycle).
 364   void allocate_dummy_regions() PRODUCT_RETURN;
 365 
 366   // Clear RSets after a compaction. It also resets the GC time stamps.
 367   void clear_rsets_post_compaction();
 368 
 369   // If the HR printer is active, dump the state of the regions in the
 370   // heap after a compaction.
 371   void print_hrm_post_compaction();
 372 
 373   // Create a memory mapper for auxiliary data structures of the given size and
 374   // translation factor.
 375   static G1RegionToSpaceMapper* create_aux_memory_mapper(const char* description,
 376                                                          size_t size,
 377                                                          size_t translation_factor);
 378 


 379   double verify(bool guard, const char* msg);
 380   void verify_before_gc();
 381   void verify_after_gc();
 382 
 383   void log_gc_header();
 384   void log_gc_footer(double pause_time_sec);
 385 
 386   // These are macros so that, if the assert fires, we get the correct
 387   // line number, file, etc.
 388 
 389 #define heap_locking_asserts_err_msg(_extra_message_)                         \
 390   err_msg("%s : Heap_lock locked: %s, at safepoint: %s, is VM thread: %s",    \
 391           (_extra_message_),                                                  \
 392           BOOL_TO_STR(Heap_lock->owned_by_self()),                            \
 393           BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()),               \
 394           BOOL_TO_STR(Thread::current()->is_VM_thread()))
 395 
 396 #define assert_heap_locked()                                                  \
 397   do {                                                                        \
 398     assert(Heap_lock->owned_by_self(),                                        \


1604   // information at the end of remark.
1605   // Currently there is only one place where this is called with
1606   // vo == UseMarkWord, which is to verify the marking during a
1607   // full GC.
1608   void verify(bool silent, VerifyOption vo);
1609 
1610   // Override; it uses the "prev" marking information
1611   virtual void verify(bool silent);
1612 
1613   // The methods below are here for convenience and dispatch the
1614   // appropriate method depending on value of the given VerifyOption
1615   // parameter. The values for that parameter, and their meanings,
1616   // are the same as those above.
1617 
1618   bool is_obj_dead_cond(const oop obj,
1619                         const HeapRegion* hr,
1620                         const VerifyOption vo) const;
1621 
1622   bool is_obj_dead_cond(const oop obj,
1623                         const VerifyOption vo) const;


1624 
1625   // Printing
1626 
1627   virtual void print_on(outputStream* st) const;
1628   virtual void print_extended_on(outputStream* st) const;
1629   virtual void print_on_error(outputStream* st) const;
1630 
1631   virtual void print_gc_threads_on(outputStream* st) const;
1632   virtual void gc_threads_do(ThreadClosure* tc) const;
1633 
1634   // Override
1635   void print_tracing_info() const;
1636 
1637   // The following two methods are helpful for debugging RSet issues.
1638   void print_cset_rsets() PRODUCT_RETURN;
1639   void print_all_rsets() PRODUCT_RETURN;
1640 
1641 public:
1642   size_t pending_card_num();
1643   size_t cards_scanned();


  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP
  27 
  28 #include "gc_implementation/g1/g1AllocationContext.hpp"
  29 #include "gc_implementation/g1/g1Allocator.hpp"
  30 #include "gc_implementation/g1/concurrentMark.hpp"
  31 #include "gc_implementation/g1/evacuationInfo.hpp"
  32 #include "gc_implementation/g1/g1AllocRegion.hpp"
  33 #include "gc_implementation/g1/g1BiasedArray.hpp"
  34 #include "gc_implementation/g1/g1HRPrinter.hpp"
  35 #include "gc_implementation/g1/g1InCSetState.hpp"
  36 #include "gc_implementation/g1/g1MonitoringSupport.hpp"
  37 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
  38 #include "gc_implementation/g1/g1YCTypes.hpp"
  39 #include "gc_implementation/g1/heapRegionManager.hpp"
  40 #include "gc_implementation/g1/heapRegionSet.hpp"
  41 #include "gc_implementation/shared/gcHeapSummary.hpp"
  42 #include "gc_implementation/shared/hSpaceCounters.hpp"
  43 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
  44 #include "memory/barrierSet.hpp"
  45 #include "memory/memRegion.hpp"
  46 #include "memory/sharedHeap.hpp"
  47 #include "utilities/stack.hpp"
  48 
  49 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot.
  50 // It uses the "Garbage First" heap organization and algorithm, which
  51 // may combine concurrent marking with parallel, incremental compaction of
  52 // heap subsets that will yield large amounts of garbage.
  53 
  54 // Forward declarations
  55 class HeapRegion;
  56 class HRRSCleanupTask;
  57 class GenerationSpec;
  58 class OopsInHeapRegionClosure;
  59 class G1KlassScanClosure;
  60 class G1ScanHeapEvacClosure;
  61 class ObjectClosure;
  62 class SpaceClosure;
  63 class CompactibleSpaceClosure;
  64 class Space;
  65 class G1CollectorPolicy;
  66 class GenRemSet;
  67 class G1RemSet;
  68 class HeapRegionRemSetIterator;
  69 class ConcurrentMark;
  70 class ConcurrentMarkThread;
  71 class ConcurrentG1Refine;
  72 class ConcurrentGCTimer;
  73 class GenerationCounters;
  74 class STWGCTimer;
  75 class G1NewTracer;
  76 class G1OldTracer;
  77 class EvacuationFailedInfo;
  78 class nmethod;

  79 
  80 typedef OverflowTaskQueue<StarTask, mtGC>         RefToScanQueue;
  81 typedef GenericTaskQueueSet<RefToScanQueue, mtGC> RefToScanQueueSet;
  82 
  83 typedef int RegionIdx_t;   // needs to hold [ 0..max_regions() )
  84 typedef int CardIdx_t;     // needs to hold [ 0..CardsPerRegion )
  85 
  86 class YoungList : public CHeapObj<mtGC> {
  87 private:
  88   G1CollectedHeap* _g1h;
  89 
  90   HeapRegion* _head;
  91 
  92   HeapRegion* _survivor_head;
  93   HeapRegion* _survivor_tail;
  94 
  95   HeapRegion* _curr;
  96 
  97   uint        _length;
  98   uint        _survivor_length;


 359   // called at the end of a GC and artificially expands the heap by
 360   // allocating a number of dead regions. This way we can induce very
 361   // frequent marking cycles and stress the cleanup / concurrent
 362   // cleanup code more (as all the regions that will be allocated by
 363   // this method will be found dead by the marking cycle).
 364   void allocate_dummy_regions() PRODUCT_RETURN;
 365 
 366   // Clear RSets after a compaction. It also resets the GC time stamps.
 367   void clear_rsets_post_compaction();
 368 
 369   // If the HR printer is active, dump the state of the regions in the
 370   // heap after a compaction.
 371   void print_hrm_post_compaction();
 372 
 373   // Create a memory mapper for auxiliary data structures of the given size and
 374   // translation factor.
 375   static G1RegionToSpaceMapper* create_aux_memory_mapper(const char* description,
 376                                                          size_t size,
 377                                                          size_t translation_factor);
 378 
 379   void trace_heap(GCWhen::Type when, GCTracer* tracer);
 380 
 381   double verify(bool guard, const char* msg);
 382   void verify_before_gc();
 383   void verify_after_gc();
 384 
 385   void log_gc_header();
 386   void log_gc_footer(double pause_time_sec);
 387 
 388   // These are macros so that, if the assert fires, we get the correct
 389   // line number, file, etc.
 390 
 391 #define heap_locking_asserts_err_msg(_extra_message_)                         \
 392   err_msg("%s : Heap_lock locked: %s, at safepoint: %s, is VM thread: %s",    \
 393           (_extra_message_),                                                  \
 394           BOOL_TO_STR(Heap_lock->owned_by_self()),                            \
 395           BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()),               \
 396           BOOL_TO_STR(Thread::current()->is_VM_thread()))
 397 
 398 #define assert_heap_locked()                                                  \
 399   do {                                                                        \
 400     assert(Heap_lock->owned_by_self(),                                        \


1606   // information at the end of remark.
1607   // Currently there is only one place where this is called with
1608   // vo == UseMarkWord, which is to verify the marking during a
1609   // full GC.
1610   void verify(bool silent, VerifyOption vo);
1611 
1612   // Override; it uses the "prev" marking information
1613   virtual void verify(bool silent);
1614 
1615   // The methods below are here for convenience and dispatch the
1616   // appropriate method depending on value of the given VerifyOption
1617   // parameter. The values for that parameter, and their meanings,
1618   // are the same as those above.
1619 
1620   bool is_obj_dead_cond(const oop obj,
1621                         const HeapRegion* hr,
1622                         const VerifyOption vo) const;
1623 
1624   bool is_obj_dead_cond(const oop obj,
1625                         const VerifyOption vo) const;
1626 
1627   G1HeapSummary create_g1_heap_summary();
1628 
1629   // Printing
1630 
1631   virtual void print_on(outputStream* st) const;
1632   virtual void print_extended_on(outputStream* st) const;
1633   virtual void print_on_error(outputStream* st) const;
1634 
1635   virtual void print_gc_threads_on(outputStream* st) const;
1636   virtual void gc_threads_do(ThreadClosure* tc) const;
1637 
1638   // Override
1639   void print_tracing_info() const;
1640 
1641   // The following two methods are helpful for debugging RSet issues.
1642   void print_cset_rsets() PRODUCT_RETURN;
1643   void print_all_rsets() PRODUCT_RETURN;
1644 
1645 public:
1646   size_t pending_card_num();
1647   size_t cards_scanned();
< prev index next >