< prev index next >

src/hotspot/share/gc/z/zMark.cpp

concurrent root iterator

122   ZRootsIterator _roots;                                                                                                             
123 
124 public:                                                                                                                              
125   ZMarkRootsTask(ZMark* mark) :                                                                                                      
126       ZTask("ZMarkRootsTask"),                                                                                                       
127       _mark(mark),                                                                                                                   
128       _roots() {}                                                                                                                    
129 
130   virtual void work() {                                                                                                              
131     ZMarkRootOopClosure cl;                                                                                                          
132     _roots.oops_do(&cl);                                                                                                             
133 
134     // Flush and free worker stacks. Needed here since                                                                               
135     // the set of workers executing during root scanning                                                                             
136     // can be different from the set of workers executing                                                                            
137     // during mark.                                                                                                                  
138     _mark->flush_and_free();                                                                                                         
139   }                                                                                                                                  
140 };                                                                                                                                   
141 
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
142 void ZMark::start() {                                                                                                                
143   // Verification                                                                                                                    
144   if (ZVerifyMarking) {                                                                                                              
145     verify_all_stacks_empty();                                                                                                       
146   }                                                                                                                                  
147 
148   // Prepare for concurrent mark                                                                                                     
149   prepare_mark();                                                                                                                    
150 
151   // Mark roots                                                                                                                      
152   ZMarkRootsTask task(this);                                                                                                         
153   _workers->run_parallel(&task);                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
154 }                                                                                                                                    
155 
156 void ZMark::prepare_work() {                                                                                                         
157   assert(_nworkers == _workers->nconcurrent(), "Invalid number of workers");                                                         
158 
159   // Set number of active workers                                                                                                    
160   _terminate.reset(_nworkers);                                                                                                       
161 
162   // Reset flush counters                                                                                                            
163   _work_nproactiveflush = _work_nterminateflush = 0;                                                                                 
164   _work_terminateflush = true;                                                                                                       
165 }                                                                                                                                    
166 
167 void ZMark::finish_work() {                                                                                                          
168   // Accumulate proactive/terminate flush counters                                                                                   
169   _nproactiveflush += _work_nproactiveflush;                                                                                         
170   _nterminateflush += _work_nterminateflush;                                                                                         
171 }                                                                                                                                    
172 

122   ZRootsIterator _roots;
123 
124 public:
125   ZMarkRootsTask(ZMark* mark) :
126       ZTask("ZMarkRootsTask"),
127       _mark(mark),
128       _roots() {}
129 
130   virtual void work() {
131     ZMarkRootOopClosure cl;
132     _roots.oops_do(&cl);
133 
134     // Flush and free worker stacks. Needed here since
135     // the set of workers executing during root scanning
136     // can be different from the set of workers executing
137     // during mark.
138     _mark->flush_and_free();
139   }
140 };
141 
142 class ZMarkConcurrentRootsTask : public ZTask {
143 private:
144   ZMark* const             _mark;
145   ZConcurrentRootsIterator _roots;
146 
147 public:
148   ZMarkConcurrentRootsTask(ZMark* mark) :
149       ZTask("ZMarkConcurrentRootsTask"),
150       _mark(mark),
151       _roots() {}
152 
153   virtual void work() {
154     ZMarkBarrierOopClosure</* finalizable */ false> cl;
155     _roots.oops_do(&cl);
156   }
157 };
158 
159 
160 void ZMark::start() {
161   // Verification
162   if (ZVerifyMarking) {
163     verify_all_stacks_empty();
164   }
165 
166   // Prepare for concurrent mark
167   prepare_mark();
168 
169   // Mark roots
170   ZMarkRootsTask task(this);
171   _workers->run_parallel(&task);
172 }
173 
174 void ZMark::mark_concurrent_roots() {
175   ZMarkConcurrentRootsTask task(this);
176   _workers->run_concurrent(&task);
177 }
178 
179 void ZMark::prepare_work() {
180   assert(_nworkers == _workers->nconcurrent(), "Invalid number of workers");
181 
182   // Set number of active workers
183   _terminate.reset(_nworkers);
184 
185   // Reset flush counters
186   _work_nproactiveflush = _work_nterminateflush = 0;
187   _work_terminateflush = true;
188 }
189 
190 void ZMark::finish_work() {
191   // Accumulate proactive/terminate flush counters
192   _nproactiveflush += _work_nproactiveflush;
193   _nterminateflush += _work_nterminateflush;
194 }
195 
< prev index next >