Print this page
rev 2591 : [mq]: g1-reference-processing

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/heapRegion.cpp
          +++ new/src/share/vm/gc_implementation/g1/heapRegion.cpp
↓ open down ↓ 37 lines elided ↑ open up ↑
  38   38  int HeapRegion::GrainBytes        = 0;
  39   39  int HeapRegion::GrainWords        = 0;
  40   40  int HeapRegion::CardsPerRegion    = 0;
  41   41  
  42   42  HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
  43   43                                   HeapRegion* hr, OopClosure* cl,
  44   44                                   CardTableModRefBS::PrecisionStyle precision,
  45   45                                   FilterKind fk) :
  46   46    ContiguousSpaceDCTOC(hr, cl, precision, NULL),
  47   47    _hr(hr), _fk(fk), _g1(g1)
  48      -{}
       48 +{ }
  49   49  
  50   50  FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
  51   51                                                     OopClosure* oc) :
  52   52    _r_bottom(r->bottom()), _r_end(r->end()),
  53   53    _oc(oc), _out_of_region(0)
  54   54  {}
  55   55  
  56   56  class VerifyLiveClosure: public OopClosure {
  57   57  private:
  58   58    G1CollectedHeap* _g1h;
↓ open down ↓ 148 lines elided ↑ open up ↑
 207  207  
 208  208  void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr,
 209  209                                                HeapWord* bottom,
 210  210                                                HeapWord* top,
 211  211                                                OopClosure* cl) {
 212  212    G1CollectedHeap* g1h = _g1;
 213  213  
 214  214    int oop_size;
 215  215  
 216  216    OopClosure* cl2 = cl;
 217      -  FilterIntoCSClosure intoCSFilt(this, g1h, cl);
      217 +
      218 +  // If we are scanning the remembered sets looking for refs
      219 +  // into the collection set during an evacuation pause then
      220 +  // we will want to 'discover' reference objects that point
      221 +  // to referents in the collection set.
      222 +  //
      223 +  // Unfortunately it is an instance of FilterIntoCSClosure
      224 +  // that is iterated over the reference fields of oops in
      225 +  // mr (and not the G1ParPushHeapRSClosure - which is the
      226 +  // cl parameter).
      227 +  // If we set the _ref_processor field in the FilterIntoCSClosure
      228 +  // instance, all the reference objects that are walked
      229 +  // (regardless of whether their referent object's are in
      230 +  // the cset) will be 'discovered'.
      231 +  // 
      232 +  // The G1STWIsAlive closure considers a referent object that
      233 +  // is outside the cset as alive. The G1CopyingKeepAliveClosure
      234 +  // skips referents that are not in the cset.
      235 +  //
      236 +  // Therefore reference objects in mr with a referent that is
      237 +  // outside the cset should be OK.
      238 +
      239 +  ReferenceProcessor* rp = _cl->_ref_processor;
      240 +  if (rp != NULL) {
      241 +    assert(rp == _g1->ref_processor_stw(), "should be stw");
      242 +    assert(_fk == IntoCSFilterKind, "should be looking for refs into CS");
      243 +  }
      244 +
      245 +  FilterIntoCSClosure intoCSFilt(this, g1h, cl, rp);
 218  246    FilterOutOfRegionClosure outOfRegionFilt(_hr, cl);
      247 +
 219  248    switch (_fk) {
 220  249    case IntoCSFilterKind:      cl2 = &intoCSFilt; break;
 221  250    case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
 222  251    }
 223  252  
 224  253    // Start filtering what we add to the remembered set. If the object is
 225  254    // not considered dead, either because it is marked (in the mark bitmap)
 226  255    // or it was allocated after marking finished, then we add it. Otherwise
 227  256    // we can safely ignore the object.
 228  257    if (!g1h->is_obj_dead(oop(bottom), _hr)) {
↓ open down ↓ 3 lines elided ↑ open up ↑
 232  261    }
 233  262  
 234  263    bottom += oop_size;
 235  264  
 236  265    if (bottom < top) {
 237  266      // We replicate the loop below for several kinds of possible filters.
 238  267      switch (_fk) {
 239  268      case NoFilterKind:
 240  269        bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top);
 241  270        break;
      271 +
 242  272      case IntoCSFilterKind: {
 243      -      FilterIntoCSClosure filt(this, g1h, cl);
      273 +      FilterIntoCSClosure filt(this, g1h, cl, rp);
 244  274        bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
 245  275        break;
 246  276      }
      277 +
 247  278      case OutOfRegionFilterKind: {
 248  279        FilterOutOfRegionClosure filt(_hr, cl);
 249  280        bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
 250  281        break;
 251  282      }
      283 +
 252  284      default:
 253  285        ShouldNotReachHere();
 254  286      }
 255  287  
 256  288      // Last object. Need to do dead-obj filtering here too.
 257  289      if (!g1h->is_obj_dead(oop(bottom), _hr)) {
 258  290        oop(bottom)->oop_iterate(cl2, mr);
 259  291      }
 260  292    }
 261  293  }
↓ open down ↓ 214 lines elided ↑ open up ↑
 476  508  }
 477  509  #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
 478  510  #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
 479  511  #endif // _MSC_VER
 480  512  
 481  513  
 482  514  HeapRegion::
 483  515  HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray,
 484  516             MemRegion mr, bool is_zeroed)
 485  517    : G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed),
 486      -    _next_fk(HeapRegionDCTOC::NoFilterKind), _hrs_index(hrs_index),
      518 +    _hrs_index(hrs_index),
 487  519      _humongous_type(NotHumongous), _humongous_start_region(NULL),
 488  520      _in_collection_set(false),
 489  521      _next_in_special_set(NULL), _orig_end(NULL),
 490  522      _claimed(InitialClaimValue), _evacuation_failed(false),
 491  523      _prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1),
 492  524      _young_type(NotYoung), _next_young_region(NULL),
 493  525      _next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false),
 494  526  #ifdef ASSERT
 495  527      _containing_set(NULL),
 496  528  #endif // ASSERT
↓ open down ↓ 469 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX