src/share/vm/memory/cardTableRS.hpp

Fri, 15 Feb 2008 07:01:10 -0800

author
jmasa
date
Fri, 15 Feb 2008 07:01:10 -0800
changeset 441
73e96e5c30df
parent 435
a61af66fc99e
child 548
ba764ed4b6f2
permissions
-rw-r--r--

6624765: Guarantee failure "Unexpected dirty card found"
Summary: In verification take into account partial coverage of a region by a card and expansion of the card table.
Reviewed-by: ysr, apetrusenko

duke@435 1 /*
duke@435 2 * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 class Space;
duke@435 26 class OopsInGenClosure;
duke@435 27 class DirtyCardToOopClosure;
duke@435 28
duke@435 29 // This kind of "GenRemSet" uses a card table both as shared data structure
duke@435 30 // for a mod ref barrier set and for the rem set information.
duke@435 31
duke@435 32 class CardTableRS: public GenRemSet {
duke@435 33 friend class VMStructs;
duke@435 34 // Below are private classes used in impl.
duke@435 35 friend class VerifyCTSpaceClosure;
duke@435 36 friend class ClearNoncleanCardWrapper;
duke@435 37
duke@435 38 static jbyte clean_card_val() {
duke@435 39 return CardTableModRefBS::clean_card;
duke@435 40 }
duke@435 41
duke@435 42 static bool
duke@435 43 card_is_dirty_wrt_gen_iter(jbyte cv) {
duke@435 44 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
duke@435 45 }
duke@435 46
duke@435 47 CardTableModRefBSForCTRS _ct_bs;
duke@435 48
duke@435 49 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
duke@435 50
duke@435 51 void verify_space(Space* s, HeapWord* gen_start);
duke@435 52
duke@435 53 enum ExtendedCardValue {
duke@435 54 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
duke@435 55 // These are for parallel collection.
duke@435 56 // There are three P (parallel) youngergen card values. In general, this
duke@435 57 // needs to be more than the number of generations (including the perm
duke@435 58 // gen) that might have younger_refs_do invoked on them separately. So
duke@435 59 // if we add more gens, we have to add more values.
duke@435 60 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
duke@435 61 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
duke@435 62 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
duke@435 63 cur_youngergen_and_prev_nonclean_card =
duke@435 64 CardTableModRefBS::CT_MR_BS_last_reserved + 5
duke@435 65 };
duke@435 66
duke@435 67 // An array that contains, for each generation, the card table value last
duke@435 68 // used as the current value for a younger_refs_do iteration of that
duke@435 69 // portion of the table. (The perm gen is index 0; other gens are at
duke@435 70 // their level plus 1. They youngest gen is in the table, but will
duke@435 71 // always have the value "clean_card".)
duke@435 72 jbyte* _last_cur_val_in_gen;
duke@435 73
duke@435 74 jbyte _cur_youngergen_card_val;
duke@435 75
duke@435 76 jbyte cur_youngergen_card_val() {
duke@435 77 return _cur_youngergen_card_val;
duke@435 78 }
duke@435 79 void set_cur_youngergen_card_val(jbyte v) {
duke@435 80 _cur_youngergen_card_val = v;
duke@435 81 }
duke@435 82 bool is_prev_youngergen_card_val(jbyte v) {
duke@435 83 return
duke@435 84 youngergen_card <= v &&
duke@435 85 v < cur_youngergen_and_prev_nonclean_card &&
duke@435 86 v != _cur_youngergen_card_val;
duke@435 87 }
duke@435 88 // Return a youngergen_card_value that is not currently in use.
duke@435 89 jbyte find_unused_youngergenP_card_value();
duke@435 90
duke@435 91 public:
duke@435 92 CardTableRS(MemRegion whole_heap, int max_covered_regions);
duke@435 93
duke@435 94 // *** GenRemSet functions.
duke@435 95 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; }
duke@435 96
duke@435 97 CardTableRS* as_CardTableRS() { return this; }
duke@435 98
duke@435 99 CardTableModRefBS* ct_bs() { return &_ct_bs; }
duke@435 100
duke@435 101 // Override.
duke@435 102 void prepare_for_younger_refs_iterate(bool parallel);
duke@435 103
duke@435 104 // Card table entries are cleared before application; "blk" is
duke@435 105 // responsible for dirtying if the oop is still older-to-younger after
duke@435 106 // closure application.
duke@435 107 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk);
duke@435 108
duke@435 109 void inline_write_ref_field_gc(oop* field, oop new_val) {
duke@435 110 jbyte* byte = _ct_bs.byte_for(field);
duke@435 111 *byte = youngergen_card;
duke@435 112 }
duke@435 113 void write_ref_field_gc_work(oop* field, oop new_val) {
duke@435 114 inline_write_ref_field_gc(field, new_val);
duke@435 115 }
duke@435 116
duke@435 117 // Override. Might want to devirtualize this in the same fashion as
duke@435 118 // above. Ensures that the value of the card for field says that it's
duke@435 119 // a younger card in the current collection.
duke@435 120 virtual void write_ref_field_gc_par(oop* field, oop new_val);
duke@435 121
duke@435 122 void resize_covered_region(MemRegion new_region);
duke@435 123
duke@435 124 bool is_aligned(HeapWord* addr) {
duke@435 125 return _ct_bs.is_card_aligned(addr);
duke@435 126 }
duke@435 127
duke@435 128 void verify();
jmasa@441 129 void verify_aligned_region_empty(MemRegion mr);
duke@435 130
duke@435 131 void clear(MemRegion mr) { _ct_bs.clear(mr); }
duke@435 132 void clear_into_younger(Generation* gen, bool clear_perm);
duke@435 133
duke@435 134 void invalidate(MemRegion mr) { _ct_bs.invalidate(mr); }
duke@435 135 void invalidate_or_clear(Generation* gen, bool younger, bool perm);
duke@435 136
duke@435 137 static uintx ct_max_alignment_constraint() {
duke@435 138 return CardTableModRefBS::ct_max_alignment_constraint();
duke@435 139 }
duke@435 140
duke@435 141 jbyte* byte_for(void* p) { return _ct_bs.byte_for(p); }
duke@435 142 jbyte* byte_after(void* p) { return _ct_bs.byte_after(p); }
duke@435 143 HeapWord* addr_for(jbyte* p) { return _ct_bs.addr_for(p); }
duke@435 144
duke@435 145 bool is_prev_nonclean_card_val(jbyte v) {
duke@435 146 return
duke@435 147 youngergen_card <= v &&
duke@435 148 v <= cur_youngergen_and_prev_nonclean_card &&
duke@435 149 v != _cur_youngergen_card_val;
duke@435 150 }
duke@435 151
duke@435 152 static bool youngergen_may_have_been_dirty(jbyte cv) {
duke@435 153 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
duke@435 154 }
duke@435 155
duke@435 156 };

mercurial