src/share/vm/gc_implementation/g1/g1RemSet.cpp

changeset 2849
063382f9b575
parent 2646
04d1138b4cce
child 2962
ae5b2f1dcf12
     1.1 --- a/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Fri Apr 29 12:40:49 2011 -0400
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Fri Apr 29 14:59:04 2011 -0400
     1.3 @@ -157,7 +157,6 @@
     1.4    void set_try_claimed() { _try_claimed = true; }
     1.5  
     1.6    void scanCard(size_t index, HeapRegion *r) {
     1.7 -    _cards_done++;
     1.8      DirtyCardToOopClosure* cl =
     1.9        r->new_dcto_closure(_oc,
    1.10                           CardTableModRefBS::Precise,
    1.11 @@ -168,17 +167,14 @@
    1.12      HeapWord* card_start = _bot_shared->address_for_index(index);
    1.13      HeapWord* card_end = card_start + G1BlockOffsetSharedArray::N_words;
    1.14      Space *sp = SharedHeap::heap()->space_containing(card_start);
    1.15 -    MemRegion sm_region;
    1.16 -    if (ParallelGCThreads > 0) {
    1.17 -      // first find the used area
    1.18 -      sm_region = sp->used_region_at_save_marks();
    1.19 -    } else {
    1.20 -      // The closure is not idempotent.  We shouldn't look at objects
    1.21 -      // allocated during the GC.
    1.22 -      sm_region = sp->used_region_at_save_marks();
    1.23 -    }
    1.24 +    MemRegion sm_region = sp->used_region_at_save_marks();
    1.25      MemRegion mr = sm_region.intersection(MemRegion(card_start,card_end));
    1.26 -    if (!mr.is_empty()) {
    1.27 +    if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
    1.28 +      // We make the card as "claimed" lazily (so races are possible
    1.29 +      // but they're benign), which reduces the number of duplicate
    1.30 +      // scans (the rsets of the regions in the cset can intersect).
    1.31 +      _ct_bs->set_card_claimed(index);
    1.32 +      _cards_done++;
    1.33        cl->do_MemRegion(mr);
    1.34      }
    1.35    }
    1.36 @@ -199,6 +195,9 @@
    1.37      HeapRegionRemSet* hrrs = r->rem_set();
    1.38      if (hrrs->iter_is_complete()) return false; // All done.
    1.39      if (!_try_claimed && !hrrs->claim_iter()) return false;
    1.40 +    // If we ever free the collection set concurrently, we should also
    1.41 +    // clear the card table concurrently therefore we won't need to
    1.42 +    // add regions of the collection set to the dirty cards region.
    1.43      _g1h->push_dirty_cards_region(r);
    1.44      // If we didn't return above, then
    1.45      //   _try_claimed || r->claim_iter()
    1.46 @@ -230,15 +229,10 @@
    1.47          _g1h->push_dirty_cards_region(card_region);
    1.48        }
    1.49  
    1.50 -       // If the card is dirty, then we will scan it during updateRS.
    1.51 -      if (!card_region->in_collection_set() && !_ct_bs->is_card_dirty(card_index)) {
    1.52 -        // We make the card as "claimed" lazily (so races are possible but they're benign),
    1.53 -        // which reduces the number of duplicate scans (the rsets of the regions in the cset
    1.54 -        // can intersect).
    1.55 -        if (!_ct_bs->is_card_claimed(card_index)) {
    1.56 -          _ct_bs->set_card_claimed(card_index);
    1.57 -          scanCard(card_index, card_region);
    1.58 -        }
    1.59 +      // If the card is dirty, then we will scan it during updateRS.
    1.60 +      if (!card_region->in_collection_set() &&
    1.61 +          !_ct_bs->is_card_dirty(card_index)) {
    1.62 +        scanCard(card_index, card_region);
    1.63        }
    1.64      }
    1.65      if (!_try_claimed) {
    1.66 @@ -246,8 +240,6 @@
    1.67      }
    1.68      return false;
    1.69    }
    1.70 -  // Set all cards back to clean.
    1.71 -  void cleanup() {_g1h->cleanUpCardTable();}
    1.72    size_t cards_done() { return _cards_done;}
    1.73    size_t cards_looked_up() { return _cards;}
    1.74  };
    1.75 @@ -566,8 +558,9 @@
    1.76      update_rs_cl.set_region(r);
    1.77      HeapWord* stop_point =
    1.78        r->oops_on_card_seq_iterate_careful(scanRegion,
    1.79 -                                        &filter_then_update_rs_cset_oop_cl,
    1.80 -                                        false /* filter_young */);
    1.81 +                                          &filter_then_update_rs_cset_oop_cl,
    1.82 +                                          false /* filter_young */,
    1.83 +                                          NULL  /* card_ptr */);
    1.84  
    1.85      // Since this is performed in the event of an evacuation failure, we
    1.86      // we shouldn't see a non-null stop point
    1.87 @@ -735,12 +728,6 @@
    1.88                                  (OopClosure*)&mux :
    1.89                                  (OopClosure*)&update_rs_oop_cl));
    1.90  
    1.91 -  // Undirty the card.
    1.92 -  *card_ptr = CardTableModRefBS::clean_card_val();
    1.93 -  // We must complete this write before we do any of the reads below.
    1.94 -  OrderAccess::storeload();
    1.95 -  // And process it, being careful of unallocated portions of TLAB's.
    1.96 -
    1.97    // The region for the current card may be a young region. The
    1.98    // current card may have been a card that was evicted from the
    1.99    // card cache. When the card was inserted into the cache, we had
   1.100 @@ -749,7 +736,7 @@
   1.101    // and tagged as young.
   1.102    //
   1.103    // We wish to filter out cards for such a region but the current
   1.104 -  // thread, if we're running conucrrently, may "see" the young type
   1.105 +  // thread, if we're running concurrently, may "see" the young type
   1.106    // change at any time (so an earlier "is_young" check may pass or
   1.107    // fail arbitrarily). We tell the iteration code to perform this
   1.108    // filtering when it has been determined that there has been an actual
   1.109 @@ -759,7 +746,8 @@
   1.110    HeapWord* stop_point =
   1.111      r->oops_on_card_seq_iterate_careful(dirtyRegion,
   1.112                                          &filter_then_update_rs_oop_cl,
   1.113 -                                        filter_young);
   1.114 +                                        filter_young,
   1.115 +                                        card_ptr);
   1.116  
   1.117    // If stop_point is non-null, then we encountered an unallocated region
   1.118    // (perhaps the unfilled portion of a TLAB.)  For now, we'll dirty the

mercurial