hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp
changeset 28207 6ad23566cbef
parent 27889 7d50f95e0076
child 28633 f346493c0f7d
equal deleted inserted replaced
28206:98aac9173d5f 28207:6ad23566cbef
    46 size_t HeapRegion::GrainBytes        = 0;
    46 size_t HeapRegion::GrainBytes        = 0;
    47 size_t HeapRegion::GrainWords        = 0;
    47 size_t HeapRegion::GrainWords        = 0;
    48 size_t HeapRegion::CardsPerRegion    = 0;
    48 size_t HeapRegion::CardsPerRegion    = 0;
    49 
    49 
    50 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
    50 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
    51                                  HeapRegion* hr, ExtendedOopClosure* cl,
    51                                  HeapRegion* hr,
    52                                  CardTableModRefBS::PrecisionStyle precision,
    52                                  G1ParPushHeapRSClosure* cl,
    53                                  FilterKind fk) :
    53                                  CardTableModRefBS::PrecisionStyle precision) :
    54   DirtyCardToOopClosure(hr, cl, precision, NULL),
    54   DirtyCardToOopClosure(hr, cl, precision, NULL),
    55   _hr(hr), _fk(fk), _g1(g1) { }
    55   _hr(hr), _rs_scan(cl), _g1(g1) { }
    56 
    56 
    57 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
    57 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
    58                                                    OopClosure* oc) :
    58                                                    OopClosure* oc) :
    59   _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
    59   _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
    60 
       
    61 template<class ClosureType>
       
    62 HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h,
       
    63                                HeapRegion* hr,
       
    64                                HeapWord* cur, HeapWord* top) {
       
    65   oop cur_oop = oop(cur);
       
    66   size_t oop_size = hr->block_size(cur);
       
    67   HeapWord* next_obj = cur + oop_size;
       
    68   while (next_obj < top) {
       
    69     // Keep filtering the remembered set.
       
    70     if (!g1h->is_obj_dead(cur_oop, hr)) {
       
    71       // Bottom lies entirely below top, so we can call the
       
    72       // non-memRegion version of oop_iterate below.
       
    73       cur_oop->oop_iterate(cl);
       
    74     }
       
    75     cur = next_obj;
       
    76     cur_oop = oop(cur);
       
    77     oop_size = hr->block_size(cur);
       
    78     next_obj = cur + oop_size;
       
    79   }
       
    80   return cur;
       
    81 }
       
    82 
    60 
    83 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
    61 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
    84                                       HeapWord* bottom,
    62                                       HeapWord* bottom,
    85                                       HeapWord* top) {
    63                                       HeapWord* top) {
    86   G1CollectedHeap* g1h = _g1;
    64   G1CollectedHeap* g1h = _g1;
    87   size_t oop_size;
    65   size_t oop_size;
    88   ExtendedOopClosure* cl2 = NULL;
    66   HeapWord* cur = bottom;
    89 
       
    90   FilterIntoCSClosure intoCSFilt(this, g1h, _cl);
       
    91   FilterOutOfRegionClosure outOfRegionFilt(_hr, _cl);
       
    92 
       
    93   switch (_fk) {
       
    94   case NoFilterKind:          cl2 = _cl; break;
       
    95   case IntoCSFilterKind:      cl2 = &intoCSFilt; break;
       
    96   case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
       
    97   default:                    ShouldNotReachHere();
       
    98   }
       
    99 
    67 
   100   // Start filtering what we add to the remembered set. If the object is
    68   // Start filtering what we add to the remembered set. If the object is
   101   // not considered dead, either because it is marked (in the mark bitmap)
    69   // not considered dead, either because it is marked (in the mark bitmap)
   102   // or it was allocated after marking finished, then we add it. Otherwise
    70   // or it was allocated after marking finished, then we add it. Otherwise
   103   // we can safely ignore the object.
    71   // we can safely ignore the object.
   104   if (!g1h->is_obj_dead(oop(bottom), _hr)) {
    72   if (!g1h->is_obj_dead(oop(cur), _hr)) {
   105     oop_size = oop(bottom)->oop_iterate(cl2, mr);
    73     oop_size = oop(cur)->oop_iterate(_rs_scan, mr);
   106   } else {
    74   } else {
   107     oop_size = _hr->block_size(bottom);
    75     oop_size = _hr->block_size(cur);
   108   }
    76   }
   109 
    77 
   110   bottom += oop_size;
    78   cur += oop_size;
   111 
    79 
   112   if (bottom < top) {
    80   if (cur < top) {
   113     // We replicate the loop below for several kinds of possible filters.
    81     oop cur_oop = oop(cur);
   114     switch (_fk) {
    82     oop_size = _hr->block_size(cur);
   115     case NoFilterKind:
    83     HeapWord* next_obj = cur + oop_size;
   116       bottom = walk_mem_region_loop(_cl, g1h, _hr, bottom, top);
    84     while (next_obj < top) {
   117       break;
    85       // Keep filtering the remembered set.
   118 
    86       if (!g1h->is_obj_dead(cur_oop, _hr)) {
   119     case IntoCSFilterKind: {
    87         // Bottom lies entirely below top, so we can call the
   120       FilterIntoCSClosure filt(this, g1h, _cl);
    88         // non-memRegion version of oop_iterate below.
   121       bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
    89         cur_oop->oop_iterate(_rs_scan);
   122       break;
    90       }
   123     }
    91       cur = next_obj;
   124 
    92       cur_oop = oop(cur);
   125     case OutOfRegionFilterKind: {
    93       oop_size = _hr->block_size(cur);
   126       FilterOutOfRegionClosure filt(_hr, _cl);
    94       next_obj = cur + oop_size;
   127       bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
       
   128       break;
       
   129     }
       
   130 
       
   131     default:
       
   132       ShouldNotReachHere();
       
   133     }
    95     }
   134 
    96 
   135     // Last object. Need to do dead-obj filtering here too.
    97     // Last object. Need to do dead-obj filtering here too.
   136     if (!g1h->is_obj_dead(oop(bottom), _hr)) {
    98     if (!g1h->is_obj_dead(oop(cur), _hr)) {
   137       oop(bottom)->oop_iterate(cl2, mr);
    99       oop(cur)->oop_iterate(_rs_scan, mr);
   138     }
   100     }
   139   }
   101   }
   140 }
   102 }
   141 
   103 
   142 size_t HeapRegion::max_region_size() {
   104 size_t HeapRegion::max_region_size() {