comparison src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 52b4284cb496 9337d0e7ea4f
children
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
84 CardTableModRefBS* ct_bs = g1h->g1_barrier_set(); 84 CardTableModRefBS* ct_bs = g1h->g1_barrier_set();
85 85
86 HeapWord* start = mr.start(); 86 HeapWord* start = mr.start();
87 HeapWord* end = mr.end(); 87 HeapWord* end = mr.end();
88 size_t region_size_bytes = mr.byte_size(); 88 size_t region_size_bytes = mr.byte_size();
89 uint index = hr->hrs_index(); 89 uint index = hr->hrm_index();
90 90
91 assert(!hr->continuesHumongous(), "should not be HC region"); 91 assert(!hr->continuesHumongous(), "should not be HC region");
92 assert(hr == g1h->heap_region_containing(start), "sanity"); 92 assert(hr == g1h->heap_region_containing(start), "sanity");
93 assert(hr == g1h->heap_region_containing(mr.last()), "sanity"); 93 assert(hr == g1h->heap_region_containing(mr.last()), "sanity");
94 assert(marked_bytes_array != NULL, "pre-condition"); 94 assert(marked_bytes_array != NULL, "pre-condition");
123 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); 123 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
124 BitMap* task_card_bm = count_card_bitmap_for(worker_id); 124 BitMap* task_card_bm = count_card_bitmap_for(worker_id);
125 count_region(mr, hr, marked_bytes_array, task_card_bm); 125 count_region(mr, hr, marked_bytes_array, task_card_bm);
126 } 126 }
127 127
128 // Counts the given memory region, which may be a single object, in the
129 // task/worker counting data structures for the given worker id.
130 inline void ConcurrentMark::count_region(MemRegion mr, uint worker_id) {
131 HeapWord* addr = mr.start();
132 HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
133 count_region(mr, hr, worker_id);
134 }
135
136 // Counts the given object in the given task/worker counting data structures. 128 // Counts the given object in the given task/worker counting data structures.
137 inline void ConcurrentMark::count_object(oop obj, 129 inline void ConcurrentMark::count_object(oop obj,
138 HeapRegion* hr, 130 HeapRegion* hr,
139 size_t* marked_bytes_array, 131 size_t* marked_bytes_array,
140 BitMap* task_card_bm) { 132 BitMap* task_card_bm) {
141 MemRegion mr((HeapWord*)obj, obj->size()); 133 MemRegion mr((HeapWord*)obj, obj->size());
142 count_region(mr, hr, marked_bytes_array, task_card_bm); 134 count_region(mr, hr, marked_bytes_array, task_card_bm);
143 }
144
145 // Counts the given object in the task/worker counting data
146 // structures for the given worker id.
147 inline void ConcurrentMark::count_object(oop obj,
148 HeapRegion* hr,
149 uint worker_id) {
150 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
151 BitMap* task_card_bm = count_card_bitmap_for(worker_id);
152 HeapWord* addr = (HeapWord*) obj;
153 count_object(obj, hr, marked_bytes_array, task_card_bm);
154 } 135 }
155 136
156 // Attempts to mark the given object and, if successful, counts 137 // Attempts to mark the given object and, if successful, counts
157 // the object in the given task/worker counting structures. 138 // the object in the given task/worker counting structures.
158 inline bool ConcurrentMark::par_mark_and_count(oop obj, 139 inline bool ConcurrentMark::par_mark_and_count(oop obj,
182 return true; 163 return true;
183 } 164 }
184 return false; 165 return false;
185 } 166 }
186 167
187 // Attempts to mark the given object and, if successful, counts
188 // the object in the task/worker counting structures for the
189 // given worker id.
190 inline bool ConcurrentMark::par_mark_and_count(oop obj,
191 HeapRegion* hr,
192 uint worker_id) {
193 HeapWord* addr = (HeapWord*)obj;
194 if (_nextMarkBitMap->parMark(addr)) {
195 // Update the task specific count data for the object.
196 count_object(obj, hr, worker_id);
197 return true;
198 }
199 return false;
200 }
201
202 // As above - but we don't know the heap region containing the
203 // object and so have to supply it.
204 inline bool ConcurrentMark::par_mark_and_count(oop obj, uint worker_id) {
205 HeapWord* addr = (HeapWord*)obj;
206 HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
207 return par_mark_and_count(obj, hr, worker_id);
208 }
209
210 // Similar to the above routine but we already know the size, in words, of
211 // the object that we wish to mark/count
212 inline bool ConcurrentMark::par_mark_and_count(oop obj,
213 size_t word_size,
214 uint worker_id) {
215 HeapWord* addr = (HeapWord*)obj;
216 if (_nextMarkBitMap->parMark(addr)) {
217 // Update the task specific count data for the object.
218 MemRegion mr(addr, word_size);
219 count_region(mr, worker_id);
220 return true;
221 }
222 return false;
223 }
224
225 // Unconditionally mark the given object, and unconditinally count
226 // the object in the counting structures for worker id 0.
227 // Should *not* be called from parallel code.
228 inline bool ConcurrentMark::mark_and_count(oop obj, HeapRegion* hr) {
229 HeapWord* addr = (HeapWord*)obj;
230 _nextMarkBitMap->mark(addr);
231 // Update the task specific count data for the object.
232 count_object(obj, hr, 0 /* worker_id */);
233 return true;
234 }
235
236 // As above - but we don't have the heap region containing the
237 // object, so we have to supply it.
238 inline bool ConcurrentMark::mark_and_count(oop obj) {
239 HeapWord* addr = (HeapWord*)obj;
240 HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
241 return mark_and_count(obj, hr);
242 }
243
244 inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) { 168 inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) {
245 HeapWord* start_addr = MAX2(startWord(), mr.start()); 169 HeapWord* start_addr = MAX2(startWord(), mr.start());
246 HeapWord* end_addr = MIN2(endWord(), mr.end()); 170 HeapWord* end_addr = MIN2(endWord(), mr.end());
247 171
248 if (end_addr > start_addr) { 172 if (end_addr > start_addr) {
265 189
266 inline bool CMBitMapRO::iterate(BitMapClosure* cl) { 190 inline bool CMBitMapRO::iterate(BitMapClosure* cl) {
267 MemRegion mr(startWord(), sizeInWords()); 191 MemRegion mr(startWord(), sizeInWords());
268 return iterate(cl, mr); 192 return iterate(cl, mr);
269 } 193 }
194
195 #define check_mark(addr) \
196 assert(_bmStartWord <= (addr) && (addr) < (_bmStartWord + _bmWordSize), \
197 "outside underlying space?"); \
198 assert(G1CollectedHeap::heap()->is_in_exact(addr), \
199 err_msg("Trying to access not available bitmap "PTR_FORMAT \
200 " corresponding to "PTR_FORMAT" (%u)", \
201 p2i(this), p2i(addr), G1CollectedHeap::heap()->addr_to_region(addr)));
202
203 inline void CMBitMap::mark(HeapWord* addr) {
204 check_mark(addr);
205 _bm.set_bit(heapWordToOffset(addr));
206 }
207
208 inline void CMBitMap::clear(HeapWord* addr) {
209 check_mark(addr);
210 _bm.clear_bit(heapWordToOffset(addr));
211 }
212
213 inline bool CMBitMap::parMark(HeapWord* addr) {
214 check_mark(addr);
215 return _bm.par_set_bit(heapWordToOffset(addr));
216 }
217
218 inline bool CMBitMap::parClear(HeapWord* addr) {
219 check_mark(addr);
220 return _bm.par_clear_bit(heapWordToOffset(addr));
221 }
222
223 #undef check_mark
270 224
271 inline void CMTask::push(oop obj) { 225 inline void CMTask::push(oop obj) {
272 HeapWord* objAddr = (HeapWord*) obj; 226 HeapWord* objAddr = (HeapWord*) obj;
273 assert(_g1h->is_in_g1_reserved(objAddr), "invariant"); 227 assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
274 assert(!_g1h->is_on_master_free_list( 228 assert(!_g1h->is_on_master_free_list(