6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")

Make sure that two marking cycles do not overlap, i.e., a new one can only start after the concurrent marking thread finishes all its work. In the fix I piggy-back a couple of minor extra fixes: some general code reformatting for consistency (only around the code I modified), the removal of a field (G1CollectorPolicy::_should_initiate_conc_mark) which doesn't seem to be used at all (it's only set but never read), as well as moving the "is GC locker active" test earlier into the G1 pause / Full GC and using a more appropriate method for it.

Reviewed-by: johnc, jmasa, jcoomes, ysr
This commit is contained in:
Antonios Printezis 2010-04-06 10:59:45 -04:00
parent 2e3363d109
commit 719e7f0926
5 changed files with 186 additions and 59 deletions

View file

@ -42,8 +42,8 @@ class ConcurrentMarkThread: public ConcurrentGCThread {
private:
ConcurrentMark* _cm;
bool _started;
bool _in_progress;
volatile bool _started;
volatile bool _in_progress;
void sleepBeforeNextCycle();
@ -67,15 +67,25 @@ class ConcurrentMarkThread: public ConcurrentGCThread {
// Counting virtual time so far.
double vtime_count_accum() { return _vtime_count_accum; }
ConcurrentMark* cm() { return _cm; }
ConcurrentMark* cm() { return _cm; }
void set_started() { _started = true; }
void clear_started() { _started = false; }
bool started() { return _started; }
void set_started() { _started = true; }
void clear_started() { _started = false; }
bool started() { return _started; }
void set_in_progress() { _in_progress = true; }
void clear_in_progress() { _in_progress = false; }
bool in_progress() { return _in_progress; }
void set_in_progress() { _in_progress = true; }
void clear_in_progress() { _in_progress = false; }
bool in_progress() { return _in_progress; }
// This flag returns true from the moment a marking cycle is
// initiated (during the initial-mark pause when started() is set)
// to the moment when the cycle completes (just after the next
// marking bitmap has been cleared and in_progress() is
// cleared). While this flag is true we will not start another cycle
// so that cycles do not overlap. We cannot use just in_progress()
// as the CM thread might take some time to wake up before noticing
// that started() is set and set in_progress().
bool during_cycle() { return started() || in_progress(); }
// Yield for GC
void yield();