/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "memory/modRefBarrierSet.hpp"
#include "oops/oop.inline2.hpp"
// This kind of "BarrierSet" allows a "CollectedHeap" to detect and
// enumerate ref fields that have been modified (since the last
// enumeration.)
// As it currently stands, this barrier is *imprecise*: when a ref field in
// an object "o" is modified, the card table entry for the card containing
// the head of "o" is dirtied, not necessarily the card containing the
// modified field itself. For object arrays, however, the barrier *is*
// precise; only the card containing the modified element is dirtied.
// Any MemRegionClosures used to scan dirty cards should take these
// considerations into account.
class Generation;
class OopsInGenClosure;
class DirtyCardToOopClosure;
class ClearNoncleanCardWrapper;
// Some classes get to look at some private stuff.
friend class BytecodeInterpreter;
friend class VMStructs;
friend class CardTableRS;
friend class CheckForUnmarkedOops; // Needs access to raw card bytes.
friend class SharkBuilder;
#ifndef PRODUCT
// For debugging.
friend class GuaranteeNotModClosure;
#endif
protected:
enum CardValues {
// The mask contains zeros in places for all other values.
dirty_card = 0,
};
// a word's worth (row) of clean card values
// dirty and precleaned are equivalent wrt younger_refs_iter.
}
// Returns "true" iff the value "cv" will cause the card containing it
// to be scanned in the current traversal. May be overridden by
// subtypes.
}
// Returns "true" iff the value "cv" may have represented a dirty card at
// some point.
return card_is_dirty_wrt_gen_iter(cv);
}
// The declaration order of these const fields is important; see the
// constructor before changing.
// table; it is set to a guard value
// (last_card) and should never be modified
int _cur_covered_regions;
// The covered regions should be in address order.
// The committed regions correspond one-to-one to the covered regions.
// They represent the card-table memory that has been committed to service
// the corresponding covered region. It may be that committed region for
// one covered region corresponds to a larger region because of page-size
// roundings. Thus, a committed region for one covered region may
// actually extend onto the card-table space for the next covered region.
// The last card is a guard card, and we commit the page for it so
// we can use the card for verification purposes. We make sure we never
// uncommit the MemRegion for that page.
protected:
// Initialization utilities; covered_words is the size of the covered region
// in, um, words.
inline size_t compute_byte_map_size();
// Finds and return the index of the region, if any, to which the given
// region would be contiguous. If none exists, assign a new region and
// returns its index. Requires that no more than the maximum number of
// covered regions defined in the constructor are ever in use.
// Same as above, but finds the region containing the given address
// instead of starting at a given base address.
// Resize one of the regions covered by the remembered set.
// Returns the leftmost end of a committed region corresponding to a
// covered region before covered region "ind", or else "NULL" if "ind" is
// the first covered region.
// Returns the part of the region mr that doesn't intersect with
// any committed region other than self. Used to prevent uncommitting
// regions that are also committed by other regions. Also protects
// against uncommitting the guard region.
// Mapping from address to card marking array entry
"out of bounds accessor for card marking array");
return result;
}
// The card table byte one after the card marking array
// entry for argument address. Typically used for higher bounds
// for loops iterating through the card table.
return byte_for(p) + 1;
}
// Iterate over the portion of the card-table which covers the given
// region mr in the given space and apply cl to any dirty sub-regions
// of mr. Dirty cards are _not_ cleared by the iterator method itself,
// but closures may arrange to do so on their own should they so wish.
// A variant of the above that will operate in a parallel mode if
// worker threads are available, and clear the dirty cards as it
// processes them.
// XXX ??? MemRegionClosure above vs OopsInGenClosure below XXX
// XXX some new_dcto_cl's take OopClosure's, plus as above there are
// some MemRegionClosures. Clean this up everywhere. XXX
private:
// Work method used to implement non_clean_card_iterate_possibly_parallel()
// above in the parallel case.
int n_threads);
protected:
// Dirty the bytes corresponding to "mr" (not all of which must be
// covered.)
// Clear (to clean_card) the bytes entirely contained within "mr" (not
// all of which must be covered.)
// *** Support for parallel card scanning.
// This is an array, one element per covered region of the card table.
// Each entry is itself an array, with one element per chunk in the
// covered region. Each entry of these arrays is the lowest non-clean
// card of the corresponding chunk containing part of an object from the
// previous chunk, or else NULL.
// Initializes "lowest_non_clean" to point to the array for the region
// covering "sp", and "lowest_non_clean_base_chunk_index" to the chunk
// index of the corresponding to the first element of that array.
// Ensures that these arrays are of sufficient size, allocating if necessary.
// May be called by several threads concurrently.
// Returns the number of chunks necessary to cover "mr".
}
// Returns the index of the chunk in a stride which
// covers the given address.
return card / ParGCCardsPerStrideChunk;
}
// Apply cl, which must either itself apply dcto_cl or be dcto_cl,
// to the cards in the stride (of n_strides) within the given space.
// Makes sure that chunk boundaries are handled appropriately, by
// adjusting the min_done of dcto_cl, and by using a special card-table
// value to indicate how min_done should be set.
public:
// Constants
enum SomePublicConstants {
};
// For RTTI simulation.
}
// *** Barrier set functions.
bool has_write_ref_pre_barrier() { return false; }
// Note that this assumes the perm gen is the highest generation
// in the address space
}
// Record a reference update. Note that these versions are precise!
// The scanning code has to handle the fact that the write barrier may be
// either precise or imprecise. We make non-virtual inline variants of
// these functions here for performance.
protected:
public:
bool has_write_ref_array_opt() { return true; }
bool has_write_region_opt() { return true; }
}
protected:
}
public:
}
protected:
}
public:
return is_card_aligned(addr);
}
// *** Card-table-barrier-specific things.
*byte = dirty_card;
}
// These are used by G1, when it uses the card table as a temporary data
// structure for card claiming.
}
}
}
if (val == clean_card_val()) {
} else {
}
}
}
}
// Card marking array base (adjusted for heap low boundary)
// This would be the 0th element of _byte_map, if the heap started at 0x0.
// But since the heap starts at some higher address, this points to somewhere
// before the beginning of the actual _byte_map.
// Return true if "p" is at the start of a card.
}
}
// The kinds of precision a CardTableModRefBS may offer.
enum PrecisionStyle {
};
// Tells what style of precision this card table offers.
return ObjHeadPreciseArray; // Only one supported for now.
}
// ModRefBS functions.
// *** Card-table-RemSet-specific things.
// Invoke "cl.do_MemRegion" on a set of MemRegions that collectively
// includes all the modified cards (expressing each card as a
// MemRegion). Thus, several modified cards may be lumped into one
// region. The regions are non-overlapping, and are visited in
// *decreasing* address order. (This order aids with imprecise card
// marking, where a dirty card may cause scanning, and summarization
// marking, of objects that extend onto subsequent cards.)
}
// Like the "mod_cards_iterate" above, except only invokes the closure
// for cards within the MemRegion "mr" (which is required to be
// card-aligned and sized.)
}
static uintx ct_max_alignment_constraint();
// Apply closure "cl" to the dirty cards containing some part of
// MemRegion "mr".
// Return the MemRegion corresponding to the first maximal run
// of dirty cards lying completely within MemRegion mr.
// If reset is "true", then sets those card table entries to the given
// value.
int reset_val);
// Provide read-only access to the card table array.
return byte_for(p);
}
return byte_after(p);
}
// Mapping from card marking array entry to address of first word
"out of bounds access to card marking array");
return result;
}
// Mapping from address to card marking array index.
}
return _byte_map + card_index;
}
// Print a description of the memory for the barrier set
void verify();
void verify_guard();
// val_equals -> it will check that all cards covered by mr equal val
// !val_equals -> it will check that all cards covered by mr do not equal val
return ParGCCardsPerStrideChunk * card_size_in_words;
}
};
class CardTableRS;
// A specialization for the CardTableRS gen rem set.
protected:
public:
int max_covered_regions) :
};
#endif // SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP