src/share/vm/memory/cardTableRS.hpp

Wed, 15 Feb 2012 10:12:55 -0800

author
never
date
Wed, 15 Feb 2012 10:12:55 -0800
changeset 3571
09d00c18e323
parent 2889
fc2b798ab316
child 3642
c7a555a9449a
permissions
-rw-r--r--

7145537: minor tweaks to LogEvents
Reviewed-by: kvn, twisti

duke@435 1 /*
ysr@2819 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_MEMORY_CARDTABLERS_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_CARDTABLERS_HPP
stefank@2314 27
stefank@2314 28 #include "memory/cardTableModRefBS.hpp"
stefank@2314 29 #include "memory/genRemSet.hpp"
stefank@2314 30 #include "memory/memRegion.hpp"
stefank@2314 31
duke@435 32 class Space;
duke@435 33 class OopsInGenClosure;
duke@435 34
duke@435 35 // This kind of "GenRemSet" uses a card table both as shared data structure
duke@435 36 // for a mod ref barrier set and for the rem set information.
duke@435 37
duke@435 38 class CardTableRS: public GenRemSet {
duke@435 39 friend class VMStructs;
duke@435 40 // Below are private classes used in impl.
duke@435 41 friend class VerifyCTSpaceClosure;
duke@435 42 friend class ClearNoncleanCardWrapper;
duke@435 43
duke@435 44 static jbyte clean_card_val() {
duke@435 45 return CardTableModRefBS::clean_card;
duke@435 46 }
duke@435 47
duke@435 48 static bool
duke@435 49 card_is_dirty_wrt_gen_iter(jbyte cv) {
duke@435 50 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
duke@435 51 }
duke@435 52
ysr@777 53 CardTableModRefBSForCTRS* _ct_bs;
duke@435 54
duke@435 55 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
duke@435 56
duke@435 57 void verify_space(Space* s, HeapWord* gen_start);
duke@435 58
duke@435 59 enum ExtendedCardValue {
duke@435 60 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
duke@435 61 // These are for parallel collection.
duke@435 62 // There are three P (parallel) youngergen card values. In general, this
duke@435 63 // needs to be more than the number of generations (including the perm
duke@435 64 // gen) that might have younger_refs_do invoked on them separately. So
duke@435 65 // if we add more gens, we have to add more values.
duke@435 66 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
duke@435 67 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
duke@435 68 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
duke@435 69 cur_youngergen_and_prev_nonclean_card =
duke@435 70 CardTableModRefBS::CT_MR_BS_last_reserved + 5
duke@435 71 };
duke@435 72
duke@435 73 // An array that contains, for each generation, the card table value last
duke@435 74 // used as the current value for a younger_refs_do iteration of that
duke@435 75 // portion of the table. (The perm gen is index 0; other gens are at
duke@435 76 // their level plus 1. They youngest gen is in the table, but will
duke@435 77 // always have the value "clean_card".)
duke@435 78 jbyte* _last_cur_val_in_gen;
duke@435 79
duke@435 80 jbyte _cur_youngergen_card_val;
duke@435 81
ysr@777 82 int _regions_to_iterate;
ysr@777 83
duke@435 84 jbyte cur_youngergen_card_val() {
duke@435 85 return _cur_youngergen_card_val;
duke@435 86 }
duke@435 87 void set_cur_youngergen_card_val(jbyte v) {
duke@435 88 _cur_youngergen_card_val = v;
duke@435 89 }
duke@435 90 bool is_prev_youngergen_card_val(jbyte v) {
duke@435 91 return
duke@435 92 youngergen_card <= v &&
duke@435 93 v < cur_youngergen_and_prev_nonclean_card &&
duke@435 94 v != _cur_youngergen_card_val;
duke@435 95 }
duke@435 96 // Return a youngergen_card_value that is not currently in use.
duke@435 97 jbyte find_unused_youngergenP_card_value();
duke@435 98
duke@435 99 public:
duke@435 100 CardTableRS(MemRegion whole_heap, int max_covered_regions);
duke@435 101
duke@435 102 // *** GenRemSet functions.
duke@435 103 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; }
duke@435 104
duke@435 105 CardTableRS* as_CardTableRS() { return this; }
duke@435 106
ysr@777 107 CardTableModRefBS* ct_bs() { return _ct_bs; }
duke@435 108
duke@435 109 // Override.
duke@435 110 void prepare_for_younger_refs_iterate(bool parallel);
duke@435 111
duke@435 112 // Card table entries are cleared before application; "blk" is
duke@435 113 // responsible for dirtying if the oop is still older-to-younger after
duke@435 114 // closure application.
duke@435 115 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk);
duke@435 116
coleenp@548 117 void inline_write_ref_field_gc(void* field, oop new_val) {
ysr@777 118 jbyte* byte = _ct_bs->byte_for(field);
duke@435 119 *byte = youngergen_card;
duke@435 120 }
coleenp@548 121 void write_ref_field_gc_work(void* field, oop new_val) {
duke@435 122 inline_write_ref_field_gc(field, new_val);
duke@435 123 }
duke@435 124
duke@435 125 // Override. Might want to devirtualize this in the same fashion as
duke@435 126 // above. Ensures that the value of the card for field says that it's
duke@435 127 // a younger card in the current collection.
coleenp@548 128 virtual void write_ref_field_gc_par(void* field, oop new_val);
duke@435 129
duke@435 130 void resize_covered_region(MemRegion new_region);
duke@435 131
duke@435 132 bool is_aligned(HeapWord* addr) {
ysr@777 133 return _ct_bs->is_card_aligned(addr);
duke@435 134 }
duke@435 135
duke@435 136 void verify();
jmasa@441 137 void verify_aligned_region_empty(MemRegion mr);
duke@435 138
ysr@777 139 void clear(MemRegion mr) { _ct_bs->clear(mr); }
duke@435 140 void clear_into_younger(Generation* gen, bool clear_perm);
duke@435 141
ysr@777 142 void invalidate(MemRegion mr, bool whole_heap = false) {
ysr@777 143 _ct_bs->invalidate(mr, whole_heap);
ysr@777 144 }
duke@435 145 void invalidate_or_clear(Generation* gen, bool younger, bool perm);
duke@435 146
duke@435 147 static uintx ct_max_alignment_constraint() {
duke@435 148 return CardTableModRefBS::ct_max_alignment_constraint();
duke@435 149 }
duke@435 150
ysr@777 151 jbyte* byte_for(void* p) { return _ct_bs->byte_for(p); }
ysr@777 152 jbyte* byte_after(void* p) { return _ct_bs->byte_after(p); }
ysr@777 153 HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); }
duke@435 154
duke@435 155 bool is_prev_nonclean_card_val(jbyte v) {
duke@435 156 return
duke@435 157 youngergen_card <= v &&
duke@435 158 v <= cur_youngergen_and_prev_nonclean_card &&
duke@435 159 v != _cur_youngergen_card_val;
duke@435 160 }
duke@435 161
duke@435 162 static bool youngergen_may_have_been_dirty(jbyte cv) {
duke@435 163 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
duke@435 164 }
duke@435 165
duke@435 166 };
stefank@2314 167
ysr@2819 168 class ClearNoncleanCardWrapper: public MemRegionClosure {
ysr@2889 169 DirtyCardToOopClosure* _dirty_card_closure;
ysr@2819 170 CardTableRS* _ct;
ysr@2819 171 bool _is_par;
ysr@2819 172 private:
ysr@2819 173 // Clears the given card, return true if the corresponding card should be
ysr@2819 174 // processed.
ysr@2819 175 inline bool clear_card(jbyte* entry);
ysr@2819 176 // Work methods called by the clear_card()
ysr@2819 177 inline bool clear_card_serial(jbyte* entry);
ysr@2819 178 inline bool clear_card_parallel(jbyte* entry);
ysr@2819 179
ysr@2819 180 public:
ysr@2889 181 ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct);
ysr@2819 182 void do_MemRegion(MemRegion mr);
ysr@2819 183 };
ysr@2819 184
stefank@2314 185 #endif // SHARE_VM_MEMORY_CARDTABLERS_HPP

mercurial