src/share/vm/memory/cardTableRS.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 2819
c48ad6ab8bdf
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

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

mercurial