114 }
115
116 size_t CMBitMap::compute_size(size_t heap_size) {
117 return heap_size / mark_distance();
118 }
119
120 size_t CMBitMap::mark_distance() {
121 return MinObjAlignmentInBytes * BitsPerByte;
122 }
123
124 void CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
125 _bmStartWord = heap.start();
126 _bmWordSize = heap.word_size();
127
128 _bm.set_map((BitMap::bm_word_t*) storage->reserved().start());
129 _bm.set_size(_bmWordSize >> _shifter);
130
131 storage->set_mapping_changed_listener(&_listener);
132 }
133
134 void CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions) {
135 // We need to clear the bitmap on commit, removing any existing information.
136 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords);
137 _bm->clearRange(mr);
138 }
139
140 // Closure used for clearing the given mark bitmap.
141 class ClearBitmapHRClosure : public HeapRegionClosure {
142 private:
143 ConcurrentMark* _cm;
144 CMBitMap* _bitmap;
145 bool _may_yield; // The closure may yield during iteration. If yielded, abort the iteration.
146 public:
147 ClearBitmapHRClosure(ConcurrentMark* cm, CMBitMap* bitmap, bool may_yield) : HeapRegionClosure(), _cm(cm), _bitmap(bitmap), _may_yield(may_yield) {
148 assert(!may_yield || cm != NULL, "CM must be non-NULL if this closure is expected to yield.");
149 }
150
151 virtual bool doHeapRegion(HeapRegion* r) {
152 size_t const chunk_size_in_words = M / HeapWordSize;
153
154 HeapWord* cur = r->bottom();
|
114 }
115
116 size_t CMBitMap::compute_size(size_t heap_size) {
117 return heap_size / mark_distance();
118 }
119
120 size_t CMBitMap::mark_distance() {
121 return MinObjAlignmentInBytes * BitsPerByte;
122 }
123
124 void CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
125 _bmStartWord = heap.start();
126 _bmWordSize = heap.word_size();
127
128 _bm.set_map((BitMap::bm_word_t*) storage->reserved().start());
129 _bm.set_size(_bmWordSize >> _shifter);
130
131 storage->set_mapping_changed_listener(&_listener);
132 }
133
134 void CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) {
135 if (zero_filled) {
136 return;
137 }
138 // We need to clear the bitmap on commit, removing any existing information.
139 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords);
140 _bm->clearRange(mr);
141 }
142
143 // Closure used for clearing the given mark bitmap.
144 class ClearBitmapHRClosure : public HeapRegionClosure {
145 private:
146 ConcurrentMark* _cm;
147 CMBitMap* _bitmap;
148 bool _may_yield; // The closure may yield during iteration. If yielded, abort the iteration.
149 public:
150 ClearBitmapHRClosure(ConcurrentMark* cm, CMBitMap* bitmap, bool may_yield) : HeapRegionClosure(), _cm(cm), _bitmap(bitmap), _may_yield(may_yield) {
151 assert(!may_yield || cm != NULL, "CM must be non-NULL if this closure is expected to yield.");
152 }
153
154 virtual bool doHeapRegion(HeapRegion* r) {
155 size_t const chunk_size_in_words = M / HeapWordSize;
156
157 HeapWord* cur = r->bottom();
|