g1RemSet.cpp revision 1282
/*
* Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
#include "incls/_precompiled.incl"
#include "incls/_g1RemSet.cpp.incl"
#define CARD_REPEAT_HISTO 0
static size_t ct_freq_sz;
}
}
}
void ct_freq_update_histo_and_reset() {
for (size_t j = 0; j < ct_freq_sz; j++) {
ct_freq[j] = 0;
}
}
#endif
class IntoCSOopClosure: public OopsInHeapRegionClosure {
public:
}
template <class T> void do_oop_work(T* p) {
}
bool apply_to_weak_ref_discovered_field() { return true; }
bool idempotent() { return true; }
};
class IntoCSRegionClosure: public HeapRegionClosure {
public:
bool doHeapRegion(HeapRegion* r) {
if (!r->in_collection_set()) {
_blk.set_region(r);
if (r->isHumongous()) {
if (r->startsHumongous()) {
}
} else {
}
}
return false;
}
};
void
int worker_i) {
}
class VerifyRSCleanCardOopClosure: public OopClosure {
public:
template <class T> void do_oop_work(T* p) {
"Missed a rem set member.");
}
};
{
}
}
delete _seq_task;
delete _new_refs[i];
}
}
}
}
class ScanRSClosure : public HeapRegionClosure {
int _worker_i;
int _block_size;
bool _try_claimed;
public:
_cards(0),
_cards_done(0),
_try_claimed(false)
{
}
void set_try_claimed() { _try_claimed = true; }
_cards_done++;
r->new_dcto_closure(_oc,
// Set the "from" region in the closure.
_oc->set_region(r);
if (ParallelGCThreads > 0) {
// first find the used area
} else {
// The closure is not idempotent. We shouldn't look at objects
// allocated during the GC.
}
}
}
HeapWord* card_start) {
"RS names card %p: "
}
bool doHeapRegion(HeapRegion* r) {
// If we didn't return above, then
// _try_claimed || r->claim_iter()
// is true: either we're supposed to work on claimed-but-not-complete
// regions, or we successfully claimed the region.
// We claim cards in block so as to recude the contention. The block size is determined by
// the G1RSetScanBlockSize parameter.
}
if (current_card < jump_to_card) continue;
#if 0
#endif
_cards++;
if (!card_region->is_on_dirty_cards_region_list()) {
}
// If the card is dirty, then we will scan it during updateRS.
// We make the card as "claimed" lazily (so races are possible but they're benign),
// which reduces the number of duplicate scans (the rsets of the regions in the cset
// can intersect).
}
}
}
if (!_try_claimed) {
}
return false;
}
// Set all cards back to clean.
};
// We want the parallel threads to start their scanning at
// different collection set regions to avoid contention.
// If we have:
// n collection set regions
// p threads
// Then thread t will start at region t * floor (n/p)
if (ParallelGCThreads > 0) {
}
return result;
}
}
// Apply the appropriate closure to all remaining log entries.
// Now there should be no dirty cards.
if (G1RSLogCheckCardTable) {
// XXX This isn't true any more: keeping cards of young regions
// marked dirty broke it. Need some reasonable fix.
}
}
#ifndef PRODUCT
class PrintRSClosure : public HeapRegionClosure {
int _count;
public:
PrintRSClosure() : _count(0) {}
bool doHeapRegion(HeapRegion* r) {
"has no remset entries\n",
} else {
r->print();
}
return false;
}
};
#endif
class CountRSSizeClosure: public HeapRegionClosure {
enum {
N = 20,
MIN = 6
};
int _histo[N];
public:
for (int i = 0; i < N; i++) _histo[i] = 0;
}
bool doHeapRegion(HeapRegion* r) {
if (!r->continuesHumongous()) {
_n++;
_max_r = r;
}
// Fit it into a histo bin.
int s = 1 << MIN;
int i = 0;
s = s << 1;
i++;
}
_histo[i]++;
}
return false;
}
void print_histo() {
int mx = N;
while (mx >= 0) {
mx--;
}
1 << (MIN + i),
_histo[i]);
}
}
};
template <class T> void
int worker_i) {
// *p was in the collection set when p was pushed on "_new_refs", but
// another thread may have processed this location from an RS, so it
// might not point into the CS any longer. If so, it's obviously been
// processed, and we don't need to do anything further.
oc->set_region(r);
// If "p" has already been processed concurrently, this is
// idempotent.
}
}
}
void HRInto_G1RemSet::cleanupHRRS() {
}
void
int worker_i) {
#endif
if (worker_i == 0) {
}
// Make this into a command-line flag...
"max region is " PTR_FORMAT,
}
if (ParallelGCThreads > 0) {
// The two flags below were introduced temporarily to serialize
// the updating and scanning of remembered sets. There are some
// race conditions when these two operations are done in parallel
// and they are causing failures. When we resolve said race
// conditions, we'll revert back to parallel remembered set
// updating and scanning. See CRs 6677707 and 6677708.
if (G1UseParallelRSetUpdating || (worker_i == 0)) {
} else {
}
if (G1UseParallelRSetScanning || (worker_i == 0)) {
} else {
}
} else {
updateRS(0);
scanNewRefsRS(oc, 0);
}
}
void HRInto_G1RemSet::
#endif
cleanupHRRS();
_g1->set_refine_cte_cl_concurrency(false);
if (ParallelGCThreads > 0) {
set_par_traversal(true);
}
_cards_scanned[i] = 0;
}
_total_cards_scanned = 0;
}
class cleanUpIteratorsClosure : public HeapRegionClosure {
bool doHeapRegion(HeapRegion *r) {
return false;
}
};
class UpdateRSetOopsIntoCSImmediate : public OopClosure {
public:
template <class T> void do_oop_work(T* p) {
if (to->in_collection_set()) {
}
}
};
class UpdateRSetOopsIntoCSDeferred : public OopClosure {
public:
template <class T> void do_oop_work(T* p) {
}
}
}
};
}
}
}
_total_cards_scanned = 0;
// Cleanup after copy
#endif
_g1->set_refine_cte_cl_concurrency(true);
// Set all cards back to clean.
_g1->cleanUpCardTable();
if (ParallelGCThreads > 0) {
set_par_traversal(false);
}
if (_g1->evacuation_failed()) {
// Restore remembered sets for the regions pointing into
// the collection set.
if (G1DeferredRSUpdate) {
} else {
}
}
}
}
class UpdateRSObjectClosure: public ObjectClosure {
public:
}
};
class ScrubRSClosure: public HeapRegionClosure {
public:
{
}
bool doHeapRegion(HeapRegion* r) {
if (!r->continuesHumongous()) {
}
return false;
}
};
}
int worker_num, int claim_val) {
}
// Construct the region representing the card.
// And find the region containing it.
#endif
// Undirty the card.
// We must complete this write before we do any of the reads below.
OrderAccess::storeload();
// And process it, being careful of unallocated portions of TLAB's.
// If stop_point is non-null, then we encountered an unallocated region
// (perhaps the unfilled portion of a TLAB.) For now, we'll dirty the
// card and re-enqueue: if we put off the card until a GC pause, then the
// unallocated portion will be filled in. Alternatively, we might try
// the full complexity of the technique used in "regular" precleaning.
if (stop_point != NULL) {
// The card might have gotten re-dirtied and re-enqueued while we
// worked. (In fact, it's pretty likely.)
}
} else {
}
}
// If the card is no longer dirty, nothing to do.
// Construct the region representing the card.
// And find the region containing it.
if (r == NULL) {
return; // Not in the G1 heap (might be in perm, for example.)
}
// Why do we have to check here whether a card is on a young region,
// given that we dirty young regions and, as a result, the
// post-barrier is supposed to filter them out and never to enqueue
// them? When we allocate a new region as the "allocation region" we
// actually dirty its cards after we release the lock, since card
// dirtying while holding the lock was a performance bottleneck. So,
// as a result, it is possible for other threads to actually
// allocate objects in the region (after the acquire the lock)
// before all the cards on the region are dirtied. This is unlikely,
// and it doesn't happen often, but it can happen. So, the extra
// check below filters out those cards.
if (r->is_young()) {
return;
}
// While we are processing RSet buffers during the collection, we
// actually don't want to scan any cards on the collection set,
// since we don't want to update remebered sets with entries that
// point into the collection set, given that live objects from the
// collection set are about to move and such entries will be stale
// very soon. This change also deals with a reliability issue which
// involves scanning a card in the collection set and coming across
// an array that was being chunked and looking malformed. Note,
// however, that if evacuation fails, we have to scan any objects
// that were not moved and create any missing entries.
if (r->in_collection_set()) {
return;
}
// Should we defer processing the card?
//
// Previously the result from the insert_cache call would be
// either card_ptr (implying that card_ptr was currently "cold"),
// null (meaning we had inserted the card ptr into the "hot"
// cache, which had some headroom), or a "hot" card ptr
// extracted from the "hot" cache.
//
// Now that the _card_counts cache in the ConcurrentG1Refine
// instance is an evicting hash table, the result we get back
// could be from evicting the card ptr in an already occupied
// bucket (in which case we have replaced the card ptr in the
// bucket with card_ptr and "defer" is set to false). To avoid
// having a data structure (updates to which would need a lock)
// to hold these unprocessed dirty cards, we need to immediately
// process card_ptr. The actions needed to be taken on return
// from cache_insert are summarized in the following table:
//
// res defer action
// --------------------------------------------------------------
// null false card evicted from _card_counts & replaced with
// card_ptr; evicted ptr added to hot cache.
// No need to process res; immediately process card_ptr
//
// null true card not evicted from _card_counts; card_ptr added
// to hot cache.
// Nothing to do.
//
// non-null false card evicted from _card_counts & replaced with
// card_ptr; evicted ptr is currently "cold" or
// caused an eviction from the hot cache.
// Immediately process res; process card_ptr.
//
// non-null true card not evicted from _card_counts; card_ptr is
// currently cold, or caused an eviction from hot
// cache.
// Immediately process res; no need to process card_ptr.
bool defer = false;
if (r == NULL) {
} else {
// Process card pointer we get back from the hot card cache
}
}
}
if (!defer) {
}
}
class HRRSStatsIter: public HeapRegionClosure {
public:
HRRSStatsIter() :
_occupied(0),
_total_mem_sz(0),
_max_mem_sz(0),
{}
bool doHeapRegion(HeapRegion* r) {
if (r->continuesHumongous()) return false;
if (mem_sz > _max_mem_sz) {
_max_mem_sz_region = r;
}
_total_mem_sz += mem_sz;
return false;
}
};
class PrintRSThreadVTimeClosure : public ThreadClosure {
public:
}
};
void HRInto_G1RemSet::print_summary_info() {
#endif
}
(float)tot_processed_buffers);
(float)tot_processed_buffers);
if (G1UseHRIntoRS) {
HeapRegionRemSet::fl_mem_size()/K);
}
}
void HRInto_G1RemSet::prepare_for_verify() {
&& !_g1->full_collection()) {
cleanupHRRS();
_g1->set_refine_cte_cl_concurrency(false);
if (SafepointSynchronize::is_at_safepoint()) {
}
_cg1r->set_use_cache(false);
updateRS(0);
}
}