< prev index next >

src/share/vm/gc/parallel/pcTasks.cpp

Print this page
rev 10845 : 8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
Reviewed-by:


 219     while (ParCompactionManager::steal(which, &random_seed, obj)) {
 220       cm->follow_contents(obj);
 221       cm->follow_marking_stacks();
 222     }
 223   } while (!terminator()->offer_termination());
 224 }
 225 
 226 //
 227 // StealRegionCompactionTask
 228 //
 229 
 230 StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t):
 231   _terminator(t) {}
 232 
 233 void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) {
 234   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 235 
 236   ParCompactionManager* cm =
 237     ParCompactionManager::gc_thread_compaction_manager(which);
 238 
 239 
 240   // If not all threads are active, get a draining stack
 241   // from the list.  Else, just use this threads draining stack.
 242   uint which_stack_index;
 243   bool use_all_workers = manager->all_workers_active();
 244   if (use_all_workers) {
 245     which_stack_index = which;
 246     assert(manager->active_workers() == ParallelGCThreads,
 247            "all_workers_active has been incorrectly set: "
 248            " active %d  ParallelGCThreads %u", manager->active_workers(),
 249            ParallelGCThreads);
 250   } else {
 251     which_stack_index = ParCompactionManager::pop_recycled_stack_index();
 252   }
 253 
 254   cm->set_region_stack_index(which_stack_index);
 255   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
 256 
 257   // Has to drain stacks first because there may be regions on
 258   // preloaded onto the stack and this thread may never have
 259   // done a draining task.  Are the draining tasks needed?
 260 
 261   cm->drain_region_stacks();
 262 


 263   size_t region_index = 0;
 264   int random_seed = 17;
 265 
 266   // If we're the termination task, try 10 rounds of stealing before
 267   // setting the termination flag
 268 
 269   while(true) {
 270     if (ParCompactionManager::steal(which, &random_seed, region_index)) {
 271       PSParallelCompact::fill_and_update_region(cm, region_index);
 272       cm->drain_region_stacks();
 273     } else {
 274       if (terminator()->offer_termination()) {
 275         break;
 276       }
 277       // Go around again.
 278     }
 279   }
 280   return;
 281 }
 282 
 283 UpdateDensePrefixTask::UpdateDensePrefixTask(
 284                                    PSParallelCompact::SpaceId space_id,
 285                                    size_t region_index_start,
 286                                    size_t region_index_end) :
 287   _space_id(space_id), _region_index_start(region_index_start),
 288   _region_index_end(region_index_end) {}
 289 
 290 void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
 291 
 292   ParCompactionManager* cm =
 293     ParCompactionManager::gc_thread_compaction_manager(which);
 294 
 295   PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
 296                                                          _space_id,
 297                                                          _region_index_start,
 298                                                          _region_index_end);
 299 }
 300 
 301 void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
 302   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 303 
 304   ParCompactionManager* cm =
 305     ParCompactionManager::gc_thread_compaction_manager(which);
 306 
 307   uint which_stack_index;
 308   bool use_all_workers = manager->all_workers_active();
 309   if (use_all_workers) {
 310     which_stack_index = which;
 311     assert(manager->active_workers() == ParallelGCThreads,
 312            "all_workers_active has been incorrectly set: "
 313            " active %d  ParallelGCThreads %u", manager->active_workers(),
 314            ParallelGCThreads);
 315   } else {
 316     which_stack_index = stack_index();
 317   }
 318 
 319   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
 320 
 321   cm->set_region_stack_index(which_stack_index);
 322 
 323   // Process any regions already in the compaction managers stacks.
 324   cm->drain_region_stacks();
 325 
 326   assert(cm->region_stack()->is_empty(), "Not empty");
 327 
 328   if (!use_all_workers) {
 329     // Always give up the region stack.
 330     assert(cm->region_stack() ==
 331            ParCompactionManager::region_list(cm->region_stack_index()),
 332            "region_stack and region_stack_index are inconsistent");
 333     ParCompactionManager::push_recycled_stack_index(cm->region_stack_index());
 334 
 335     cm->set_region_stack(NULL);
 336     cm->set_region_stack_index((uint)max_uintx);
 337   }
 338 }


 219     while (ParCompactionManager::steal(which, &random_seed, obj)) {
 220       cm->follow_contents(obj);
 221       cm->follow_marking_stacks();
 222     }
 223   } while (!terminator()->offer_termination());
 224 }
 225 
 226 //
 227 // StealRegionCompactionTask
 228 //
 229 
 230 StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t):
 231   _terminator(t) {}
 232 
 233 void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) {
 234   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 235 
 236   ParCompactionManager* cm =
 237     ParCompactionManager::gc_thread_compaction_manager(which);
 238 
 239   // Drain the stacks that have been preloaded with regions
 240   // that are ready to fill.



















 241 
 242   cm->drain_region_stacks();
 243 
 244   guarantee(cm->region_stack()->is_empty(), "Not empty");
 245 
 246   size_t region_index = 0;
 247   int random_seed = 17;
 248 



 249   while(true) {
 250     if (ParCompactionManager::steal(which, &random_seed, region_index)) {
 251       PSParallelCompact::fill_and_update_region(cm, region_index);
 252       cm->drain_region_stacks();
 253     } else {
 254       if (terminator()->offer_termination()) {
 255         break;
 256       }
 257       // Go around again.
 258     }
 259   }
 260   return;
 261 }
 262 
 263 UpdateDensePrefixTask::UpdateDensePrefixTask(
 264                                    PSParallelCompact::SpaceId space_id,
 265                                    size_t region_index_start,
 266                                    size_t region_index_end) :
 267   _space_id(space_id), _region_index_start(region_index_start),
 268   _region_index_end(region_index_end) {}
 269 
 270 void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
 271 
 272   ParCompactionManager* cm =
 273     ParCompactionManager::gc_thread_compaction_manager(which);
 274 
 275   PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
 276                                                          _space_id,
 277                                                          _region_index_start,
 278                                                          _region_index_end);







































 279 }
< prev index next >