src/share/vm/memory/cardTableModRefBS.hpp

Thu, 24 May 2018 18:41:44 +0800

author
aoqi
date
Thu, 24 May 2018 18:41:44 +0800
changeset 8856
ac27a9c85bea
parent 8659
c70ebf41026a
parent 8019
3fb3ceb7398f
child 9138
b56ab8e56604
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2000, 2014, 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_CARDTABLEMODREFBS_HPP
aoqi@0 26 #define SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP
aoqi@0 27
aoqi@0 28 #include "memory/modRefBarrierSet.hpp"
aoqi@0 29 #include "oops/oop.hpp"
aoqi@0 30 #include "oops/oop.inline2.hpp"
aoqi@0 31
aoqi@0 32 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
aoqi@0 33 // enumerate ref fields that have been modified (since the last
aoqi@0 34 // enumeration.)
aoqi@0 35
aoqi@0 36 // As it currently stands, this barrier is *imprecise*: when a ref field in
aoqi@0 37 // an object "o" is modified, the card table entry for the card containing
aoqi@0 38 // the head of "o" is dirtied, not necessarily the card containing the
aoqi@0 39 // modified field itself. For object arrays, however, the barrier *is*
aoqi@0 40 // precise; only the card containing the modified element is dirtied.
aoqi@0 41 // Any MemRegionClosures used to scan dirty cards should take these
aoqi@0 42 // considerations into account.
aoqi@0 43
aoqi@0 44 class Generation;
aoqi@0 45 class OopsInGenClosure;
aoqi@0 46 class DirtyCardToOopClosure;
aoqi@0 47 class ClearNoncleanCardWrapper;
aoqi@0 48
aoqi@0 49 class CardTableModRefBS: public ModRefBarrierSet {
aoqi@0 50 // Some classes get to look at some private stuff.
aoqi@0 51 friend class BytecodeInterpreter;
aoqi@0 52 friend class VMStructs;
aoqi@0 53 friend class CardTableRS;
aoqi@0 54 friend class CheckForUnmarkedOops; // Needs access to raw card bytes.
aoqi@0 55 friend class SharkBuilder;
aoqi@0 56 #ifndef PRODUCT
aoqi@0 57 // For debugging.
aoqi@0 58 friend class GuaranteeNotModClosure;
aoqi@0 59 #endif
aoqi@0 60 protected:
aoqi@0 61
aoqi@0 62 enum CardValues {
aoqi@0 63 clean_card = -1,
aoqi@0 64 // The mask contains zeros in places for all other values.
aoqi@0 65 clean_card_mask = clean_card - 31,
aoqi@0 66
aoqi@0 67 dirty_card = 0,
aoqi@0 68 precleaned_card = 1,
aoqi@0 69 claimed_card = 2,
aoqi@0 70 deferred_card = 4,
aoqi@0 71 last_card = 8,
aoqi@0 72 CT_MR_BS_last_reserved = 16
aoqi@0 73 };
aoqi@0 74
aoqi@0 75 // a word's worth (row) of clean card values
aoqi@0 76 static const intptr_t clean_card_row = (intptr_t)(-1);
aoqi@0 77
aoqi@0 78 // dirty and precleaned are equivalent wrt younger_refs_iter.
aoqi@0 79 static bool card_is_dirty_wrt_gen_iter(jbyte cv) {
aoqi@0 80 return cv == dirty_card || cv == precleaned_card;
aoqi@0 81 }
aoqi@0 82
aoqi@0 83 // Returns "true" iff the value "cv" will cause the card containing it
aoqi@0 84 // to be scanned in the current traversal. May be overridden by
aoqi@0 85 // subtypes.
aoqi@0 86 virtual bool card_will_be_scanned(jbyte cv) {
aoqi@0 87 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
aoqi@0 88 }
aoqi@0 89
aoqi@0 90 // Returns "true" iff the value "cv" may have represented a dirty card at
aoqi@0 91 // some point.
aoqi@0 92 virtual bool card_may_have_been_dirty(jbyte cv) {
aoqi@0 93 return card_is_dirty_wrt_gen_iter(cv);
aoqi@0 94 }
aoqi@0 95
aoqi@0 96 // The declaration order of these const fields is important; see the
aoqi@0 97 // constructor before changing.
aoqi@0 98 const MemRegion _whole_heap; // the region covered by the card table
tschatzl@7051 99 size_t _guard_index; // index of very last element in the card
aoqi@0 100 // table; it is set to a guard value
aoqi@0 101 // (last_card) and should never be modified
tschatzl@7051 102 size_t _last_valid_index; // index of the last valid element
aoqi@0 103 const size_t _page_size; // page size used when mapping _byte_map
tschatzl@7051 104 size_t _byte_map_size; // in bytes
aoqi@0 105 jbyte* _byte_map; // the card marking array
aoqi@0 106
aoqi@0 107 int _cur_covered_regions;
aoqi@0 108 // The covered regions should be in address order.
aoqi@0 109 MemRegion* _covered;
aoqi@0 110 // The committed regions correspond one-to-one to the covered regions.
aoqi@0 111 // They represent the card-table memory that has been committed to service
aoqi@0 112 // the corresponding covered region. It may be that committed region for
aoqi@0 113 // one covered region corresponds to a larger region because of page-size
aoqi@0 114 // roundings. Thus, a committed region for one covered region may
aoqi@0 115 // actually extend onto the card-table space for the next covered region.
aoqi@0 116 MemRegion* _committed;
aoqi@0 117
aoqi@0 118 // The last card is a guard card, and we commit the page for it so
aoqi@0 119 // we can use the card for verification purposes. We make sure we never
aoqi@0 120 // uncommit the MemRegion for that page.
aoqi@0 121 MemRegion _guard_region;
aoqi@0 122
aoqi@0 123 protected:
aoqi@0 124 // Initialization utilities; covered_words is the size of the covered region
aoqi@0 125 // in, um, words.
tschatzl@7051 126 inline size_t cards_required(size_t covered_words) {
tschatzl@7051 127 // Add one for a guard card, used to detect errors.
tschatzl@7051 128 const size_t words = align_size_up(covered_words, card_size_in_words);
tschatzl@7051 129 return words / card_size_in_words + 1;
tschatzl@7051 130 }
tschatzl@7051 131
aoqi@0 132 inline size_t compute_byte_map_size();
aoqi@0 133
aoqi@0 134 // Finds and return the index of the region, if any, to which the given
aoqi@0 135 // region would be contiguous. If none exists, assign a new region and
aoqi@0 136 // returns its index. Requires that no more than the maximum number of
aoqi@0 137 // covered regions defined in the constructor are ever in use.
aoqi@0 138 int find_covering_region_by_base(HeapWord* base);
aoqi@0 139
aoqi@0 140 // Same as above, but finds the region containing the given address
aoqi@0 141 // instead of starting at a given base address.
aoqi@0 142 int find_covering_region_containing(HeapWord* addr);
aoqi@0 143
aoqi@0 144 // Resize one of the regions covered by the remembered set.
tschatzl@7051 145 virtual void resize_covered_region(MemRegion new_region);
aoqi@0 146
aoqi@0 147 // Returns the leftmost end of a committed region corresponding to a
aoqi@0 148 // covered region before covered region "ind", or else "NULL" if "ind" is
aoqi@0 149 // the first covered region.
aoqi@0 150 HeapWord* largest_prev_committed_end(int ind) const;
aoqi@0 151
aoqi@0 152 // Returns the part of the region mr that doesn't intersect with
aoqi@0 153 // any committed region other than self. Used to prevent uncommitting
aoqi@0 154 // regions that are also committed by other regions. Also protects
aoqi@0 155 // against uncommitting the guard region.
aoqi@0 156 MemRegion committed_unique_to_self(int self, MemRegion mr) const;
aoqi@0 157
aoqi@0 158 // Mapping from address to card marking array entry
aoqi@0 159 jbyte* byte_for(const void* p) const {
aoqi@0 160 assert(_whole_heap.contains(p),
aoqi@0 161 err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of "
aoqi@0 162 " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
aoqi@0 163 p2i(p), p2i(_whole_heap.start()), p2i(_whole_heap.end())));
aoqi@0 164 jbyte* result = &byte_map_base[uintptr_t(p) >> card_shift];
aoqi@0 165 assert(result >= _byte_map && result < _byte_map + _byte_map_size,
aoqi@0 166 "out of bounds accessor for card marking array");
aoqi@0 167 return result;
aoqi@0 168 }
aoqi@0 169
aoqi@0 170 // The card table byte one after the card marking array
aoqi@0 171 // entry for argument address. Typically used for higher bounds
aoqi@0 172 // for loops iterating through the card table.
aoqi@0 173 jbyte* byte_after(const void* p) const {
aoqi@0 174 return byte_for(p) + 1;
aoqi@0 175 }
aoqi@0 176
aoqi@0 177 // Iterate over the portion of the card-table which covers the given
aoqi@0 178 // region mr in the given space and apply cl to any dirty sub-regions
aoqi@0 179 // of mr. Dirty cards are _not_ cleared by the iterator method itself,
aoqi@0 180 // but closures may arrange to do so on their own should they so wish.
aoqi@0 181 void non_clean_card_iterate_serial(MemRegion mr, MemRegionClosure* cl);
aoqi@0 182
aoqi@0 183 // A variant of the above that will operate in a parallel mode if
aoqi@0 184 // worker threads are available, and clear the dirty cards as it
aoqi@0 185 // processes them.
aoqi@0 186 // XXX ??? MemRegionClosure above vs OopsInGenClosure below XXX
aoqi@0 187 // XXX some new_dcto_cl's take OopClosure's, plus as above there are
aoqi@0 188 // some MemRegionClosures. Clean this up everywhere. XXX
aoqi@0 189 void non_clean_card_iterate_possibly_parallel(Space* sp, MemRegion mr,
aoqi@0 190 OopsInGenClosure* cl, CardTableRS* ct);
aoqi@0 191
aoqi@0 192 private:
aoqi@0 193 // Work method used to implement non_clean_card_iterate_possibly_parallel()
aoqi@0 194 // above in the parallel case.
aoqi@0 195 void non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
aoqi@0 196 OopsInGenClosure* cl, CardTableRS* ct,
aoqi@0 197 int n_threads);
aoqi@0 198
aoqi@0 199 protected:
aoqi@0 200 // Dirty the bytes corresponding to "mr" (not all of which must be
aoqi@0 201 // covered.)
aoqi@0 202 void dirty_MemRegion(MemRegion mr);
aoqi@0 203
aoqi@0 204 // Clear (to clean_card) the bytes entirely contained within "mr" (not
aoqi@0 205 // all of which must be covered.)
aoqi@0 206 void clear_MemRegion(MemRegion mr);
aoqi@0 207
aoqi@0 208 // *** Support for parallel card scanning.
aoqi@0 209
aoqi@0 210 // This is an array, one element per covered region of the card table.
aoqi@0 211 // Each entry is itself an array, with one element per chunk in the
aoqi@0 212 // covered region. Each entry of these arrays is the lowest non-clean
aoqi@0 213 // card of the corresponding chunk containing part of an object from the
aoqi@0 214 // previous chunk, or else NULL.
aoqi@0 215 typedef jbyte* CardPtr;
aoqi@0 216 typedef CardPtr* CardArr;
aoqi@0 217 CardArr* _lowest_non_clean;
aoqi@0 218 size_t* _lowest_non_clean_chunk_size;
aoqi@0 219 uintptr_t* _lowest_non_clean_base_chunk_index;
simonis@8659 220 volatile int* _last_LNC_resizing_collection;
aoqi@0 221
aoqi@0 222 // Initializes "lowest_non_clean" to point to the array for the region
aoqi@0 223 // covering "sp", and "lowest_non_clean_base_chunk_index" to the chunk
aoqi@0 224 // index of the corresponding to the first element of that array.
aoqi@0 225 // Ensures that these arrays are of sufficient size, allocating if necessary.
aoqi@0 226 // May be called by several threads concurrently.
aoqi@0 227 void get_LNC_array_for_space(Space* sp,
aoqi@0 228 jbyte**& lowest_non_clean,
aoqi@0 229 uintptr_t& lowest_non_clean_base_chunk_index,
aoqi@0 230 size_t& lowest_non_clean_chunk_size);
aoqi@0 231
aoqi@0 232 // Returns the number of chunks necessary to cover "mr".
aoqi@0 233 size_t chunks_to_cover(MemRegion mr) {
aoqi@0 234 return (size_t)(addr_to_chunk_index(mr.last()) -
aoqi@0 235 addr_to_chunk_index(mr.start()) + 1);
aoqi@0 236 }
aoqi@0 237
aoqi@0 238 // Returns the index of the chunk in a stride which
aoqi@0 239 // covers the given address.
aoqi@0 240 uintptr_t addr_to_chunk_index(const void* addr) {
aoqi@0 241 uintptr_t card = (uintptr_t) byte_for(addr);
aoqi@0 242 return card / ParGCCardsPerStrideChunk;
aoqi@0 243 }
aoqi@0 244
aoqi@0 245 // Apply cl, which must either itself apply dcto_cl or be dcto_cl,
aoqi@0 246 // to the cards in the stride (of n_strides) within the given space.
aoqi@0 247 void process_stride(Space* sp,
aoqi@0 248 MemRegion used,
aoqi@0 249 jint stride, int n_strides,
aoqi@0 250 OopsInGenClosure* cl,
aoqi@0 251 CardTableRS* ct,
aoqi@0 252 jbyte** lowest_non_clean,
aoqi@0 253 uintptr_t lowest_non_clean_base_chunk_index,
aoqi@0 254 size_t lowest_non_clean_chunk_size);
aoqi@0 255
aoqi@0 256 // Makes sure that chunk boundaries are handled appropriately, by
aoqi@0 257 // adjusting the min_done of dcto_cl, and by using a special card-table
aoqi@0 258 // value to indicate how min_done should be set.
aoqi@0 259 void process_chunk_boundaries(Space* sp,
aoqi@0 260 DirtyCardToOopClosure* dcto_cl,
aoqi@0 261 MemRegion chunk_mr,
aoqi@0 262 MemRegion used,
aoqi@0 263 jbyte** lowest_non_clean,
aoqi@0 264 uintptr_t lowest_non_clean_base_chunk_index,
aoqi@0 265 size_t lowest_non_clean_chunk_size);
aoqi@0 266
aoqi@0 267 public:
aoqi@0 268 // Constants
aoqi@0 269 enum SomePublicConstants {
aoqi@0 270 card_shift = 9,
aoqi@0 271 card_size = 1 << card_shift,
aoqi@0 272 card_size_in_words = card_size / sizeof(HeapWord)
aoqi@0 273 };
aoqi@0 274
aoqi@0 275 static int clean_card_val() { return clean_card; }
aoqi@0 276 static int clean_card_mask_val() { return clean_card_mask; }
aoqi@0 277 static int dirty_card_val() { return dirty_card; }
aoqi@0 278 static int claimed_card_val() { return claimed_card; }
aoqi@0 279 static int precleaned_card_val() { return precleaned_card; }
aoqi@0 280 static int deferred_card_val() { return deferred_card; }
aoqi@0 281
aoqi@0 282 // For RTTI simulation.
aoqi@0 283 bool is_a(BarrierSet::Name bsn) {
aoqi@0 284 return bsn == BarrierSet::CardTableModRef || ModRefBarrierSet::is_a(bsn);
aoqi@0 285 }
aoqi@0 286
aoqi@0 287 CardTableModRefBS(MemRegion whole_heap, int max_covered_regions);
aoqi@0 288 ~CardTableModRefBS();
aoqi@0 289
tschatzl@7051 290 virtual void initialize();
tschatzl@7051 291
aoqi@0 292 // *** Barrier set functions.
aoqi@0 293
aoqi@0 294 bool has_write_ref_pre_barrier() { return false; }
aoqi@0 295
aoqi@0 296 // Record a reference update. Note that these versions are precise!
aoqi@0 297 // The scanning code has to handle the fact that the write barrier may be
aoqi@0 298 // either precise or imprecise. We make non-virtual inline variants of
aoqi@0 299 // these functions here for performance.
aoqi@0 300 protected:
aoqi@0 301 void write_ref_field_work(oop obj, size_t offset, oop newVal);
aoqi@0 302 virtual void write_ref_field_work(void* field, oop newVal, bool release = false);
aoqi@0 303 public:
aoqi@0 304
aoqi@0 305 bool has_write_ref_array_opt() { return true; }
aoqi@0 306 bool has_write_region_opt() { return true; }
aoqi@0 307
aoqi@0 308 inline void inline_write_region(MemRegion mr) {
aoqi@0 309 dirty_MemRegion(mr);
aoqi@0 310 }
aoqi@0 311 protected:
aoqi@0 312 void write_region_work(MemRegion mr) {
aoqi@0 313 inline_write_region(mr);
aoqi@0 314 }
aoqi@0 315 public:
aoqi@0 316
aoqi@0 317 inline void inline_write_ref_array(MemRegion mr) {
aoqi@0 318 dirty_MemRegion(mr);
fujie@116 319 #ifdef MIPS64
aoqi@8019 320 if (UseSyncLevel >= 2000) OrderAccess::fence();
fujie@116 321 #endif
aoqi@0 322 }
aoqi@0 323 protected:
aoqi@0 324 void write_ref_array_work(MemRegion mr) {
aoqi@0 325 inline_write_ref_array(mr);
aoqi@0 326 }
aoqi@0 327 public:
aoqi@0 328
aoqi@0 329 bool is_aligned(HeapWord* addr) {
aoqi@0 330 return is_card_aligned(addr);
aoqi@0 331 }
aoqi@0 332
aoqi@0 333 // *** Card-table-barrier-specific things.
aoqi@0 334
fujie@116 335 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
fujie@116 336 #ifdef MIPS64
aoqi@8019 337 if (UseSyncLevel >= 2000) OrderAccess::fence();
fujie@116 338 #endif
fujie@116 339 }
aoqi@0 340
aoqi@0 341 template <class T> inline void inline_write_ref_field(T* field, oop newVal, bool release) {
aoqi@0 342 jbyte* byte = byte_for((void*)field);
aoqi@0 343 if (release) {
aoqi@0 344 // Perform a releasing store if requested.
aoqi@0 345 OrderAccess::release_store((volatile jbyte*) byte, dirty_card);
aoqi@0 346 } else {
aoqi@0 347 *byte = dirty_card;
aoqi@0 348 }
fujie@116 349 #ifdef MIPS64
aoqi@8019 350 if (UseSyncLevel >= 2000) OrderAccess::fence();
fujie@116 351 #endif
aoqi@0 352 }
aoqi@0 353
aoqi@0 354 // These are used by G1, when it uses the card table as a temporary data
aoqi@0 355 // structure for card claiming.
aoqi@0 356 bool is_card_dirty(size_t card_index) {
aoqi@0 357 return _byte_map[card_index] == dirty_card_val();
aoqi@0 358 }
aoqi@0 359
aoqi@0 360 void mark_card_dirty(size_t card_index) {
aoqi@0 361 _byte_map[card_index] = dirty_card_val();
aoqi@0 362 }
aoqi@0 363
aoqi@0 364 bool is_card_clean(size_t card_index) {
aoqi@0 365 return _byte_map[card_index] == clean_card_val();
aoqi@0 366 }
aoqi@0 367
aoqi@0 368 // Card marking array base (adjusted for heap low boundary)
aoqi@0 369 // This would be the 0th element of _byte_map, if the heap started at 0x0.
aoqi@0 370 // But since the heap starts at some higher address, this points to somewhere
aoqi@0 371 // before the beginning of the actual _byte_map.
aoqi@0 372 jbyte* byte_map_base;
aoqi@0 373
aoqi@0 374 // Return true if "p" is at the start of a card.
aoqi@0 375 bool is_card_aligned(HeapWord* p) {
aoqi@0 376 jbyte* pcard = byte_for(p);
aoqi@0 377 return (addr_for(pcard) == p);
aoqi@0 378 }
aoqi@0 379
aoqi@0 380 HeapWord* align_to_card_boundary(HeapWord* p) {
aoqi@0 381 jbyte* pcard = byte_for(p + card_size_in_words - 1);
aoqi@0 382 return addr_for(pcard);
aoqi@0 383 }
aoqi@0 384
aoqi@0 385 // The kinds of precision a CardTableModRefBS may offer.
aoqi@0 386 enum PrecisionStyle {
aoqi@0 387 Precise,
aoqi@0 388 ObjHeadPreciseArray
aoqi@0 389 };
aoqi@0 390
aoqi@0 391 // Tells what style of precision this card table offers.
aoqi@0 392 PrecisionStyle precision() {
aoqi@0 393 return ObjHeadPreciseArray; // Only one supported for now.
aoqi@0 394 }
aoqi@0 395
aoqi@0 396 // ModRefBS functions.
aoqi@0 397 virtual void invalidate(MemRegion mr, bool whole_heap = false);
aoqi@0 398 void clear(MemRegion mr);
aoqi@0 399 void dirty(MemRegion mr);
aoqi@0 400
aoqi@0 401 // *** Card-table-RemSet-specific things.
aoqi@0 402
aoqi@0 403 // Invoke "cl.do_MemRegion" on a set of MemRegions that collectively
aoqi@0 404 // includes all the modified cards (expressing each card as a
aoqi@0 405 // MemRegion). Thus, several modified cards may be lumped into one
aoqi@0 406 // region. The regions are non-overlapping, and are visited in
aoqi@0 407 // *decreasing* address order. (This order aids with imprecise card
aoqi@0 408 // marking, where a dirty card may cause scanning, and summarization
aoqi@0 409 // marking, of objects that extend onto subsequent cards.)
aoqi@0 410 void mod_card_iterate(MemRegionClosure* cl) {
aoqi@0 411 non_clean_card_iterate_serial(_whole_heap, cl);
aoqi@0 412 }
aoqi@0 413
aoqi@0 414 // Like the "mod_cards_iterate" above, except only invokes the closure
aoqi@0 415 // for cards within the MemRegion "mr" (which is required to be
aoqi@0 416 // card-aligned and sized.)
aoqi@0 417 void mod_card_iterate(MemRegion mr, MemRegionClosure* cl) {
aoqi@0 418 non_clean_card_iterate_serial(mr, cl);
aoqi@0 419 }
aoqi@0 420
aoqi@0 421 static uintx ct_max_alignment_constraint();
aoqi@0 422
aoqi@0 423 // Apply closure "cl" to the dirty cards containing some part of
aoqi@0 424 // MemRegion "mr".
aoqi@0 425 void dirty_card_iterate(MemRegion mr, MemRegionClosure* cl);
aoqi@0 426
aoqi@0 427 // Return the MemRegion corresponding to the first maximal run
aoqi@0 428 // of dirty cards lying completely within MemRegion mr.
aoqi@0 429 // If reset is "true", then sets those card table entries to the given
aoqi@0 430 // value.
aoqi@0 431 MemRegion dirty_card_range_after_reset(MemRegion mr, bool reset,
aoqi@0 432 int reset_val);
aoqi@0 433
aoqi@0 434 // Provide read-only access to the card table array.
aoqi@0 435 const jbyte* byte_for_const(const void* p) const {
aoqi@0 436 return byte_for(p);
aoqi@0 437 }
aoqi@0 438 const jbyte* byte_after_const(const void* p) const {
aoqi@0 439 return byte_after(p);
aoqi@0 440 }
aoqi@0 441
aoqi@0 442 // Mapping from card marking array entry to address of first word
aoqi@0 443 HeapWord* addr_for(const jbyte* p) const {
aoqi@0 444 assert(p >= _byte_map && p < _byte_map + _byte_map_size,
aoqi@0 445 "out of bounds access to card marking array");
aoqi@0 446 size_t delta = pointer_delta(p, byte_map_base, sizeof(jbyte));
aoqi@0 447 HeapWord* result = (HeapWord*) (delta << card_shift);
aoqi@0 448 assert(_whole_heap.contains(result),
aoqi@0 449 err_msg("Returning result = "PTR_FORMAT" out of bounds of "
aoqi@0 450 " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
aoqi@0 451 p2i(result), p2i(_whole_heap.start()), p2i(_whole_heap.end())));
aoqi@0 452 return result;
aoqi@0 453 }
aoqi@0 454
aoqi@0 455 // Mapping from address to card marking array index.
aoqi@0 456 size_t index_for(void* p) {
aoqi@0 457 assert(_whole_heap.contains(p),
aoqi@0 458 err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of "
aoqi@0 459 " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
aoqi@0 460 p2i(p), p2i(_whole_heap.start()), p2i(_whole_heap.end())));
aoqi@0 461 return byte_for(p) - _byte_map;
aoqi@0 462 }
aoqi@0 463
aoqi@0 464 const jbyte* byte_for_index(const size_t card_index) const {
aoqi@0 465 return _byte_map + card_index;
aoqi@0 466 }
aoqi@0 467
aoqi@0 468 // Print a description of the memory for the barrier set
aoqi@0 469 virtual void print_on(outputStream* st) const;
aoqi@0 470
aoqi@0 471 void verify();
aoqi@0 472 void verify_guard();
aoqi@0 473
aoqi@0 474 // val_equals -> it will check that all cards covered by mr equal val
aoqi@0 475 // !val_equals -> it will check that all cards covered by mr do not equal val
aoqi@0 476 void verify_region(MemRegion mr, jbyte val, bool val_equals) PRODUCT_RETURN;
aoqi@0 477 void verify_not_dirty_region(MemRegion mr) PRODUCT_RETURN;
aoqi@0 478 void verify_dirty_region(MemRegion mr) PRODUCT_RETURN;
aoqi@0 479
aoqi@0 480 static size_t par_chunk_heapword_alignment() {
aoqi@0 481 return ParGCCardsPerStrideChunk * card_size_in_words;
aoqi@0 482 }
aoqi@0 483
aoqi@0 484 };
aoqi@0 485
aoqi@0 486 class CardTableRS;
aoqi@0 487
aoqi@0 488 // A specialization for the CardTableRS gen rem set.
aoqi@0 489 class CardTableModRefBSForCTRS: public CardTableModRefBS {
aoqi@0 490 CardTableRS* _rs;
aoqi@0 491 protected:
aoqi@0 492 bool card_will_be_scanned(jbyte cv);
aoqi@0 493 bool card_may_have_been_dirty(jbyte cv);
aoqi@0 494 public:
aoqi@0 495 CardTableModRefBSForCTRS(MemRegion whole_heap,
aoqi@0 496 int max_covered_regions) :
aoqi@0 497 CardTableModRefBS(whole_heap, max_covered_regions) {}
aoqi@0 498
aoqi@0 499 void set_CTRS(CardTableRS* rs) { _rs = rs; }
aoqi@0 500 };
aoqi@0 501
aoqi@0 502
aoqi@0 503 #endif // SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP

mercurial