hotspot/src/share/vm/gc/g1/concurrentMark.inline.hpp
changeset 33786 ac8da6513351
parent 33740 bede37d20aaf
child 34282 92f8f8941296
equal deleted inserted replaced
33785:f5e6ef11d24b 33786:ac8da6513351
    87   HeapWord* start = mr.start();
    87   HeapWord* start = mr.start();
    88   HeapWord* end = mr.end();
    88   HeapWord* end = mr.end();
    89   size_t region_size_bytes = mr.byte_size();
    89   size_t region_size_bytes = mr.byte_size();
    90   uint index = hr->hrm_index();
    90   uint index = hr->hrm_index();
    91 
    91 
    92   assert(!hr->is_continues_humongous(), "should not be HC region");
       
    93   assert(hr == g1h->heap_region_containing(start), "sanity");
    92   assert(hr == g1h->heap_region_containing(start), "sanity");
    94   assert(hr == g1h->heap_region_containing(mr.last()), "sanity");
       
    95   assert(marked_bytes_array != NULL, "pre-condition");
    93   assert(marked_bytes_array != NULL, "pre-condition");
    96   assert(task_card_bm != NULL, "pre-condition");
    94   assert(task_card_bm != NULL, "pre-condition");
    97 
    95 
    98   // Add to the task local marked bytes for this region.
    96   // Add to the task local marked bytes for this region.
    99   marked_bytes_array[index] += region_size_bytes;
    97   marked_bytes_array[index] += region_size_bytes;
   114   // the 'par' BitMap routines.
   112   // the 'par' BitMap routines.
   115   // Set bits in the exclusive bit range [start_idx, end_idx).
   113   // Set bits in the exclusive bit range [start_idx, end_idx).
   116   set_card_bitmap_range(task_card_bm, start_idx, end_idx, false /* is_par */);
   114   set_card_bitmap_range(task_card_bm, start_idx, end_idx, false /* is_par */);
   117 }
   115 }
   118 
   116 
   119 // Counts the given memory region in the task/worker counting
       
   120 // data structures for the given worker id.
       
   121 inline void ConcurrentMark::count_region(MemRegion mr,
       
   122                                          HeapRegion* hr,
       
   123                                          uint worker_id) {
       
   124   size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
       
   125   BitMap* task_card_bm = count_card_bitmap_for(worker_id);
       
   126   count_region(mr, hr, marked_bytes_array, task_card_bm);
       
   127 }
       
   128 
       
   129 // Counts the given object in the given task/worker counting data structures.
   117 // Counts the given object in the given task/worker counting data structures.
   130 inline void ConcurrentMark::count_object(oop obj,
   118 inline void ConcurrentMark::count_object(oop obj,
   131                                          HeapRegion* hr,
   119                                          HeapRegion* hr,
   132                                          size_t* marked_bytes_array,
   120                                          size_t* marked_bytes_array,
   133                                          BitMap* task_card_bm) {
   121                                          BitMap* task_card_bm,
   134   MemRegion mr((HeapWord*)obj, obj->size());
   122                                          size_t word_size) {
   135   count_region(mr, hr, marked_bytes_array, task_card_bm);
   123   assert(!hr->is_continues_humongous(), "Cannot enter count_object with continues humongous");
       
   124   if (!hr->is_starts_humongous()) {
       
   125     MemRegion mr((HeapWord*)obj, word_size);
       
   126     count_region(mr, hr, marked_bytes_array, task_card_bm);
       
   127   } else {
       
   128     do {
       
   129       MemRegion mr(hr->bottom(), hr->top());
       
   130       count_region(mr, hr, marked_bytes_array, task_card_bm);
       
   131       hr = _g1h->next_region_in_humongous(hr);
       
   132     } while (hr != NULL);
       
   133   }
   136 }
   134 }
   137 
   135 
   138 // Attempts to mark the given object and, if successful, counts
   136 // Attempts to mark the given object and, if successful, counts
   139 // the object in the given task/worker counting structures.
   137 // the object in the given task/worker counting structures.
   140 inline bool ConcurrentMark::par_mark_and_count(oop obj,
   138 inline bool ConcurrentMark::par_mark_and_count(oop obj,
   141                                                HeapRegion* hr,
   139                                                HeapRegion* hr,
   142                                                size_t* marked_bytes_array,
   140                                                size_t* marked_bytes_array,
   143                                                BitMap* task_card_bm) {
   141                                                BitMap* task_card_bm) {
   144   HeapWord* addr = (HeapWord*)obj;
   142   if (_nextMarkBitMap->parMark((HeapWord*)obj)) {
   145   if (_nextMarkBitMap->parMark(addr)) {
       
   146     // Update the task specific count data for the object.
   143     // Update the task specific count data for the object.
   147     count_object(obj, hr, marked_bytes_array, task_card_bm);
   144     count_object(obj, hr, marked_bytes_array, task_card_bm, obj->size());
   148     return true;
   145     return true;
   149   }
   146   }
   150   return false;
   147   return false;
   151 }
   148 }
   152 
   149 
   155 // given worker id.
   152 // given worker id.
   156 inline bool ConcurrentMark::par_mark_and_count(oop obj,
   153 inline bool ConcurrentMark::par_mark_and_count(oop obj,
   157                                                size_t word_size,
   154                                                size_t word_size,
   158                                                HeapRegion* hr,
   155                                                HeapRegion* hr,
   159                                                uint worker_id) {
   156                                                uint worker_id) {
   160   HeapWord* addr = (HeapWord*)obj;
   157   if (_nextMarkBitMap->parMark((HeapWord*)obj)) {
   161   if (_nextMarkBitMap->parMark(addr)) {
   158     size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
   162     MemRegion mr(addr, word_size);
   159     BitMap* task_card_bm = count_card_bitmap_for(worker_id);
   163     count_region(mr, hr, worker_id);
   160     count_object(obj, hr, marked_bytes_array, task_card_bm, word_size);
   164     return true;
   161     return true;
   165   }
   162   }
   166   return false;
   163   return false;
   167 }
   164 }
   168 
   165 
   349     assert(obj != NULL, "null check is implicit");
   346     assert(obj != NULL, "null check is implicit");
   350     if (!_nextMarkBitMap->isMarked(objAddr)) {
   347     if (!_nextMarkBitMap->isMarked(objAddr)) {
   351       // Only get the containing region if the object is not marked on the
   348       // Only get the containing region if the object is not marked on the
   352       // bitmap (otherwise, it's a waste of time since we won't do
   349       // bitmap (otherwise, it's a waste of time since we won't do
   353       // anything with it).
   350       // anything with it).
   354       HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
   351       HeapRegion* hr = _g1h->heap_region_containing(obj);
   355       if (!hr->obj_allocated_since_next_marking(obj)) {
   352       if (!hr->obj_allocated_since_next_marking(obj)) {
   356         make_reference_grey(obj, hr);
   353         make_reference_grey(obj, hr);
   357       }
   354       }
   358     }
   355     }
   359   }
   356   }
   369 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
   366 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
   370                                      uint worker_id, HeapRegion* hr) {
   367                                      uint worker_id, HeapRegion* hr) {
   371   assert(obj != NULL, "pre-condition");
   368   assert(obj != NULL, "pre-condition");
   372   HeapWord* addr = (HeapWord*) obj;
   369   HeapWord* addr = (HeapWord*) obj;
   373   if (hr == NULL) {
   370   if (hr == NULL) {
   374     hr = _g1h->heap_region_containing_raw(addr);
   371     hr = _g1h->heap_region_containing(addr);
   375   } else {
   372   } else {
   376     assert(hr->is_in(addr), "pre-condition");
   373     assert(hr->is_in(addr), "pre-condition");
   377   }
   374   }
   378   assert(hr != NULL, "sanity");
   375   assert(hr != NULL, "sanity");
   379   // Given that we're looking for a region that contains an object
   376   // Given that we're looking for a region that contains an object
   380   // header it's impossible to get back a HC region.
   377   // header it's impossible to get back a HC region.
   381   assert(!hr->is_continues_humongous(), "sanity");
   378   assert(!hr->is_continues_humongous(), "sanity");
   382 
   379 
   383   // We cannot assert that word_size == obj->size() given that obj
       
   384   // might not be in a consistent state (another thread might be in
       
   385   // the process of copying it). So the best thing we can do is to
       
   386   // assert that word_size is under an upper bound which is its
       
   387   // containing region's capacity.
       
   388   assert(word_size * HeapWordSize <= hr->capacity(),
       
   389          "size: " SIZE_FORMAT " capacity: " SIZE_FORMAT " " HR_FORMAT,
       
   390          word_size * HeapWordSize, hr->capacity(),
       
   391          HR_FORMAT_PARAMS(hr));
       
   392 
       
   393   if (addr < hr->next_top_at_mark_start()) {
   380   if (addr < hr->next_top_at_mark_start()) {
   394     if (!_nextMarkBitMap->isMarked(addr)) {
   381     if (!_nextMarkBitMap->isMarked(addr)) {
   395       par_mark_and_count(obj, word_size, hr, worker_id);
   382       par_mark_and_count(obj, word_size, hr, worker_id);
   396     }
   383     }
   397   }
   384   }