This commit is contained in:
Bengt Rutisson 2015-10-09 20:45:45 +00:00
commit 30e8dff916
6 changed files with 79 additions and 64 deletions

View File

@ -1654,7 +1654,7 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) {
_collectorState = Resetting;
assert(_restart_addr == NULL,
"Should have been NULL'd before baton was passed");
reset(false /* == !concurrent */);
reset_stw();
_cmsGen->reset_after_compaction();
_concurrent_cycles_since_last_unload = 0;
@ -1934,7 +1934,7 @@ void CMSCollector::collect_in_background(GCCause::Cause cause) {
}
case Resetting:
// CMS heap resizing has been completed
reset(true);
reset_concurrent();
assert(_collectorState == Idling, "Collector state should "
"have changed");
@ -5698,8 +5698,7 @@ void CMSCollector::sweepWork(ConcurrentMarkSweepGeneration* old_gen) {
// Reset CMS data structures (for now just the marking bit map)
// preparatory for the next cycle.
void CMSCollector::reset(bool concurrent) {
if (concurrent) {
void CMSCollector::reset_concurrent() {
CMSTokenSyncWithLocks ts(true, bitMapLock());
// If the state is not "Resetting", the foreground thread
@ -5752,14 +5751,18 @@ void CMSCollector::reset(bool concurrent) {
// and count.
size_policy()->reset_gc_overhead_limit_count();
_collectorState = Idling;
} else {
register_gc_end();
}
// Same as above but for STW paths
void CMSCollector::reset_stw() {
// already have the lock
assert(_collectorState == Resetting, "just checking");
assert_lock_strong(bitMapLock());
GCIdMarkAndRestore gc_id_mark(_cmsThread->gc_id());
_markBitMap.clear_all();
_collectorState = Idling;
}
register_gc_end();
}

View File

@ -799,8 +799,10 @@ class CMSCollector: public CHeapObj<mtGC> {
// Concurrent sweeping work
void sweepWork(ConcurrentMarkSweepGeneration* old_gen);
// (Concurrent) resetting of support data structures
void reset(bool concurrent);
// Concurrent resetting of support data structures
void reset_concurrent();
// Resetting of support data structures from a STW full GC
void reset_stw();
// Clear _expansion_cause fields of constituent generations
void clear_expansion_cause();

View File

@ -109,7 +109,7 @@ void ConcurrentMarkThread::run() {
break;
}
GCIdMark gc_id_mark;
assert(GCId::current() != GCId::undefined(), "GC id should have been set up by the initial mark GC.");
{
ResourceMark rm;
HandleMark hm;

View File

@ -2612,15 +2612,18 @@ void G1CollectedHeap::increment_old_marking_cycles_completed(bool concurrent) {
}
void G1CollectedHeap::register_concurrent_cycle_start(const Ticks& start_time) {
GCIdMarkAndRestore conc_gc_id_mark;
collector_state()->set_concurrent_cycle_started(true);
_gc_timer_cm->register_gc_start(start_time);
_gc_tracer_cm->report_gc_start(gc_cause(), _gc_timer_cm->gc_start());
trace_heap_before_gc(_gc_tracer_cm);
_cmThread->set_gc_id(GCId::current());
}
void G1CollectedHeap::register_concurrent_cycle_end() {
if (collector_state()->concurrent_cycle_started()) {
GCIdMarkAndRestore conc_gc_id_mark(_cmThread->gc_id());
if (_cm->has_aborted()) {
_gc_tracer_cm->report_concurrent_mode_failure();
}
@ -2643,6 +2646,7 @@ void G1CollectedHeap::trace_heap_after_concurrent_cycle() {
// but before the concurrent cycle end has been registered.
// Make sure that we only send the heap information once.
if (!_heap_summary_sent) {
GCIdMarkAndRestore conc_gc_id_mark(_cmThread->gc_id());
trace_heap_after_gc(_gc_tracer_cm);
_heap_summary_sent = true;
}

View File

@ -60,6 +60,11 @@ GCIdMark::~GCIdMark() {
}
GCIdMarkAndRestore::GCIdMarkAndRestore() : _gc_id(GCId::create()) {
_previous_gc_id = GCId::current(); // will assert that the GC Id is not undefined
currentNamedthread()->set_gc_id(_gc_id);
}
GCIdMarkAndRestore::GCIdMarkAndRestore(uint gc_id) : _gc_id(gc_id) {
_previous_gc_id = GCId::current(); // will assert that the GC Id is not undefinied
currentNamedthread()->set_gc_id(_gc_id);
}

View File

@ -55,6 +55,7 @@ class GCIdMarkAndRestore : public StackObj {
uint _previous_gc_id;
public:
GCIdMarkAndRestore();
GCIdMarkAndRestore(uint gc_id);
~GCIdMarkAndRestore();
};