src/share/vm/memory/cardTableRS.hpp

Mon, 26 Sep 2016 13:56:18 -0400

author
fujie
date
Mon, 26 Sep 2016 13:56:18 -0400
changeset 121
fc16fcee952c
parent 116
09e17e497778
child 6876
710a3c8b516e
permissions
-rw-r--r--

Mark changes for 3A2000 only with the Use3A2000 flag.

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_MEMORY_CARDTABLERS_HPP
aoqi@0 26 #define SHARE_VM_MEMORY_CARDTABLERS_HPP
aoqi@0 27
aoqi@0 28 #include "memory/cardTableModRefBS.hpp"
aoqi@0 29 #include "memory/genRemSet.hpp"
aoqi@0 30 #include "memory/memRegion.hpp"
aoqi@0 31
aoqi@0 32 class Space;
aoqi@0 33 class OopsInGenClosure;
aoqi@0 34
aoqi@0 35 // This kind of "GenRemSet" uses a card table both as shared data structure
aoqi@0 36 // for a mod ref barrier set and for the rem set information.
aoqi@0 37
aoqi@0 38 class CardTableRS: public GenRemSet {
aoqi@0 39 friend class VMStructs;
aoqi@0 40 // Below are private classes used in impl.
aoqi@0 41 friend class VerifyCTSpaceClosure;
aoqi@0 42 friend class ClearNoncleanCardWrapper;
aoqi@0 43
aoqi@0 44 static jbyte clean_card_val() {
aoqi@0 45 return CardTableModRefBS::clean_card;
aoqi@0 46 }
aoqi@0 47
aoqi@0 48 static intptr_t clean_card_row() {
aoqi@0 49 return CardTableModRefBS::clean_card_row;
aoqi@0 50 }
aoqi@0 51
aoqi@0 52 static bool
aoqi@0 53 card_is_dirty_wrt_gen_iter(jbyte cv) {
aoqi@0 54 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
aoqi@0 55 }
aoqi@0 56
aoqi@0 57 CardTableModRefBSForCTRS* _ct_bs;
aoqi@0 58
aoqi@0 59 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
aoqi@0 60
aoqi@0 61 void verify_space(Space* s, HeapWord* gen_start);
aoqi@0 62
aoqi@0 63 enum ExtendedCardValue {
aoqi@0 64 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
aoqi@0 65 // These are for parallel collection.
aoqi@0 66 // There are three P (parallel) youngergen card values. In general, this
aoqi@0 67 // needs to be more than the number of generations (including the perm
aoqi@0 68 // gen) that might have younger_refs_do invoked on them separately. So
aoqi@0 69 // if we add more gens, we have to add more values.
aoqi@0 70 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
aoqi@0 71 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
aoqi@0 72 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
aoqi@0 73 cur_youngergen_and_prev_nonclean_card =
aoqi@0 74 CardTableModRefBS::CT_MR_BS_last_reserved + 5
aoqi@0 75 };
aoqi@0 76
aoqi@0 77 // An array that contains, for each generation, the card table value last
aoqi@0 78 // used as the current value for a younger_refs_do iteration of that
aoqi@0 79 // portion of the table. (The perm gen is index 0; other gens are at
aoqi@0 80 // their level plus 1. They youngest gen is in the table, but will
aoqi@0 81 // always have the value "clean_card".)
aoqi@0 82 jbyte* _last_cur_val_in_gen;
aoqi@0 83
aoqi@0 84 jbyte _cur_youngergen_card_val;
aoqi@0 85
aoqi@0 86 int _regions_to_iterate;
aoqi@0 87
aoqi@0 88 jbyte cur_youngergen_card_val() {
aoqi@0 89 return _cur_youngergen_card_val;
aoqi@0 90 }
aoqi@0 91 void set_cur_youngergen_card_val(jbyte v) {
aoqi@0 92 _cur_youngergen_card_val = v;
aoqi@0 93 }
aoqi@0 94 bool is_prev_youngergen_card_val(jbyte v) {
aoqi@0 95 return
aoqi@0 96 youngergen_card <= v &&
aoqi@0 97 v < cur_youngergen_and_prev_nonclean_card &&
aoqi@0 98 v != _cur_youngergen_card_val;
aoqi@0 99 }
aoqi@0 100 // Return a youngergen_card_value that is not currently in use.
aoqi@0 101 jbyte find_unused_youngergenP_card_value();
aoqi@0 102
aoqi@0 103 public:
aoqi@0 104 CardTableRS(MemRegion whole_heap, int max_covered_regions);
aoqi@0 105 ~CardTableRS();
aoqi@0 106
aoqi@0 107 // *** GenRemSet functions.
aoqi@0 108 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; }
aoqi@0 109
aoqi@0 110 CardTableRS* as_CardTableRS() { return this; }
aoqi@0 111
aoqi@0 112 CardTableModRefBS* ct_bs() { return _ct_bs; }
aoqi@0 113
aoqi@0 114 // Override.
aoqi@0 115 void prepare_for_younger_refs_iterate(bool parallel);
aoqi@0 116
aoqi@0 117 // Card table entries are cleared before application; "blk" is
aoqi@0 118 // responsible for dirtying if the oop is still older-to-younger after
aoqi@0 119 // closure application.
aoqi@0 120 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk);
aoqi@0 121
aoqi@0 122 void inline_write_ref_field_gc(void* field, oop new_val) {
aoqi@0 123 jbyte* byte = _ct_bs->byte_for(field);
fujie@116 124 #ifdef MIPS64
fujie@121 125 if (Use3A2000) OrderAccess::fence();
fujie@116 126 #endif
fujie@116 127 *byte = youngergen_card;
fujie@116 128 #ifdef MIPS64
fujie@121 129 if (Use3A2000) OrderAccess::fence();
fujie@116 130 #endif
fujie@116 131
aoqi@0 132 }
aoqi@0 133 void write_ref_field_gc_work(void* field, oop new_val) {
aoqi@0 134 inline_write_ref_field_gc(field, new_val);
aoqi@0 135 }
aoqi@0 136
aoqi@0 137 // Override. Might want to devirtualize this in the same fashion as
aoqi@0 138 // above. Ensures that the value of the card for field says that it's
aoqi@0 139 // a younger card in the current collection.
aoqi@0 140 virtual void write_ref_field_gc_par(void* field, oop new_val);
aoqi@0 141
aoqi@0 142 void resize_covered_region(MemRegion new_region);
aoqi@0 143
aoqi@0 144 bool is_aligned(HeapWord* addr) {
aoqi@0 145 return _ct_bs->is_card_aligned(addr);
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 void verify();
aoqi@0 149 void verify_aligned_region_empty(MemRegion mr);
aoqi@0 150
aoqi@0 151 void clear(MemRegion mr) { _ct_bs->clear(mr); }
aoqi@0 152 void clear_into_younger(Generation* old_gen);
aoqi@0 153
aoqi@0 154 void invalidate(MemRegion mr, bool whole_heap = false) {
aoqi@0 155 _ct_bs->invalidate(mr, whole_heap);
aoqi@0 156 }
aoqi@0 157 void invalidate_or_clear(Generation* old_gen);
aoqi@0 158
aoqi@0 159 static uintx ct_max_alignment_constraint() {
aoqi@0 160 return CardTableModRefBS::ct_max_alignment_constraint();
aoqi@0 161 }
aoqi@0 162
aoqi@0 163 jbyte* byte_for(void* p) { return _ct_bs->byte_for(p); }
aoqi@0 164 jbyte* byte_after(void* p) { return _ct_bs->byte_after(p); }
aoqi@0 165 HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); }
aoqi@0 166
aoqi@0 167 bool is_prev_nonclean_card_val(jbyte v) {
aoqi@0 168 return
aoqi@0 169 youngergen_card <= v &&
aoqi@0 170 v <= cur_youngergen_and_prev_nonclean_card &&
aoqi@0 171 v != _cur_youngergen_card_val;
aoqi@0 172 }
aoqi@0 173
aoqi@0 174 static bool youngergen_may_have_been_dirty(jbyte cv) {
aoqi@0 175 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
aoqi@0 176 }
aoqi@0 177
aoqi@0 178 };
aoqi@0 179
aoqi@0 180 class ClearNoncleanCardWrapper: public MemRegionClosure {
aoqi@0 181 DirtyCardToOopClosure* _dirty_card_closure;
aoqi@0 182 CardTableRS* _ct;
aoqi@0 183 bool _is_par;
aoqi@0 184 private:
aoqi@0 185 // Clears the given card, return true if the corresponding card should be
aoqi@0 186 // processed.
aoqi@0 187 inline bool clear_card(jbyte* entry);
aoqi@0 188 // Work methods called by the clear_card()
aoqi@0 189 inline bool clear_card_serial(jbyte* entry);
aoqi@0 190 inline bool clear_card_parallel(jbyte* entry);
aoqi@0 191 // check alignment of pointer
aoqi@0 192 bool is_word_aligned(jbyte* entry);
aoqi@0 193
aoqi@0 194 public:
aoqi@0 195 ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct);
aoqi@0 196 void do_MemRegion(MemRegion mr);
aoqi@0 197 };
aoqi@0 198
aoqi@0 199 #endif // SHARE_VM_MEMORY_CARDTABLERS_HPP

mercurial