< prev index next >

src/hotspot/share/gc/shared/cardTableRS.cpp

Print this page




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/cardTableRS.hpp"
  27 #include "gc/shared/genCollectedHeap.hpp"
  28 #include "gc/shared/generation.hpp"
  29 #include "gc/shared/space.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/atomic.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/os.hpp"
  35 #include "utilities/macros.hpp"
  36 
  37 class HasAccumulatedModifiedOopsClosure : public KlassClosure {
  38   bool _found;
  39  public:
  40   HasAccumulatedModifiedOopsClosure() : _found(false) {}
  41   void do_klass(Klass* klass) {
  42     if (_found) {
  43       return;
  44     }
  45 
  46     if (klass->has_accumulated_modified_oops()) {
  47       _found = true;
  48     }
  49   }
  50   bool found() {
  51     return _found;
  52   }
  53 };
  54 
  55 bool KlassRemSet::mod_union_is_clear() {
  56   HasAccumulatedModifiedOopsClosure closure;
  57   ClassLoaderDataGraph::classes_do(&closure);
  58 
  59   return !closure.found();
  60 }
  61 
  62 
  63 class ClearKlassModUnionClosure : public KlassClosure {
  64  public:
  65   void do_klass(Klass* klass) {
  66     if (klass->has_accumulated_modified_oops()) {
  67       klass->clear_accumulated_modified_oops();
  68     }
  69   }
  70 };
  71 
  72 void KlassRemSet::clear_mod_union() {
  73   ClearKlassModUnionClosure closure;
  74   ClassLoaderDataGraph::classes_do(&closure);
  75 }

  76 
  77 CardTableRS::CardTableRS(MemRegion whole_heap) :
  78   _bs(NULL),
  79   _cur_youngergen_card_val(youngergenP1_card)
  80 {
  81   _ct_bs = new CardTableModRefBSForCTRS(whole_heap);
  82   _ct_bs->initialize();
  83   set_bs(_ct_bs);
  84   // max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations()
  85   // (which is always 2, young & old), but GenCollectedHeap has not been initialized yet.
  86   uint max_gens = 2;
  87   _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, max_gens + 1,
  88                          mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
  89   if (_last_cur_val_in_gen == NULL) {
  90     vm_exit_during_initialization("Could not create last_cur_val_in_gen array.");
  91   }
  92   for (uint i = 0; i < max_gens + 1; i++) {
  93     _last_cur_val_in_gen[i] = clean_card_val();
  94   }
  95   _ct_bs->set_CTRS(this);




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/cardTableRS.hpp"
  27 #include "gc/shared/genCollectedHeap.hpp"
  28 #include "gc/shared/generation.hpp"
  29 #include "gc/shared/space.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/atomic.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/os.hpp"
  35 #include "utilities/macros.hpp"
  36 
  37 class HasAccumulatedModifiedOopsClosure : public CLDClosure {
  38   bool _found;
  39  public:
  40   HasAccumulatedModifiedOopsClosure() : _found(false) {}
  41   void do_cld(ClassLoaderData* cld) {
  42     if (_found) {
  43       return;
  44     }
  45 
  46     if (cld->has_accumulated_modified_oops()) {
  47       _found = true;
  48     }
  49   }
  50   bool found() {
  51     return _found;
  52   }
  53 };
  54 
  55 bool CLDRemSet::mod_union_is_clear() {
  56   HasAccumulatedModifiedOopsClosure closure;
  57   ClassLoaderDataGraph::cld_do(&closure);
  58 
  59   return !closure.found();
  60 }
  61 
  62 
  63 class ClearCLDModUnionClosure : public CLDClosure {
  64  public:
  65   void do_cld(ClassLoaderData* cld) {
  66     if (cld->has_accumulated_modified_oops()) {
  67       cld->clear_accumulated_modified_oops();
  68     }
  69   }
  70 };
  71 
  72 void CLDRemSet::clear_mod_union() {
  73   ClearCLDModUnionClosure closure;
  74   ClassLoaderDataGraph::cld_do(&closure);
  75 }
  76 
  77 
  78 CardTableRS::CardTableRS(MemRegion whole_heap) :
  79   _bs(NULL),
  80   _cur_youngergen_card_val(youngergenP1_card)
  81 {
  82   _ct_bs = new CardTableModRefBSForCTRS(whole_heap);
  83   _ct_bs->initialize();
  84   set_bs(_ct_bs);
  85   // max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations()
  86   // (which is always 2, young & old), but GenCollectedHeap has not been initialized yet.
  87   uint max_gens = 2;
  88   _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, max_gens + 1,
  89                          mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
  90   if (_last_cur_val_in_gen == NULL) {
  91     vm_exit_during_initialization("Could not create last_cur_val_in_gen array.");
  92   }
  93   for (uint i = 0; i < max_gens + 1; i++) {
  94     _last_cur_val_in_gen[i] = clean_card_val();
  95   }
  96   _ct_bs->set_CTRS(this);


< prev index next >