79 // Note: BitMap::set_range() is exclusive. |
79 // Note: BitMap::set_range() is exclusive. |
80 task_card_bm->set_range(start_idx, last_idx+1); |
80 task_card_bm->set_range(start_idx, last_idx+1); |
81 } |
81 } |
82 } |
82 } |
83 |
83 |
|
84 // Counts the given memory region in the task/worker counting |
|
85 // data structures for the given worker id. |
|
86 inline void ConcurrentMark::count_region(MemRegion mr, |
|
87 HeapRegion* hr, |
|
88 uint worker_id) { |
|
89 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); |
|
90 BitMap* task_card_bm = count_card_bitmap_for(worker_id); |
|
91 count_region(mr, hr, marked_bytes_array, task_card_bm); |
|
92 } |
|
93 |
84 // Counts the given memory region, which may be a single object, in the |
94 // Counts the given memory region, which may be a single object, in the |
85 // task/worker counting data structures for the given worker id. |
95 // task/worker counting data structures for the given worker id. |
86 inline void ConcurrentMark::count_region(MemRegion mr, uint worker_id) { |
96 inline void ConcurrentMark::count_region(MemRegion mr, uint worker_id) { |
87 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); |
|
88 BitMap* task_card_bm = count_card_bitmap_for(worker_id); |
|
89 HeapWord* addr = mr.start(); |
97 HeapWord* addr = mr.start(); |
90 HeapRegion* hr = _g1h->heap_region_containing_raw(addr); |
98 HeapRegion* hr = _g1h->heap_region_containing_raw(addr); |
91 count_region(mr, hr, marked_bytes_array, task_card_bm); |
99 count_region(mr, hr, worker_id); |
92 } |
100 } |
93 |
101 |
94 // Counts the given object in the given task/worker counting data structures. |
102 // Counts the given object in the given task/worker counting data structures. |
95 inline void ConcurrentMark::count_object(oop obj, |
103 inline void ConcurrentMark::count_object(oop obj, |
96 HeapRegion* hr, |
104 HeapRegion* hr, |
100 count_region(mr, hr, marked_bytes_array, task_card_bm); |
108 count_region(mr, hr, marked_bytes_array, task_card_bm); |
101 } |
109 } |
102 |
110 |
103 // Counts the given object in the task/worker counting data |
111 // Counts the given object in the task/worker counting data |
104 // structures for the given worker id. |
112 // structures for the given worker id. |
105 inline void ConcurrentMark::count_object(oop obj, HeapRegion* hr, uint worker_id) { |
113 inline void ConcurrentMark::count_object(oop obj, |
|
114 HeapRegion* hr, |
|
115 uint worker_id) { |
106 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); |
116 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); |
107 BitMap* task_card_bm = count_card_bitmap_for(worker_id); |
117 BitMap* task_card_bm = count_card_bitmap_for(worker_id); |
108 HeapWord* addr = (HeapWord*) obj; |
118 HeapWord* addr = (HeapWord*) obj; |
109 count_object(obj, hr, marked_bytes_array, task_card_bm); |
119 count_object(obj, hr, marked_bytes_array, task_card_bm); |
110 } |
120 } |
117 BitMap* task_card_bm) { |
127 BitMap* task_card_bm) { |
118 HeapWord* addr = (HeapWord*)obj; |
128 HeapWord* addr = (HeapWord*)obj; |
119 if (_nextMarkBitMap->parMark(addr)) { |
129 if (_nextMarkBitMap->parMark(addr)) { |
120 // Update the task specific count data for the object. |
130 // Update the task specific count data for the object. |
121 count_object(obj, hr, marked_bytes_array, task_card_bm); |
131 count_object(obj, hr, marked_bytes_array, task_card_bm); |
|
132 return true; |
|
133 } |
|
134 return false; |
|
135 } |
|
136 |
|
137 // Attempts to mark the given object and, if successful, counts |
|
138 // the object in the task/worker counting structures for the |
|
139 // given worker id. |
|
140 inline bool ConcurrentMark::par_mark_and_count(oop obj, |
|
141 size_t word_size, |
|
142 HeapRegion* hr, |
|
143 uint worker_id) { |
|
144 HeapWord* addr = (HeapWord*)obj; |
|
145 if (_nextMarkBitMap->parMark(addr)) { |
|
146 MemRegion mr(addr, word_size); |
|
147 count_region(mr, hr, worker_id); |
122 return true; |
148 return true; |
123 } |
149 } |
124 return false; |
150 return false; |
125 } |
151 } |
126 |
152 |
340 // Note we are overriding the read-only view of the prev map here, via |
366 // Note we are overriding the read-only view of the prev map here, via |
341 // the cast. |
367 // the cast. |
342 ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p); |
368 ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p); |
343 } |
369 } |
344 |
370 |
345 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size, uint worker_id) { |
371 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size, |
|
372 uint worker_id, HeapRegion* hr) { |
|
373 assert(obj != NULL, "pre-condition"); |
346 HeapWord* addr = (HeapWord*) obj; |
374 HeapWord* addr = (HeapWord*) obj; |
347 |
375 if (hr == NULL) { |
348 // Currently we don't do anything with word_size but we will use it |
376 hr = _g1h->heap_region_containing_raw(addr); |
349 // in the very near future in the liveness calculation piggy-backing |
377 } else { |
350 // changes. |
378 assert(hr->is_in(addr), "pre-condition"); |
351 |
379 } |
352 #ifdef ASSERT |
|
353 HeapRegion* hr = _g1h->heap_region_containing(addr); |
|
354 assert(hr != NULL, "sanity"); |
380 assert(hr != NULL, "sanity"); |
355 assert(!hr->is_survivor(), "should not allocate survivors during IM"); |
381 // Given that we're looking for a region that contains an object |
356 assert(addr < hr->next_top_at_mark_start(), |
382 // header it's impossible to get back a HC region. |
357 err_msg("addr: "PTR_FORMAT" hr: "HR_FORMAT" NTAMS: "PTR_FORMAT, |
383 assert(!hr->continuesHumongous(), "sanity"); |
358 addr, HR_FORMAT_PARAMS(hr), hr->next_top_at_mark_start())); |
384 |
359 // We cannot assert that word_size == obj->size() given that obj |
385 // We cannot assert that word_size == obj->size() given that obj |
360 // might not be in a consistent state (another thread might be in |
386 // might not be in a consistent state (another thread might be in |
361 // the process of copying it). So the best thing we can do is to |
387 // the process of copying it). So the best thing we can do is to |
362 // assert that word_size is under an upper bound which is its |
388 // assert that word_size is under an upper bound which is its |
363 // containing region's capacity. |
389 // containing region's capacity. |
364 assert(word_size * HeapWordSize <= hr->capacity(), |
390 assert(word_size * HeapWordSize <= hr->capacity(), |
365 err_msg("size: "SIZE_FORMAT" capacity: "SIZE_FORMAT" "HR_FORMAT, |
391 err_msg("size: "SIZE_FORMAT" capacity: "SIZE_FORMAT" "HR_FORMAT, |
366 word_size * HeapWordSize, hr->capacity(), |
392 word_size * HeapWordSize, hr->capacity(), |
367 HR_FORMAT_PARAMS(hr))); |
393 HR_FORMAT_PARAMS(hr))); |
368 #endif // ASSERT |
394 |
369 |
395 if (addr < hr->next_top_at_mark_start()) { |
370 if (!_nextMarkBitMap->isMarked(addr)) { |
396 if (!_nextMarkBitMap->isMarked(addr)) { |
371 par_mark_and_count(obj, word_size, worker_id); |
397 par_mark_and_count(obj, word_size, hr, worker_id); |
|
398 } |
372 } |
399 } |
373 } |
400 } |
374 |
401 |
375 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_INLINE_HPP |
402 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_INLINE_HPP |