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, |
180 MemRegion mr(addr, word_size); |
161 MemRegion mr(addr, word_size); |
181 count_region(mr, hr, worker_id); |
162 count_region(mr, hr, worker_id); |
182 return true; |
163 return true; |
183 } |
164 } |
184 return false; |
165 return false; |
185 } |
|
186 |
|
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 } |
166 } |
243 |
167 |
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()); |