1089 return (old_regions_count() + _archive_set.length() + humongous_regions_count()) * HeapRegion::GrainBytes; 1090 } 1091 1092 // Determine whether the given region is one that we are using as an 1093 // old GC alloc region. 1094 bool is_old_gc_alloc_region(HeapRegion* hr); 1095 1096 // Perform a collection of the heap; intended for use in implementing 1097 // "System.gc". This probably implies as full a collection as the 1098 // "CollectedHeap" supports. 1099 virtual void collect(GCCause::Cause cause); 1100 1101 // Perform a collection of the heap with the given cause. 1102 // Returns whether this collection actually executed. 1103 bool try_collect(GCCause::Cause cause); 1104 1105 // True iff an evacuation has failed in the most-recent collection. 1106 bool evacuation_failed() { return _evacuation_failed; } 1107 1108 void remove_from_old_sets(const uint old_regions_removed, const uint humongous_regions_removed); 1109 void prepend_to_freelist(FreeRegionList* list); 1110 void decrement_summary_bytes(size_t bytes); 1111 1112 virtual bool is_in(const void* p) const; 1113 #ifdef ASSERT 1114 // Returns whether p is in one of the available areas of the heap. Slow but 1115 // extensive version. 1116 bool is_in_exact(const void* p) const; 1117 #endif 1118 1119 // Return "TRUE" iff the given object address is within the collection 1120 // set. Assumes that the reference points into the heap. 1121 inline bool is_in_cset(const HeapRegion *hr); 1122 inline bool is_in_cset(oop obj); 1123 inline bool is_in_cset(HeapWord* addr); 1124 1125 inline bool is_in_cset_or_humongous(const oop obj); 1126 1127 private: 1128 // This array is used for a quick test on whether a reference points into 1129 // the collection set or not. Each of the array's elements denotes whether the 1183 inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const; 1184 1185 // Calculate the region index of the given address. Given address must be 1186 // within the heap. 1187 inline uint addr_to_region(HeapWord* addr) const; 1188 1189 inline HeapWord* bottom_addr_for_region(uint index) const; 1190 1191 // Two functions to iterate over the heap regions in parallel. Threads 1192 // compete using the HeapRegionClaimer to claim the regions before 1193 // applying the closure on them. 1194 // The _from_worker_offset version uses the HeapRegionClaimer and 1195 // the worker id to calculate a start offset to prevent all workers to 1196 // start from the point. 1197 void heap_region_par_iterate_from_worker_offset(HeapRegionClosure* cl, 1198 HeapRegionClaimer* hrclaimer, 1199 uint worker_id) const; 1200 1201 void heap_region_par_iterate_from_start(HeapRegionClosure* cl, 1202 HeapRegionClaimer* hrclaimer) const; 1203 1204 // Iterate over all regions currently in the current collection set. 1205 void collection_set_iterate_all(HeapRegionClosure* blk); 1206 1207 // Iterate over the regions in the current increment of the collection set. 1208 // Starts the iteration so that the start regions of a given worker id over the 1209 // set active_workers are evenly spread across the set of collection set regions 1210 // to be iterated. 1211 // The variant with the HeapRegionClaimer guarantees that the closure will be 1212 // applied to a particular region exactly once. 1213 void collection_set_iterate_increment_from(HeapRegionClosure *blk, uint worker_id) { 1214 collection_set_iterate_increment_from(blk, NULL, worker_id); 1215 } 1216 void collection_set_iterate_increment_from(HeapRegionClosure *blk, HeapRegionClaimer* hr_claimer, uint worker_id); 1217 1218 // Returns the HeapRegion that contains addr. addr must not be NULL. 1219 template <class T> 1220 inline HeapRegion* heap_region_containing(const T addr) const; 1221 1222 // Returns the HeapRegion that contains addr, or NULL if that is an uncommitted | 1089 return (old_regions_count() + _archive_set.length() + humongous_regions_count()) * HeapRegion::GrainBytes; 1090 } 1091 1092 // Determine whether the given region is one that we are using as an 1093 // old GC alloc region. 1094 bool is_old_gc_alloc_region(HeapRegion* hr); 1095 1096 // Perform a collection of the heap; intended for use in implementing 1097 // "System.gc". This probably implies as full a collection as the 1098 // "CollectedHeap" supports. 1099 virtual void collect(GCCause::Cause cause); 1100 1101 // Perform a collection of the heap with the given cause. 1102 // Returns whether this collection actually executed. 1103 bool try_collect(GCCause::Cause cause); 1104 1105 // True iff an evacuation has failed in the most-recent collection. 1106 bool evacuation_failed() { return _evacuation_failed; } 1107 1108 void remove_from_old_sets(const uint old_regions_removed, const uint humongous_regions_removed); 1109 void abandon_freelist(); 1110 void prepend_to_freelist(FreeRegionList* list); 1111 void append_to_freelist(FreeRegionList* list); 1112 void decrement_summary_bytes(size_t bytes); 1113 1114 virtual bool is_in(const void* p) const; 1115 #ifdef ASSERT 1116 // Returns whether p is in one of the available areas of the heap. Slow but 1117 // extensive version. 1118 bool is_in_exact(const void* p) const; 1119 #endif 1120 1121 // Return "TRUE" iff the given object address is within the collection 1122 // set. Assumes that the reference points into the heap. 1123 inline bool is_in_cset(const HeapRegion *hr); 1124 inline bool is_in_cset(oop obj); 1125 inline bool is_in_cset(HeapWord* addr); 1126 1127 inline bool is_in_cset_or_humongous(const oop obj); 1128 1129 private: 1130 // This array is used for a quick test on whether a reference points into 1131 // the collection set or not. Each of the array's elements denotes whether the 1185 inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const; 1186 1187 // Calculate the region index of the given address. Given address must be 1188 // within the heap. 1189 inline uint addr_to_region(HeapWord* addr) const; 1190 1191 inline HeapWord* bottom_addr_for_region(uint index) const; 1192 1193 // Two functions to iterate over the heap regions in parallel. Threads 1194 // compete using the HeapRegionClaimer to claim the regions before 1195 // applying the closure on them. 1196 // The _from_worker_offset version uses the HeapRegionClaimer and 1197 // the worker id to calculate a start offset to prevent all workers to 1198 // start from the point. 1199 void heap_region_par_iterate_from_worker_offset(HeapRegionClosure* cl, 1200 HeapRegionClaimer* hrclaimer, 1201 uint worker_id) const; 1202 1203 void heap_region_par_iterate_from_start(HeapRegionClosure* cl, 1204 HeapRegionClaimer* hrclaimer) const; 1205 1206 // Iterate over all regions in the collection set in parallel. 1207 void collection_set_par_iterate_all(HeapRegionClosure* cl, 1208 HeapRegionClaimer* hr_claimer, 1209 uint worker_id); 1210 1211 // Iterate over all regions currently in the current collection set. 1212 void collection_set_iterate_all(HeapRegionClosure* blk); 1213 1214 // Iterate over the regions in the current increment of the collection set. 1215 // Starts the iteration so that the start regions of a given worker id over the 1216 // set active_workers are evenly spread across the set of collection set regions 1217 // to be iterated. 1218 // The variant with the HeapRegionClaimer guarantees that the closure will be 1219 // applied to a particular region exactly once. 1220 void collection_set_iterate_increment_from(HeapRegionClosure *blk, uint worker_id) { 1221 collection_set_iterate_increment_from(blk, NULL, worker_id); 1222 } 1223 void collection_set_iterate_increment_from(HeapRegionClosure *blk, HeapRegionClaimer* hr_claimer, uint worker_id); 1224 1225 // Returns the HeapRegion that contains addr. addr must not be NULL. 1226 template <class T> 1227 inline HeapRegion* heap_region_containing(const T addr) const; 1228 1229 // Returns the HeapRegion that contains addr, or NULL if that is an uncommitted |