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

Print this page
rev 5920 : 8035406: Improve data structure for Code Cache remembered sets
Summary: Change the code cache remembered sets data structure from a GrowableArray to a chunked list of nmethods. This makes the data structure more amenable to parallelization, and decreases freeing time.
Reviewed-by:
rev 5921 : 8027295: Free CSet takes ~50% of young pause time
Summary: Improve fast card cache iteration and avoid taking locks when freeing the collection set.
Reviewed-by:
   1 /*
   2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 188   // The cast to int is safe, given that we've bounded region_size by
 189   // MIN_REGION_SIZE and MAX_REGION_SIZE.
 190   GrainBytes = (size_t)region_size;
 191 
 192   guarantee(GrainWords == 0, "we should only set it once");
 193   GrainWords = GrainBytes >> LogHeapWordSize;
 194   guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity");
 195 
 196   guarantee(CardsPerRegion == 0, "we should only set it once");
 197   CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
 198 }
 199 
 200 void HeapRegion::reset_after_compaction() {
 201   G1OffsetTableContigSpace::reset_after_compaction();
 202   // After a compaction the mark bitmap is invalid, so we must
 203   // treat all objects as being inside the unmarked area.
 204   zero_marked_bytes();
 205   init_top_at_mark_start();
 206 }
 207 
 208 void HeapRegion::hr_clear(bool par, bool clear_space) {
 209   assert(_humongous_type == NotHumongous,
 210          "we should have already filtered out humongous regions");
 211   assert(_humongous_start_region == NULL,
 212          "we should have already filtered out humongous regions");
 213   assert(_end == _orig_end,
 214          "we should have already filtered out humongous regions");
 215 
 216   _in_collection_set = false;
 217 
 218   set_young_index_in_cset(-1);
 219   uninstall_surv_rate_group();
 220   set_young_type(NotYoung);
 221   reset_pre_dummy_top();
 222 
 223   if (!par) {
 224     // If this is parallel, this will be done later.
 225     HeapRegionRemSet* hrrs = rem_set();



 226     hrrs->clear();

 227     _claimed = InitialClaimValue;
 228   }
 229   zero_marked_bytes();
 230 
 231   _offsets.resize(HeapRegion::GrainWords);
 232   init_top_at_mark_start();
 233   if (clear_space) clear(SpaceDecorator::Mangle);
 234 }
 235 
 236 void HeapRegion::par_clear() {
 237   assert(used() == 0, "the region should have been already cleared");
 238   assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
 239   HeapRegionRemSet* hrrs = rem_set();
 240   hrrs->clear();
 241   CardTableModRefBS* ct_bs =
 242                    (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set();
 243   ct_bs->clear(MemRegion(bottom(), end()));
 244 }
 245 
 246 void HeapRegion::calc_gc_efficiency() {


   1 /*
   2  * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 188   // The cast to int is safe, given that we've bounded region_size by
 189   // MIN_REGION_SIZE and MAX_REGION_SIZE.
 190   GrainBytes = (size_t)region_size;
 191 
 192   guarantee(GrainWords == 0, "we should only set it once");
 193   GrainWords = GrainBytes >> LogHeapWordSize;
 194   guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity");
 195 
 196   guarantee(CardsPerRegion == 0, "we should only set it once");
 197   CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
 198 }
 199 
 200 void HeapRegion::reset_after_compaction() {
 201   G1OffsetTableContigSpace::reset_after_compaction();
 202   // After a compaction the mark bitmap is invalid, so we must
 203   // treat all objects as being inside the unmarked area.
 204   zero_marked_bytes();
 205   init_top_at_mark_start();
 206 }
 207 
 208 void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) {
 209   assert(_humongous_type == NotHumongous,
 210          "we should have already filtered out humongous regions");
 211   assert(_humongous_start_region == NULL,
 212          "we should have already filtered out humongous regions");
 213   assert(_end == _orig_end,
 214          "we should have already filtered out humongous regions");
 215 
 216   _in_collection_set = false;
 217 
 218   set_young_index_in_cset(-1);
 219   uninstall_surv_rate_group();
 220   set_young_type(NotYoung);
 221   reset_pre_dummy_top();
 222 
 223   if (!par) {
 224     // If this is parallel, this will be done later.
 225     HeapRegionRemSet* hrrs = rem_set();
 226     if (locked) {
 227       hrrs->clear_locked();
 228     } else {
 229       hrrs->clear();
 230     }
 231     _claimed = InitialClaimValue;
 232   }
 233   zero_marked_bytes();
 234 
 235   _offsets.resize(HeapRegion::GrainWords);
 236   init_top_at_mark_start();
 237   if (clear_space) clear(SpaceDecorator::Mangle);
 238 }
 239 
 240 void HeapRegion::par_clear() {
 241   assert(used() == 0, "the region should have been already cleared");
 242   assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
 243   HeapRegionRemSet* hrrs = rem_set();
 244   hrrs->clear();
 245   CardTableModRefBS* ct_bs =
 246                    (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set();
 247   ct_bs->clear(MemRegion(bottom(), end()));
 248 }
 249 
 250 void HeapRegion::calc_gc_efficiency() {