// G1FromCardCache remembers the most recently processed card on the heap on // a per-region and per-thread basis. class G1FromCardCache : public AllStatic { private: // Array of card indices. Indexed by heap region (rows) and thread (columns) to minimize // thread contention. // This order minimizes the time to clear all entries for a given region during region // freeing. I.e. a single clear of a single memory area instead of multiple separate // accesses with a large stride per region. static uintptr_t** _cache; static uint _max_reserved_regions; static size_t _static_mem_size; #ifdef ASSERT static uint _max_workers;
staticvoid check_bounds(uint worker_id, uint region_idx) {
assert(worker_id < _max_workers, "Worker_id %u is larger than maximum %u", worker_id, _max_workers);
assert(region_idx < _max_reserved_regions, "Region_idx %u is larger than maximum %u", region_idx, _max_reserved_regions);
} #endif
// This card index indicates "no card for that entry" yet. This allows us to use the OS // lazy backing of memory with zero-filled pages to avoid initial actual memory use. // This means that the heap must not contain card zero. staticconst uintptr_t InvalidCard = 0;
// Gives an approximation on how many threads can be expected to add records to // a remembered set in parallel. This is used for sizing the G1FromCardCache to // decrease performance losses due to data structure sharing. // Examples for quantities that influence this value are the maximum number of // mutator threads, maximum number of concurrent refinement or GC threads. static uint num_par_rem_sets();
public: staticvoid clear(uint region_idx);
// Returns true if the given card is in the cache at the given location, or // replaces the card at that location and returns false. staticbool contains_or_replace(uint worker_id, uint region_idx, uintptr_t card) {
uintptr_t card_in_cache = at(worker_id, region_idx); if (card_in_cache == card) { returntrue;
} else {
set(worker_id, region_idx, card); returnfalse;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.