Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/collectionSetChooser.hpp @ 6254:a2f7274eb6ef
7114678: G1: various small fixes, code cleanup, and refactoring
Summary: Various cleanups as a prelude to introducing iterators for HeapRegions.
Reviewed-by: johnc, brutisso
author | tonyp |
---|---|
date | Thu, 19 Jul 2012 15:15:54 -0700 |
parents | d2a62e0f25eb |
children | 27714220e50e |
comparison
equal
deleted
inserted
replaced
6253:db823a892a55 | 6254:a2f7274eb6ef |
---|---|
151 // Returns true if the used portion of "_regions" is properly | 151 // Returns true if the used portion of "_regions" is properly |
152 // sorted, otherwise asserts false. | 152 // sorted, otherwise asserts false. |
153 void verify() PRODUCT_RETURN; | 153 void verify() PRODUCT_RETURN; |
154 }; | 154 }; |
155 | 155 |
156 class CSetChooserParUpdater : public StackObj { | |
157 private: | |
158 CollectionSetChooser* _chooser; | |
159 bool _parallel; | |
160 uint _chunk_size; | |
161 uint _cur_chunk_idx; | |
162 uint _cur_chunk_end; | |
163 uint _regions_added; | |
164 size_t _reclaimable_bytes_added; | |
165 | |
166 public: | |
167 CSetChooserParUpdater(CollectionSetChooser* chooser, | |
168 bool parallel, uint chunk_size) : | |
169 _chooser(chooser), _parallel(parallel), _chunk_size(chunk_size), | |
170 _cur_chunk_idx(0), _cur_chunk_end(0), | |
171 _regions_added(0), _reclaimable_bytes_added(0) { } | |
172 | |
173 ~CSetChooserParUpdater() { | |
174 if (_parallel && _regions_added > 0) { | |
175 _chooser->update_totals(_regions_added, _reclaimable_bytes_added); | |
176 } | |
177 } | |
178 | |
179 void add_region(HeapRegion* hr) { | |
180 if (_parallel) { | |
181 if (_cur_chunk_idx == _cur_chunk_end) { | |
182 _cur_chunk_idx = _chooser->claim_array_chunk(_chunk_size); | |
183 _cur_chunk_end = _cur_chunk_idx + _chunk_size; | |
184 } | |
185 assert(_cur_chunk_idx < _cur_chunk_end, "invariant"); | |
186 _chooser->set_region(_cur_chunk_idx, hr); | |
187 _cur_chunk_idx += 1; | |
188 } else { | |
189 _chooser->add_region(hr); | |
190 } | |
191 _regions_added += 1; | |
192 _reclaimable_bytes_added += hr->reclaimable_bytes(); | |
193 } | |
194 | |
195 bool should_add(HeapRegion* hr) { return _chooser->should_add(hr); } | |
196 }; | |
197 | |
156 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP | 198 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP |
199 |