src/hotspot/share/gc/g1/g1CollectedHeap.hpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54934 39814e0a8964
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    29 #include "gc/g1/g1BiasedArray.hpp"
    29 #include "gc/g1/g1BiasedArray.hpp"
    30 #include "gc/g1/g1CardTable.hpp"
    30 #include "gc/g1/g1CardTable.hpp"
    31 #include "gc/g1/g1CollectionSet.hpp"
    31 #include "gc/g1/g1CollectionSet.hpp"
    32 #include "gc/g1/g1CollectorState.hpp"
    32 #include "gc/g1/g1CollectorState.hpp"
    33 #include "gc/g1/g1ConcurrentMark.hpp"
    33 #include "gc/g1/g1ConcurrentMark.hpp"
    34 #include "gc/g1/g1DirtyCardQueue.hpp"
       
    35 #include "gc/g1/g1EdenRegions.hpp"
    34 #include "gc/g1/g1EdenRegions.hpp"
    36 #include "gc/g1/g1EvacFailure.hpp"
    35 #include "gc/g1/g1EvacFailure.hpp"
    37 #include "gc/g1/g1EvacStats.hpp"
    36 #include "gc/g1/g1EvacStats.hpp"
    38 #include "gc/g1/g1EvacuationInfo.hpp"
    37 #include "gc/g1/g1EvacuationInfo.hpp"
    39 #include "gc/g1/g1GCPhaseTimes.hpp"
    38 #include "gc/g1/g1GCPhaseTimes.hpp"
    40 #include "gc/g1/g1HeapTransition.hpp"
    39 #include "gc/g1/g1HeapTransition.hpp"
    41 #include "gc/g1/g1HeapVerifier.hpp"
    40 #include "gc/g1/g1HeapVerifier.hpp"
    42 #include "gc/g1/g1HRPrinter.hpp"
    41 #include "gc/g1/g1HRPrinter.hpp"
    43 #include "gc/g1/g1HeapRegionAttr.hpp"
    42 #include "gc/g1/g1HeapRegionAttr.hpp"
    44 #include "gc/g1/g1MonitoringSupport.hpp"
    43 #include "gc/g1/g1MonitoringSupport.hpp"
       
    44 #include "gc/g1/g1RedirtyCardsQueue.hpp"
    45 #include "gc/g1/g1SurvivorRegions.hpp"
    45 #include "gc/g1/g1SurvivorRegions.hpp"
    46 #include "gc/g1/g1YCTypes.hpp"
    46 #include "gc/g1/g1YCTypes.hpp"
    47 #include "gc/g1/heapRegionManager.hpp"
    47 #include "gc/g1/heapRegionManager.hpp"
    48 #include "gc/g1/heapRegionSet.hpp"
    48 #include "gc/g1/heapRegionSet.hpp"
    49 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
    49 #include "gc/g1/heterogeneousHeapRegionManager.hpp"
    71 class MemoryManager;
    71 class MemoryManager;
    72 class ObjectClosure;
    72 class ObjectClosure;
    73 class SpaceClosure;
    73 class SpaceClosure;
    74 class CompactibleSpaceClosure;
    74 class CompactibleSpaceClosure;
    75 class Space;
    75 class Space;
       
    76 class G1CardTableEntryClosure;
    76 class G1CollectionSet;
    77 class G1CollectionSet;
    77 class G1Policy;
    78 class G1Policy;
    78 class G1HotCardCache;
    79 class G1HotCardCache;
    79 class G1RemSet;
    80 class G1RemSet;
    80 class G1YoungRemSetSamplingThread;
    81 class G1YoungRemSetSamplingThread;
    81 class HeapRegionRemSetIterator;
       
    82 class G1ConcurrentMark;
    82 class G1ConcurrentMark;
    83 class G1ConcurrentMarkThread;
    83 class G1ConcurrentMarkThread;
    84 class G1ConcurrentRefine;
    84 class G1ConcurrentRefine;
    85 class GenerationCounters;
    85 class GenerationCounters;
    86 class STWGCTimer;
    86 class STWGCTimer;
   127  public:
   127  public:
   128   virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
   128   virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
   129 };
   129 };
   130 
   130 
   131 class G1CollectedHeap : public CollectedHeap {
   131 class G1CollectedHeap : public CollectedHeap {
   132   friend class G1FreeCollectionSetTask;
       
   133   friend class VM_CollectForMetadataAllocation;
   132   friend class VM_CollectForMetadataAllocation;
   134   friend class VM_G1CollectForAllocation;
   133   friend class VM_G1CollectForAllocation;
   135   friend class VM_G1CollectFull;
   134   friend class VM_G1CollectFull;
   136   friend class VMStructs;
   135   friend class VMStructs;
   137   friend class MutatorAllocRegion;
   136   friend class MutatorAllocRegion;
   352     assert_at_safepoint();                                                    \
   351     assert_at_safepoint();                                                    \
   353     assert(Thread::current_or_null() != NULL, "no current thread");           \
   352     assert(Thread::current_or_null() != NULL, "no current thread");           \
   354     assert(Thread::current()->is_VM_thread(), "current thread is not VM thread"); \
   353     assert(Thread::current()->is_VM_thread(), "current thread is not VM thread"); \
   355   } while (0)
   354   } while (0)
   356 
   355 
       
   356 #ifdef ASSERT
   357 #define assert_used_and_recalculate_used_equal(g1h)                           \
   357 #define assert_used_and_recalculate_used_equal(g1h)                           \
   358   do {                                                                        \
   358   do {                                                                        \
   359     size_t cur_used_bytes = g1h->used();                                      \
   359     size_t cur_used_bytes = g1h->used();                                      \
   360     size_t recal_used_bytes = g1h->recalculate_used();                        \
   360     size_t recal_used_bytes = g1h->recalculate_used();                        \
   361     assert(cur_used_bytes == recal_used_bytes, "Used(" SIZE_FORMAT ") is not" \
   361     assert(cur_used_bytes == recal_used_bytes, "Used(" SIZE_FORMAT ") is not" \
   362            " same as recalculated used(" SIZE_FORMAT ").",                    \
   362            " same as recalculated used(" SIZE_FORMAT ").",                    \
   363            cur_used_bytes, recal_used_bytes);                                 \
   363            cur_used_bytes, recal_used_bytes);                                 \
   364   } while (0)
   364   } while (0)
       
   365 #else
       
   366 #define assert_used_and_recalculate_used_equal(g1h) do {} while(0)
       
   367 #endif
   365 
   368 
   366   const char* young_gc_name() const;
   369   const char* young_gc_name() const;
   367 
   370 
   368   // The young region list.
   371   // The young region list.
   369   G1EdenRegions _eden;
   372   G1EdenRegions _eden;
   590   }
   593   }
   591 
   594 
   592   void clear_region_attr() {
   595   void clear_region_attr() {
   593     _region_attr.clear();
   596     _region_attr.clear();
   594   }
   597   }
       
   598 
       
   599   // Verify that the G1RegionAttr remset tracking corresponds to actual remset tracking
       
   600   // for all regions.
       
   601   void verify_region_attr_remset_update() PRODUCT_RETURN;
   595 
   602 
   596   bool is_user_requested_concurrent_full_gc(GCCause::Cause cause);
   603   bool is_user_requested_concurrent_full_gc(GCCause::Cause cause);
   597 
   604 
   598   // This is called at the start of either a concurrent cycle or a Full
   605   // This is called at the start of either a concurrent cycle or a Full
   599   // GC to update the number of old marking cycles started.
   606   // GC to update the number of old marking cycles started.
   751 private:
   758 private:
   752   // Evacuate the next set of optional regions.
   759   // Evacuate the next set of optional regions.
   753   void evacuate_next_optional_regions(G1ParScanThreadStateSet* per_thread_states);
   760   void evacuate_next_optional_regions(G1ParScanThreadStateSet* per_thread_states);
   754 
   761 
   755 public:
   762 public:
   756   void pre_evacuate_collection_set(G1EvacuationInfo& evacuation_info);
   763   void pre_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
   757   void post_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
   764   void post_evacuate_collection_set(G1EvacuationInfo& evacuation_info,
       
   765                                     G1RedirtyCardsQueueSet* rdcqs,
       
   766                                     G1ParScanThreadStateSet* pss);
   758 
   767 
   759   void expand_heap_after_young_collection();
   768   void expand_heap_after_young_collection();
   760   // Update object copying statistics.
   769   // Update object copying statistics.
   761   void record_obj_copy_mem_stats();
   770   void record_obj_copy_mem_stats();
   762 
   771 
   764   G1HotCardCache* _hot_card_cache;
   773   G1HotCardCache* _hot_card_cache;
   765 
   774 
   766   // The g1 remembered set of the heap.
   775   // The g1 remembered set of the heap.
   767   G1RemSet* _rem_set;
   776   G1RemSet* _rem_set;
   768 
   777 
   769   // A set of cards that cover the objects for which the Rsets should be updated
       
   770   // concurrently after the collection.
       
   771   G1DirtyCardQueueSet _dirty_card_queue_set;
       
   772 
       
   773   // After a collection pause, convert the regions in the collection set into free
   778   // After a collection pause, convert the regions in the collection set into free
   774   // regions.
   779   // regions.
   775   void free_collection_set(G1CollectionSet* collection_set, G1EvacuationInfo& evacuation_info, const size_t* surviving_young_words);
   780   void free_collection_set(G1CollectionSet* collection_set, G1EvacuationInfo& evacuation_info, const size_t* surviving_young_words);
   776 
   781 
   777   // Abandon the current collection set without recording policy
   782   // Abandon the current collection set without recording policy
   793 
   798 
   794   EvacuationFailedInfo* _evacuation_failed_info_array;
   799   EvacuationFailedInfo* _evacuation_failed_info_array;
   795 
   800 
   796   // Failed evacuations cause some logical from-space objects to have
   801   // Failed evacuations cause some logical from-space objects to have
   797   // forwarding pointers to themselves.  Reset them.
   802   // forwarding pointers to themselves.  Reset them.
   798   void remove_self_forwarding_pointers();
   803   void remove_self_forwarding_pointers(G1RedirtyCardsQueueSet* rdcqs);
   799 
   804 
   800   // Restore the objects in the regions in the collection set after an
   805   // Restore the objects in the regions in the collection set after an
   801   // evacuation failure.
   806   // evacuation failure.
   802   void restore_after_evac_failure();
   807   void restore_after_evac_failure(G1RedirtyCardsQueueSet* rdcqs);
   803 
   808 
   804   PreservedMarksSet _preserved_marks_set;
   809   PreservedMarksSet _preserved_marks_set;
   805 
   810 
   806   // Preserve the mark of "obj", if necessary, in preparation for its mark
   811   // Preserve the mark of "obj", if necessary, in preparation for its mark
   807   // word being overwritten with a self-forwarding-pointer.
   812   // word being overwritten with a self-forwarding-pointer.
   808   void preserve_mark_during_evac_failure(uint worker_id, oop obj, markOop m);
   813   void preserve_mark_during_evac_failure(uint worker_id, oop obj, markWord m);
   809 
   814 
   810 #ifndef PRODUCT
   815 #ifndef PRODUCT
   811   // Support for forcing evacuation failures. Analogous to
   816   // Support for forcing evacuation failures. Analogous to
   812   // PromotionFailureALot for the other collectors.
   817   // PromotionFailureALot for the other collectors.
   813 
   818 
   925 
   930 
   926   RefToScanQueue *task_queue(uint i) const;
   931   RefToScanQueue *task_queue(uint i) const;
   927 
   932 
   928   uint num_task_queues() const;
   933   uint num_task_queues() const;
   929 
   934 
   930   // A set of cards where updates happened during the GC
       
   931   G1DirtyCardQueueSet& dirty_card_queue_set() { return _dirty_card_queue_set; }
       
   932 
       
   933   // Create a G1CollectedHeap.
   935   // Create a G1CollectedHeap.
   934   // Must call the initialize method afterwards.
   936   // Must call the initialize method afterwards.
   935   // May not return if something goes wrong.
   937   // May not return if something goes wrong.
   936   G1CollectedHeap();
   938   G1CollectedHeap();
   937 
   939 
   986 
   988 
   987   // Try to minimize the remembered set.
   989   // Try to minimize the remembered set.
   988   void scrub_rem_set();
   990   void scrub_rem_set();
   989 
   991 
   990   // Apply the given closure on all cards in the Hot Card Cache, emptying it.
   992   // Apply the given closure on all cards in the Hot Card Cache, emptying it.
   991   void iterate_hcc_closure(G1CardTableEntryClosure* cl, uint worker_i);
   993   void iterate_hcc_closure(G1CardTableEntryClosure* cl, uint worker_id);
   992 
       
   993   // Apply the given closure on all cards in the Dirty Card Queue Set, emptying it.
       
   994   void iterate_dirty_card_closure(G1CardTableEntryClosure* cl, uint worker_i);
       
   995 
   994 
   996   // The shared block offset table array.
   995   // The shared block offset table array.
   997   G1BlockOffsetTable* bot() const { return _bot; }
   996   G1BlockOffsetTable* bot() const { return _bot; }
   998 
   997 
   999   // Reference Processing accessors
   998   // Reference Processing accessors
  1109   // corresponding region is in the collection set or not.
  1108   // corresponding region is in the collection set or not.
  1110   G1HeapRegionAttrBiasedMappedArray _region_attr;
  1109   G1HeapRegionAttrBiasedMappedArray _region_attr;
  1111 
  1110 
  1112  public:
  1111  public:
  1113 
  1112 
  1114   inline G1HeapRegionAttr region_attr(const void* obj);
  1113   inline G1HeapRegionAttr region_attr(const void* obj) const;
       
  1114   inline G1HeapRegionAttr region_attr(uint idx) const;
  1115 
  1115 
  1116   // Return "TRUE" iff the given object address is in the reserved
  1116   // Return "TRUE" iff the given object address is in the reserved
  1117   // region of g1.
  1117   // region of g1.
  1118   bool is_in_g1_reserved(const void* p) const {
  1118   bool is_in_g1_reserved(const void* p) const {
  1119     return _hrm->reserved().contains(p);
  1119     return _hrm->reserved().contains(p);
  1123   // reserved for the heap
  1123   // reserved for the heap
  1124   MemRegion g1_reserved() const {
  1124   MemRegion g1_reserved() const {
  1125     return _hrm->reserved();
  1125     return _hrm->reserved();
  1126   }
  1126   }
  1127 
  1127 
  1128   G1HotCardCache* g1_hot_card_cache() const { return _hot_card_cache; }
  1128   MemRegion reserved_region() const {
       
  1129     return _reserved;
       
  1130   }
       
  1131 
       
  1132   HeapWord* base() const {
       
  1133     return _reserved.start();
       
  1134   }
       
  1135 
       
  1136   bool is_in_reserved(const void* addr) const {
       
  1137     return _reserved.contains(addr);
       
  1138   }
       
  1139 
       
  1140   G1HotCardCache* hot_card_cache() const { return _hot_card_cache; }
  1129 
  1141 
  1130   G1CardTable* card_table() const {
  1142   G1CardTable* card_table() const {
  1131     return _card_table;
  1143     return _card_table;
  1132   }
  1144   }
  1133 
  1145 
  1176 
  1188 
  1177   // Iterate over the regions in the current increment of the collection set.
  1189   // Iterate over the regions in the current increment of the collection set.
  1178   // Starts the iteration so that the start regions of a given worker id over the
  1190   // Starts the iteration so that the start regions of a given worker id over the
  1179   // set active_workers are evenly spread across the set of collection set regions
  1191   // set active_workers are evenly spread across the set of collection set regions
  1180   // to be iterated.
  1192   // to be iterated.
  1181   void collection_set_iterate_increment_from(HeapRegionClosure *blk, uint worker_id);
  1193   // The variant with the HeapRegionClaimer guarantees that the closure will be
       
  1194   // applied to a particular region exactly once.
       
  1195   void collection_set_iterate_increment_from(HeapRegionClosure *blk, uint worker_id) {
       
  1196     collection_set_iterate_increment_from(blk, NULL, worker_id);
       
  1197   }
       
  1198   void collection_set_iterate_increment_from(HeapRegionClosure *blk, HeapRegionClaimer* hr_claimer, uint worker_id);
  1182 
  1199 
  1183   // Returns the HeapRegion that contains addr. addr must not be NULL.
  1200   // Returns the HeapRegion that contains addr. addr must not be NULL.
  1184   template <class T>
  1201   template <class T>
  1185   inline HeapRegion* heap_region_containing(const T addr) const;
  1202   inline HeapRegion* heap_region_containing(const T addr) const;
  1186 
  1203 
  1200 
  1217 
  1201   // Returns the address of the start of the "block" that contains the
  1218   // Returns the address of the start of the "block" that contains the
  1202   // address "addr".  We say "blocks" instead of "object" since some heaps
  1219   // address "addr".  We say "blocks" instead of "object" since some heaps
  1203   // may not pack objects densely; a chunk may either be an object or a
  1220   // may not pack objects densely; a chunk may either be an object or a
  1204   // non-object.
  1221   // non-object.
  1205   virtual HeapWord* block_start(const void* addr) const;
  1222   HeapWord* block_start(const void* addr) const;
  1206 
  1223 
  1207   // Requires "addr" to be the start of a block, and returns "TRUE" iff
  1224   // Requires "addr" to be the start of a block, and returns "TRUE" iff
  1208   // the block is an object.
  1225   // the block is an object.
  1209   virtual bool block_is_obj(const HeapWord* addr) const;
  1226   bool block_is_obj(const HeapWord* addr) const;
  1210 
  1227 
  1211   // Section on thread-local allocation buffers (TLABs)
  1228   // Section on thread-local allocation buffers (TLABs)
  1212   // See CollectedHeap for semantics.
  1229   // See CollectedHeap for semantics.
  1213 
  1230 
  1214   bool supports_tlab_allocation() const;
  1231   bool supports_tlab_allocation() const;
  1348 
  1365 
  1349   // Performs cleaning of data structures after class unloading.
  1366   // Performs cleaning of data structures after class unloading.
  1350   void complete_cleaning(BoolObjectClosure* is_alive, bool class_unloading_occurred);
  1367   void complete_cleaning(BoolObjectClosure* is_alive, bool class_unloading_occurred);
  1351 
  1368 
  1352   // Redirty logged cards in the refinement queue.
  1369   // Redirty logged cards in the refinement queue.
  1353   void redirty_logged_cards();
  1370   void redirty_logged_cards(G1RedirtyCardsQueueSet* rdcqs);
       
  1371 
  1354   // Verification
  1372   // Verification
  1355 
  1373 
  1356   // Deduplicate the string
  1374   // Deduplicate the string
  1357   virtual void deduplicate_string(oop str);
  1375   virtual void deduplicate_string(oop str);
  1358 
  1376 
  1416 
  1434 
  1417   // The following two methods are helpful for debugging RSet issues.
  1435   // The following two methods are helpful for debugging RSet issues.
  1418   void print_cset_rsets() PRODUCT_RETURN;
  1436   void print_cset_rsets() PRODUCT_RETURN;
  1419   void print_all_rsets() PRODUCT_RETURN;
  1437   void print_all_rsets() PRODUCT_RETURN;
  1420 
  1438 
       
  1439   // Used to print information about locations in the hs_err file.
       
  1440   virtual bool print_location(outputStream* st, void* addr) const;
       
  1441 
  1421   size_t pending_card_num();
  1442   size_t pending_card_num();
  1422 };
  1443 };
  1423 
  1444 
  1424 class G1ParEvacuateFollowersClosure : public VoidClosure {
  1445 class G1ParEvacuateFollowersClosure : public VoidClosure {
  1425 private:
  1446 private: