1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Mon Apr 05 12:19:22 2010 -0400 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Tue Apr 06 10:59:45 2010 -0400 1.3 @@ -724,11 +724,31 @@ 1.4 1.5 size_t _n_marks_since_last_pause; 1.6 1.7 - // True iff CM has been initiated. 1.8 - bool _conc_mark_initiated; 1.9 + // At the end of a pause we check the heap occupancy and we decide 1.10 + // whether we will start a marking cycle during the next pause. If 1.11 + // we decide that we want to do that, we will set this parameter to 1.12 + // true. So, this parameter will stay true between the end of a 1.13 + // pause and the beginning of a subsequent pause (not necessarily 1.14 + // the next one, see the comments on the next field) when we decide 1.15 + // that we will indeed start a marking cycle and do the initial-mark 1.16 + // work. 1.17 + volatile bool _initiate_conc_mark_if_possible; 1.18 1.19 - // True iff CM should be initiated 1.20 - bool _should_initiate_conc_mark; 1.21 + // If initiate_conc_mark_if_possible() is set at the beginning of a 1.22 + // pause, it is a suggestion that the pause should start a marking 1.23 + // cycle by doing the initial-mark work. However, it is possible 1.24 + // that the concurrent marking thread is still finishing up the 1.25 + // previous marking cycle (e.g., clearing the next marking 1.26 + // bitmap). If that is the case we cannot start a new cycle and 1.27 + // we'll have to wait for the concurrent marking thread to finish 1.28 + // what it is doing. In this case we will postpone the marking cycle 1.29 + // initiation decision for the next pause. When we eventually decide 1.30 + // to start a cycle, we will set _during_initial_mark_pause which 1.31 + // will stay true until the end of the initial-mark pause and it's 1.32 + // the condition that indicates that a pause is doing the 1.33 + // initial-mark work. 1.34 + volatile bool _during_initial_mark_pause; 1.35 + 1.36 bool _should_revert_to_full_young_gcs; 1.37 bool _last_full_young_gc; 1.38 1.39 @@ -981,9 +1001,21 @@ 1.40 // Add "hr" to the CS. 1.41 void add_to_collection_set(HeapRegion* hr); 1.42 1.43 - bool should_initiate_conc_mark() { return _should_initiate_conc_mark; } 1.44 - void set_should_initiate_conc_mark() { _should_initiate_conc_mark = true; } 1.45 - void unset_should_initiate_conc_mark(){ _should_initiate_conc_mark = false; } 1.46 + bool initiate_conc_mark_if_possible() { return _initiate_conc_mark_if_possible; } 1.47 + void set_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = true; } 1.48 + void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; } 1.49 + 1.50 + bool during_initial_mark_pause() { return _during_initial_mark_pause; } 1.51 + void set_during_initial_mark_pause() { _during_initial_mark_pause = true; } 1.52 + void clear_during_initial_mark_pause(){ _during_initial_mark_pause = false; } 1.53 + 1.54 + // This is called at the very beginning of an evacuation pause (it 1.55 + // has to be the first thing that the pause does). If 1.56 + // initiate_conc_mark_if_possible() is true, and the concurrent 1.57 + // marking thread has completed its work during the previous cycle, 1.58 + // it will set during_initial_mark_pause() to so that the pause does 1.59 + // the initial-mark work and start a marking cycle. 1.60 + void decide_on_conc_mark_initiation(); 1.61 1.62 // If an expansion would be appropriate, because recent GC overhead had 1.63 // exceeded the desired limit, return an amount to expand by.