180 assert(ctx != nullptr || heap->old_generation()->is_parsable(), "Error");
181 HeapWord* p = _scc->first_object_start(dirty_l, ctx, tams, right);
182 assert((p == nullptr) || (p < right), "No first object found is denoted by nullptr, p: "
183 PTR_FORMAT ", right: " PTR_FORMAT ", end_addr: " PTR_FORMAT ", next card addr: " PTR_FORMAT,
184 p2i(p), p2i(right), p2i(end_addr), p2i(_rs->addr_for_card_index(dirty_r + 1)));
185 if (p == nullptr) {
186 // There are no live objects to be scanned in this dirty range. cur_index identifies first card in this
187 // uninteresting dirty range. At top of next loop iteration, we will either end the looop
188 // (because cur_index < start_card_index) or we will begin the search for a range of clean cards.
189 continue;
190 }
191
192 oop obj = cast_to_oop(p);
193 assert(oopDesc::is_oop(obj), "Not an object at " PTR_FORMAT ", left: " PTR_FORMAT ", right: " PTR_FORMAT,
194 p2i(p), p2i(left), p2i(right));
195 assert(ctx==nullptr || ctx->is_marked(obj), "Error");
196
197 // PREFIX: The object that straddles into this range of dirty cards
198 // from the left may be subject to special treatment unless
199 // it is an object array.
200 if (p < left && !obj->is_objArray()) {
201 // The mutator (both compiler and interpreter, but not JNI?)
202 // typically dirty imprecisely (i.e. only the head of an object),
203 // but GC closures typically dirty the object precisely. (It would
204 // be nice to have everything be precise for maximum efficiency.)
205 //
206 // To handle this, we check the head card of the object here and,
207 // if dirty, (arrange to) scan the object in its entirety. If we
208 // find the head card clean, we'll scan only the portion of the
209 // object lying in the dirty card range below, assuming this was
210 // the result of precise marking by GC closures.
211
212 // index of the "head card" for p
213 const size_t hc_index = _rs->card_index_for_addr(p);
214 if (ctbm[hc_index] == CardTable::dirty_card_val()) {
215 // Scan or skip the object, depending on location of its
216 // head card, and remember that we'll have processed all
217 // the objects back up to p, which is thus an upper bound
218 // for the next iteration of a dirty card loop.
219 upper_bound = p; // remember upper bound for next chunk
220 if (p < start_addr) {
254 // apply the closure to the oops in the portion of
255 // the object within mr.
256 p += obj->oop_iterate_size(cl, mr);
257 NOT_PRODUCT(i++);
258 } else {
259 // forget the last object pointer we remembered
260 last_p = nullptr;
261 assert(p < tams, "Tams and above are implicitly marked in ctx");
262 // object under tams isn't marked: skip to next live object
263 p = ctx->get_next_marked_addr(p, tams);
264 assert(p <= tams, "Error 3 in ctx/marking/tams logic");
265 }
266 }
267
268 // SUFFIX: Fix up a possible incomplete scan at right end of window
269 // by scanning the portion of a non-objArray that wasn't done.
270 if (p > right && last_p != nullptr) {
271 assert(last_p < right, "Error");
272 // check if last_p suffix needs scanning
273 const oop last_obj = cast_to_oop(last_p);
274 if (!last_obj->is_objArray()) {
275 // scan the remaining suffix of the object
276 const MemRegion last_mr(right, p);
277 assert(p == last_p + last_obj->size(), "Would miss portion of last_obj");
278 last_obj->oop_iterate(cl, last_mr);
279 log_develop_debug(gc, remset)("Fixed up non-objArray suffix scan in [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
280 p2i(last_mr.start()), p2i(last_mr.end()));
281 } else {
282 log_develop_debug(gc, remset)("Skipped suffix scan of objArray in [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
283 p2i(right), p2i(p));
284 }
285 }
286 NOT_PRODUCT(stats.record_scan_obj_cnt(i);)
287
288 // ==== END DIRTY card range processing ====
289 } else {
290 // ==== BEGIN CLEAN card range processing ====
291
292 // If we are using the write table (during update refs, e.g.), a mutator may dirty
293 // a card at any time. This is fine for the algorithm below because it is only
294 // counting contiguous runs of clean cards (and only for non-product builds).
|
180 assert(ctx != nullptr || heap->old_generation()->is_parsable(), "Error");
181 HeapWord* p = _scc->first_object_start(dirty_l, ctx, tams, right);
182 assert((p == nullptr) || (p < right), "No first object found is denoted by nullptr, p: "
183 PTR_FORMAT ", right: " PTR_FORMAT ", end_addr: " PTR_FORMAT ", next card addr: " PTR_FORMAT,
184 p2i(p), p2i(right), p2i(end_addr), p2i(_rs->addr_for_card_index(dirty_r + 1)));
185 if (p == nullptr) {
186 // There are no live objects to be scanned in this dirty range. cur_index identifies first card in this
187 // uninteresting dirty range. At top of next loop iteration, we will either end the looop
188 // (because cur_index < start_card_index) or we will begin the search for a range of clean cards.
189 continue;
190 }
191
192 oop obj = cast_to_oop(p);
193 assert(oopDesc::is_oop(obj), "Not an object at " PTR_FORMAT ", left: " PTR_FORMAT ", right: " PTR_FORMAT,
194 p2i(p), p2i(left), p2i(right));
195 assert(ctx==nullptr || ctx->is_marked(obj), "Error");
196
197 // PREFIX: The object that straddles into this range of dirty cards
198 // from the left may be subject to special treatment unless
199 // it is an object array.
200 if (p < left && !obj->is_refArray()) {
201 // The mutator (both compiler and interpreter, but not JNI?)
202 // typically dirty imprecisely (i.e. only the head of an object),
203 // but GC closures typically dirty the object precisely. (It would
204 // be nice to have everything be precise for maximum efficiency.)
205 //
206 // To handle this, we check the head card of the object here and,
207 // if dirty, (arrange to) scan the object in its entirety. If we
208 // find the head card clean, we'll scan only the portion of the
209 // object lying in the dirty card range below, assuming this was
210 // the result of precise marking by GC closures.
211
212 // index of the "head card" for p
213 const size_t hc_index = _rs->card_index_for_addr(p);
214 if (ctbm[hc_index] == CardTable::dirty_card_val()) {
215 // Scan or skip the object, depending on location of its
216 // head card, and remember that we'll have processed all
217 // the objects back up to p, which is thus an upper bound
218 // for the next iteration of a dirty card loop.
219 upper_bound = p; // remember upper bound for next chunk
220 if (p < start_addr) {
254 // apply the closure to the oops in the portion of
255 // the object within mr.
256 p += obj->oop_iterate_size(cl, mr);
257 NOT_PRODUCT(i++);
258 } else {
259 // forget the last object pointer we remembered
260 last_p = nullptr;
261 assert(p < tams, "Tams and above are implicitly marked in ctx");
262 // object under tams isn't marked: skip to next live object
263 p = ctx->get_next_marked_addr(p, tams);
264 assert(p <= tams, "Error 3 in ctx/marking/tams logic");
265 }
266 }
267
268 // SUFFIX: Fix up a possible incomplete scan at right end of window
269 // by scanning the portion of a non-objArray that wasn't done.
270 if (p > right && last_p != nullptr) {
271 assert(last_p < right, "Error");
272 // check if last_p suffix needs scanning
273 const oop last_obj = cast_to_oop(last_p);
274 if (!last_obj->is_refArray()) {
275 // scan the remaining suffix of the object
276 const MemRegion last_mr(right, p);
277 assert(p == last_p + last_obj->size(), "Would miss portion of last_obj");
278 last_obj->oop_iterate(cl, last_mr);
279 log_develop_debug(gc, remset)("Fixed up non-objArray suffix scan in [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
280 p2i(last_mr.start()), p2i(last_mr.end()));
281 } else {
282 log_develop_debug(gc, remset)("Skipped suffix scan of objArray in [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
283 p2i(right), p2i(p));
284 }
285 }
286 NOT_PRODUCT(stats.record_scan_obj_cnt(i);)
287
288 // ==== END DIRTY card range processing ====
289 } else {
290 // ==== BEGIN CLEAN card range processing ====
291
292 // If we are using the write table (during update refs, e.g.), a mutator may dirty
293 // a card at any time. This is fine for the algorithm below because it is only
294 // counting contiguous runs of clean cards (and only for non-product builds).
|