src/share/vm/memory/cardTableRS.hpp

changeset 435
a61af66fc99e
child 441
73e96e5c30df
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/memory/cardTableRS.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,156 @@
     1.4 +/*
     1.5 + * Copyright 2001-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +class Space;
    1.29 +class OopsInGenClosure;
    1.30 +class DirtyCardToOopClosure;
    1.31 +
    1.32 +// This kind of "GenRemSet" uses a card table both as shared data structure
    1.33 +// for a mod ref barrier set and for the rem set information.
    1.34 +
    1.35 +class CardTableRS: public GenRemSet {
    1.36 +  friend class VMStructs;
    1.37 +  // Below are private classes used in impl.
    1.38 +  friend class VerifyCTSpaceClosure;
    1.39 +  friend class ClearNoncleanCardWrapper;
    1.40 +
    1.41 +  static jbyte clean_card_val() {
    1.42 +    return CardTableModRefBS::clean_card;
    1.43 +  }
    1.44 +
    1.45 +  static bool
    1.46 +  card_is_dirty_wrt_gen_iter(jbyte cv) {
    1.47 +    return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
    1.48 +  }
    1.49 +
    1.50 +  CardTableModRefBSForCTRS _ct_bs;
    1.51 +
    1.52 +  virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
    1.53 +
    1.54 +  void verify_space(Space* s, HeapWord* gen_start);
    1.55 +
    1.56 +  enum ExtendedCardValue {
    1.57 +    youngergen_card   = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
    1.58 +    // These are for parallel collection.
    1.59 +    // There are three P (parallel) youngergen card values.  In general, this
    1.60 +    // needs to be more than the number of generations (including the perm
    1.61 +    // gen) that might have younger_refs_do invoked on them separately.  So
    1.62 +    // if we add more gens, we have to add more values.
    1.63 +    youngergenP1_card  = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
    1.64 +    youngergenP2_card  = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
    1.65 +    youngergenP3_card  = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
    1.66 +    cur_youngergen_and_prev_nonclean_card =
    1.67 +      CardTableModRefBS::CT_MR_BS_last_reserved + 5
    1.68 +  };
    1.69 +
    1.70 +  // An array that contains, for each generation, the card table value last
    1.71 +  // used as the current value for a younger_refs_do iteration of that
    1.72 +  // portion of the table.  (The perm gen is index 0; other gens are at
    1.73 +  // their level plus 1.  They youngest gen is in the table, but will
    1.74 +  // always have the value "clean_card".)
    1.75 +  jbyte* _last_cur_val_in_gen;
    1.76 +
    1.77 +  jbyte _cur_youngergen_card_val;
    1.78 +
    1.79 +  jbyte cur_youngergen_card_val() {
    1.80 +    return _cur_youngergen_card_val;
    1.81 +  }
    1.82 +  void set_cur_youngergen_card_val(jbyte v) {
    1.83 +    _cur_youngergen_card_val = v;
    1.84 +  }
    1.85 +  bool is_prev_youngergen_card_val(jbyte v) {
    1.86 +    return
    1.87 +      youngergen_card <= v &&
    1.88 +      v < cur_youngergen_and_prev_nonclean_card &&
    1.89 +      v != _cur_youngergen_card_val;
    1.90 +  }
    1.91 +  // Return a youngergen_card_value that is not currently in use.
    1.92 +  jbyte find_unused_youngergenP_card_value();
    1.93 +
    1.94 +public:
    1.95 +  CardTableRS(MemRegion whole_heap, int max_covered_regions);
    1.96 +
    1.97 +  // *** GenRemSet functions.
    1.98 +  GenRemSet::Name rs_kind() { return GenRemSet::CardTable; }
    1.99 +
   1.100 +  CardTableRS* as_CardTableRS() { return this; }
   1.101 +
   1.102 +  CardTableModRefBS* ct_bs() { return &_ct_bs; }
   1.103 +
   1.104 +  // Override.
   1.105 +  void prepare_for_younger_refs_iterate(bool parallel);
   1.106 +
   1.107 +  // Card table entries are cleared before application; "blk" is
   1.108 +  // responsible for dirtying if the oop is still older-to-younger after
   1.109 +  // closure application.
   1.110 +  void younger_refs_iterate(Generation* g, OopsInGenClosure* blk);
   1.111 +
   1.112 +  void inline_write_ref_field_gc(oop* field, oop new_val) {
   1.113 +    jbyte* byte = _ct_bs.byte_for(field);
   1.114 +    *byte = youngergen_card;
   1.115 +  }
   1.116 +  void write_ref_field_gc_work(oop* field, oop new_val) {
   1.117 +    inline_write_ref_field_gc(field, new_val);
   1.118 +  }
   1.119 +
   1.120 +  // Override.  Might want to devirtualize this in the same fashion as
   1.121 +  // above.  Ensures that the value of the card for field says that it's
   1.122 +  // a younger card in the current collection.
   1.123 +  virtual void write_ref_field_gc_par(oop* field, oop new_val);
   1.124 +
   1.125 +  void resize_covered_region(MemRegion new_region);
   1.126 +
   1.127 +  bool is_aligned(HeapWord* addr) {
   1.128 +    return _ct_bs.is_card_aligned(addr);
   1.129 +  }
   1.130 +
   1.131 +  void verify();
   1.132 +  void verify_empty(MemRegion mr);
   1.133 +
   1.134 +  void clear(MemRegion mr) { _ct_bs.clear(mr); }
   1.135 +  void clear_into_younger(Generation* gen, bool clear_perm);
   1.136 +
   1.137 +  void invalidate(MemRegion mr) { _ct_bs.invalidate(mr); }
   1.138 +  void invalidate_or_clear(Generation* gen, bool younger, bool perm);
   1.139 +
   1.140 +  static uintx ct_max_alignment_constraint() {
   1.141 +    return CardTableModRefBS::ct_max_alignment_constraint();
   1.142 +  }
   1.143 +
   1.144 +  jbyte* byte_for(void* p)     { return _ct_bs.byte_for(p); }
   1.145 +  jbyte* byte_after(void* p)   { return _ct_bs.byte_after(p); }
   1.146 +  HeapWord* addr_for(jbyte* p) { return _ct_bs.addr_for(p); }
   1.147 +
   1.148 +  bool is_prev_nonclean_card_val(jbyte v) {
   1.149 +    return
   1.150 +      youngergen_card <= v &&
   1.151 +      v <= cur_youngergen_and_prev_nonclean_card &&
   1.152 +      v != _cur_youngergen_card_val;
   1.153 +  }
   1.154 +
   1.155 +  static bool youngergen_may_have_been_dirty(jbyte cv) {
   1.156 +    return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
   1.157 +  }
   1.158 +
   1.159 +};

mercurial