< prev index next >

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

Print this page
rev 7696 : 8030646: track collection set membership in one place


6055 
6056         start_sec = os::elapsedTime();
6057         non_young = false;
6058       }
6059     } else {
6060       if (!cur->is_young()) {
6061         double end_sec = os::elapsedTime();
6062         double elapsed_ms = (end_sec - start_sec) * 1000.0;
6063         young_time_ms += elapsed_ms;
6064 
6065         start_sec = os::elapsedTime();
6066         non_young = true;
6067       }
6068     }
6069 
6070     rs_lengths += cur->rem_set()->occupied_locked();
6071 
6072     HeapRegion* next = cur->next_in_collection_set();
6073     assert(cur->in_collection_set(), "bad CS");
6074     cur->set_next_in_collection_set(NULL);
6075     cur->set_in_collection_set(false);
6076 
6077     if (cur->is_young()) {
6078       int index = cur->young_index_in_cset();
6079       assert(index != -1, "invariant");
6080       assert((uint) index < policy->young_cset_region_length(), "invariant");
6081       size_t words_survived = _surviving_young_words[index];
6082       cur->record_surv_words_in_group(words_survived);
6083 
6084       // At this point the we have 'popped' cur from the collection set
6085       // (linked via next_in_collection_set()) but it is still in the
6086       // young list (linked via next_young_region()). Clear the
6087       // _next_young_region field.
6088       cur->set_next_young_region(NULL);
6089     } else {
6090       int index = cur->young_index_in_cset();
6091       assert(index == -1, "invariant");
6092     }
6093 
6094     assert( (cur->is_young() && cur->young_index_in_cset() > -1) ||
6095             (!cur->is_young() && cur->young_index_in_cset() == -1),


6281 
6282   g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms((os::elapsedTime() - start_time) * 1000.0,
6283                                                                     cl.humongous_reclaimed());
6284 }
6285 
6286 // This routine is similar to the above but does not record
6287 // any policy statistics or update free lists; we are abandoning
6288 // the current incremental collection set in preparation of a
6289 // full collection. After the full GC we will start to build up
6290 // the incremental collection set again.
6291 // This is only called when we're doing a full collection
6292 // and is immediately followed by the tearing down of the young list.
6293 
6294 void G1CollectedHeap::abandon_collection_set(HeapRegion* cs_head) {
6295   HeapRegion* cur = cs_head;
6296 
6297   while (cur != NULL) {
6298     HeapRegion* next = cur->next_in_collection_set();
6299     assert(cur->in_collection_set(), "bad CS");
6300     cur->set_next_in_collection_set(NULL);
6301     cur->set_in_collection_set(false);
6302     cur->set_young_index_in_cset(-1);
6303     cur = next;
6304   }
6305 }
6306 
6307 void G1CollectedHeap::set_free_regions_coming() {
6308   if (G1ConcRegionFreeingVerbose) {
6309     gclog_or_tty->print_cr("G1ConcRegionFreeing [cm thread] : "
6310                            "setting free regions coming");
6311   }
6312 
6313   assert(!free_regions_coming(), "pre-condition");
6314   _free_regions_coming = true;
6315 }
6316 
6317 void G1CollectedHeap::reset_free_regions_coming() {
6318   assert(free_regions_coming(), "pre-condition");
6319 
6320   {
6321     MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);




6055 
6056         start_sec = os::elapsedTime();
6057         non_young = false;
6058       }
6059     } else {
6060       if (!cur->is_young()) {
6061         double end_sec = os::elapsedTime();
6062         double elapsed_ms = (end_sec - start_sec) * 1000.0;
6063         young_time_ms += elapsed_ms;
6064 
6065         start_sec = os::elapsedTime();
6066         non_young = true;
6067       }
6068     }
6069 
6070     rs_lengths += cur->rem_set()->occupied_locked();
6071 
6072     HeapRegion* next = cur->next_in_collection_set();
6073     assert(cur->in_collection_set(), "bad CS");
6074     cur->set_next_in_collection_set(NULL);
6075     clear_in_cset_fast_test(cur);
6076 
6077     if (cur->is_young()) {
6078       int index = cur->young_index_in_cset();
6079       assert(index != -1, "invariant");
6080       assert((uint) index < policy->young_cset_region_length(), "invariant");
6081       size_t words_survived = _surviving_young_words[index];
6082       cur->record_surv_words_in_group(words_survived);
6083 
6084       // At this point the we have 'popped' cur from the collection set
6085       // (linked via next_in_collection_set()) but it is still in the
6086       // young list (linked via next_young_region()). Clear the
6087       // _next_young_region field.
6088       cur->set_next_young_region(NULL);
6089     } else {
6090       int index = cur->young_index_in_cset();
6091       assert(index == -1, "invariant");
6092     }
6093 
6094     assert( (cur->is_young() && cur->young_index_in_cset() > -1) ||
6095             (!cur->is_young() && cur->young_index_in_cset() == -1),


6281 
6282   g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms((os::elapsedTime() - start_time) * 1000.0,
6283                                                                     cl.humongous_reclaimed());
6284 }
6285 
6286 // This routine is similar to the above but does not record
6287 // any policy statistics or update free lists; we are abandoning
6288 // the current incremental collection set in preparation of a
6289 // full collection. After the full GC we will start to build up
6290 // the incremental collection set again.
6291 // This is only called when we're doing a full collection
6292 // and is immediately followed by the tearing down of the young list.
6293 
6294 void G1CollectedHeap::abandon_collection_set(HeapRegion* cs_head) {
6295   HeapRegion* cur = cs_head;
6296 
6297   while (cur != NULL) {
6298     HeapRegion* next = cur->next_in_collection_set();
6299     assert(cur->in_collection_set(), "bad CS");
6300     cur->set_next_in_collection_set(NULL);
6301     clear_in_cset_fast_test(cur);
6302     cur->set_young_index_in_cset(-1);
6303     cur = next;
6304   }
6305 }
6306 
6307 void G1CollectedHeap::set_free_regions_coming() {
6308   if (G1ConcRegionFreeingVerbose) {
6309     gclog_or_tty->print_cr("G1ConcRegionFreeing [cm thread] : "
6310                            "setting free regions coming");
6311   }
6312 
6313   assert(!free_regions_coming(), "pre-condition");
6314   _free_regions_coming = true;
6315 }
6316 
6317 void G1CollectedHeap::reset_free_regions_coming() {
6318   assert(free_regions_coming(), "pre-condition");
6319 
6320   {
6321     MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);


< prev index next >