comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 829:30b9b25b9cc1

6850869: G1: RSet "scrubbing" scrubs too much Summary: RSet scrubbing incorrectly deletes RSet entries that point to regions tagged as "continues humongous" due to a race when RSet scrubbing iterates over regions in parallel. Reviewed-by: apetrusenko, iveresov
author tonyp
date Wed, 24 Jun 2009 11:42:03 -0400
parents 830ca2573896
children 3eb9872b10ce
comparison
equal deleted inserted replaced
812:85d0690f7d12 829:30b9b25b9cc1
1231 _bottom_card_num = 1231 _bottom_card_num =
1232 intptr_t(uintptr_t(G1CollectedHeap::heap()->reserved_region().start()) >> 1232 intptr_t(uintptr_t(G1CollectedHeap::heap()->reserved_region().start()) >>
1233 CardTableModRefBS::card_shift); 1233 CardTableModRefBS::card_shift);
1234 } 1234 }
1235 1235
1236 // It takes a region that's not empty (i.e., it has at least one
1237 // live object in it and sets its corresponding bit on the region
1238 // bitmap to 1. If the region is "starts humongous" it will also set
1239 // to 1 the bits on the region bitmap that correspond to its
1240 // associated "continues humongous" regions.
1241 void set_bit_for_region(HeapRegion* hr) {
1242 assert(!hr->continuesHumongous(), "should have filtered those out");
1243
1244 size_t index = hr->hrs_index();
1245 if (!hr->startsHumongous()) {
1246 // Normal (non-humongous) case: just set the bit.
1247 _region_bm->par_at_put((BitMap::idx_t) index, true);
1248 } else {
1249 // Starts humongous case: calculate how many regions are part of
1250 // this humongous region and then set the bit range. It might
1251 // have been a bit more efficient to look at the object that
1252 // spans these humongous regions to calculate their number from
1253 // the object's size. However, it's a good idea to calculate
1254 // this based on the metadata itself, and not the region
1255 // contents, so that this code is not aware of what goes into
1256 // the humongous regions (in case this changes in the future).
1257 G1CollectedHeap* g1h = G1CollectedHeap::heap();
1258 size_t end_index = index + 1;
1259 while (index < g1h->n_regions()) {
1260 HeapRegion* chr = g1h->region_at(index);
1261 if (!chr->continuesHumongous()) {
1262 break;
1263 }
1264 end_index += 1;
1265 }
1266 _region_bm->par_at_put_range((BitMap::idx_t) index,
1267 (BitMap::idx_t) end_index, true);
1268 }
1269 }
1270
1236 bool doHeapRegion(HeapRegion* hr) { 1271 bool doHeapRegion(HeapRegion* hr) {
1237 if (_co_tracker != NULL) 1272 if (_co_tracker != NULL)
1238 _co_tracker->update(); 1273 _co_tracker->update();
1239 1274
1240 if (!_final && _regions_done == 0) 1275 if (!_final && _regions_done == 0)
1241 _start_vtime_sec = os::elapsedVTime(); 1276 _start_vtime_sec = os::elapsedVTime();
1242 1277
1243 if (hr->continuesHumongous()) { 1278 if (hr->continuesHumongous()) {
1244 HeapRegion* hum_start = hr->humongous_start_region(); 1279 // We will ignore these here and process them when their
1245 // If the head region of the humongous region has been determined 1280 // associated "starts humongous" region is processed (see
1246 // to be alive, then all the tail regions should be marked 1281 // set_bit_for_heap_region()). Note that we cannot rely on their
1247 // such as well. 1282 // associated "starts humongous" region to have their bit set to
1248 if (_region_bm->at(hum_start->hrs_index())) { 1283 // 1 since, due to the region chunking in the parallel region
1249 _region_bm->par_at_put(hr->hrs_index(), 1); 1284 // iteration, a "continues humongous" region might be visited
1250 } 1285 // before its associated "starts humongous".
1251 return false; 1286 return false;
1252 } 1287 }
1253 1288
1254 HeapWord* nextTop = hr->next_top_at_mark_start(); 1289 HeapWord* nextTop = hr->next_top_at_mark_start();
1255 HeapWord* start = hr->top_at_conc_mark_count(); 1290 HeapWord* start = hr->top_at_conc_mark_count();
1341 intptr_t(uintptr_t(nextTop) >> CardTableModRefBS::card_shift); 1376 intptr_t(uintptr_t(nextTop) >> CardTableModRefBS::card_shift);
1342 last_card_num = 1377 last_card_num =
1343 intptr_t(uintptr_t(tp) >> CardTableModRefBS::card_shift); 1378 intptr_t(uintptr_t(tp) >> CardTableModRefBS::card_shift);
1344 mark_card_num_range(start_card_num, last_card_num); 1379 mark_card_num_range(start_card_num, last_card_num);
1345 // This definitely means the region has live objects. 1380 // This definitely means the region has live objects.
1346 _region_bm->par_at_put(hr->hrs_index(), 1); 1381 set_bit_for_region(hr);
1347 } 1382 }
1348 } 1383 }
1349 1384
1350 hr->add_to_marked_bytes(marked_bytes); 1385 hr->add_to_marked_bytes(marked_bytes);
1351 // Update the live region bitmap. 1386 // Update the live region bitmap.
1352 if (marked_bytes > 0) { 1387 if (marked_bytes > 0) {
1353 _region_bm->par_at_put(hr->hrs_index(), 1); 1388 set_bit_for_region(hr);
1354 } 1389 }
1355 hr->set_top_at_conc_mark_count(nextTop); 1390 hr->set_top_at_conc_mark_count(nextTop);
1356 _tot_live += hr->next_live_bytes(); 1391 _tot_live += hr->next_live_bytes();
1357 _tot_used += hr->used(); 1392 _tot_used += hr->used();
1358 _words_done = words_done; 1393 _words_done = words_done;