< prev index next >

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

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/parallel/pcTasks.hpp"
  30 #include "gc/parallel/psCompactionManager.inline.hpp"
  31 #include "gc/parallel/psParallelCompact.hpp"
  32 #include "gc/shared/collectedHeap.hpp"
  33 #include "gc/shared/gcTimer.hpp"
  34 #include "gc/shared/gcTraceTime.hpp"

  35 #include "memory/universe.hpp"
  36 #include "oops/objArrayKlass.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jvmtiExport.hpp"
  39 #include "runtime/fprofiler.hpp"
  40 #include "runtime/jniHandles.hpp"
  41 #include "runtime/thread.hpp"
  42 #include "runtime/vmThread.hpp"
  43 #include "services/management.hpp"
  44 #include "utilities/stack.inline.hpp"
  45 
  46 //
  47 // ThreadRootsMarkingTask
  48 //
  49 
  50 void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
  51   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
  52 
  53   ResourceMark rm;
  54 


 234   ParCompactionManager* cm =
 235     ParCompactionManager::gc_thread_compaction_manager(which);
 236 
 237 
 238   // If not all threads are active, get a draining stack
 239   // from the list.  Else, just use this threads draining stack.
 240   uint which_stack_index;
 241   bool use_all_workers = manager->all_workers_active();
 242   if (use_all_workers) {
 243     which_stack_index = which;
 244     assert(manager->active_workers() == ParallelGCThreads,
 245            "all_workers_active has been incorrectly set: "
 246            " active %d  ParallelGCThreads %u", manager->active_workers(),
 247            ParallelGCThreads);
 248   } else {
 249     which_stack_index = ParCompactionManager::pop_recycled_stack_index();
 250   }
 251 
 252   cm->set_region_stack_index(which_stack_index);
 253   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
 254   if (TraceDynamicGCThreads) {
 255     gclog_or_tty->print_cr("StealRegionCompactionTask::do_it "
 256                            "region_stack_index %d region_stack = " PTR_FORMAT " "
 257                            " empty (%d) use all workers %d",
 258     which_stack_index, p2i(ParCompactionManager::region_list(which_stack_index)),
 259     cm->region_stack()->is_empty(),
 260     use_all_workers);
 261   }
 262 
 263   // Has to drain stacks first because there may be regions on
 264   // preloaded onto the stack and this thread may never have
 265   // done a draining task.  Are the draining tasks needed?
 266 
 267   cm->drain_region_stacks();
 268 
 269   size_t region_index = 0;
 270   int random_seed = 17;
 271 
 272   // If we're the termination task, try 10 rounds of stealing before
 273   // setting the termination flag
 274 
 275   while(true) {
 276     if (ParCompactionManager::steal(which, &random_seed, region_index)) {
 277       PSParallelCompact::fill_and_update_region(cm, region_index);
 278       cm->drain_region_stacks();
 279     } else {
 280       if (terminator()->offer_termination()) {
 281         break;


 306 
 307 void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
 308   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 309 
 310   ParCompactionManager* cm =
 311     ParCompactionManager::gc_thread_compaction_manager(which);
 312 
 313   uint which_stack_index;
 314   bool use_all_workers = manager->all_workers_active();
 315   if (use_all_workers) {
 316     which_stack_index = which;
 317     assert(manager->active_workers() == ParallelGCThreads,
 318            "all_workers_active has been incorrectly set: "
 319            " active %d  ParallelGCThreads %u", manager->active_workers(),
 320            ParallelGCThreads);
 321   } else {
 322     which_stack_index = stack_index();
 323   }
 324 
 325   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
 326   if (TraceDynamicGCThreads) {
 327     gclog_or_tty->print_cr("DrainStacksCompactionTask::do_it which = %d "
 328                            "which_stack_index = %d/empty(%d) "
 329                            "use all workers %d",
 330                            which, which_stack_index,
 331                            cm->region_stack()->is_empty(),
 332                            use_all_workers);
 333   }
 334 
 335   cm->set_region_stack_index(which_stack_index);
 336 
 337   // Process any regions already in the compaction managers stacks.
 338   cm->drain_region_stacks();
 339 
 340   assert(cm->region_stack()->is_empty(), "Not empty");
 341 
 342   if (!use_all_workers) {
 343     // Always give up the region stack.
 344     assert(cm->region_stack() ==
 345            ParCompactionManager::region_list(cm->region_stack_index()),
 346            "region_stack and region_stack_index are inconsistent");
 347     ParCompactionManager::push_recycled_stack_index(cm->region_stack_index());
 348 
 349     if (TraceDynamicGCThreads) {
 350       void* old_region_stack = (void*) cm->region_stack();
 351       int old_region_stack_index = cm->region_stack_index();
 352       gclog_or_tty->print_cr("Pushing region stack " PTR_FORMAT "/%d",
 353         p2i(old_region_stack), old_region_stack_index);
 354     }
 355 
 356     cm->set_region_stack(NULL);
 357     cm->set_region_stack_index((uint)max_uintx);
 358   }
 359 }


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/parallel/pcTasks.hpp"
  30 #include "gc/parallel/psCompactionManager.inline.hpp"
  31 #include "gc/parallel/psParallelCompact.hpp"
  32 #include "gc/shared/collectedHeap.hpp"
  33 #include "gc/shared/gcTimer.hpp"
  34 #include "gc/shared/gcTraceTime.hpp"
  35 #include "logging/log.hpp"
  36 #include "memory/universe.hpp"
  37 #include "oops/objArrayKlass.inline.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "prims/jvmtiExport.hpp"
  40 #include "runtime/fprofiler.hpp"
  41 #include "runtime/jniHandles.hpp"
  42 #include "runtime/thread.hpp"
  43 #include "runtime/vmThread.hpp"
  44 #include "services/management.hpp"
  45 #include "utilities/stack.inline.hpp"
  46 
  47 //
  48 // ThreadRootsMarkingTask
  49 //
  50 
  51 void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
  52   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
  53 
  54   ResourceMark rm;
  55 


 235   ParCompactionManager* cm =
 236     ParCompactionManager::gc_thread_compaction_manager(which);
 237 
 238 
 239   // If not all threads are active, get a draining stack
 240   // from the list.  Else, just use this threads draining stack.
 241   uint which_stack_index;
 242   bool use_all_workers = manager->all_workers_active();
 243   if (use_all_workers) {
 244     which_stack_index = which;
 245     assert(manager->active_workers() == ParallelGCThreads,
 246            "all_workers_active has been incorrectly set: "
 247            " active %d  ParallelGCThreads %u", manager->active_workers(),
 248            ParallelGCThreads);
 249   } else {
 250     which_stack_index = ParCompactionManager::pop_recycled_stack_index();
 251   }
 252 
 253   cm->set_region_stack_index(which_stack_index);
 254   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));








 255 
 256   // Has to drain stacks first because there may be regions on
 257   // preloaded onto the stack and this thread may never have
 258   // done a draining task.  Are the draining tasks needed?
 259 
 260   cm->drain_region_stacks();
 261 
 262   size_t region_index = 0;
 263   int random_seed = 17;
 264 
 265   // If we're the termination task, try 10 rounds of stealing before
 266   // setting the termination flag
 267 
 268   while(true) {
 269     if (ParCompactionManager::steal(which, &random_seed, region_index)) {
 270       PSParallelCompact::fill_and_update_region(cm, region_index);
 271       cm->drain_region_stacks();
 272     } else {
 273       if (terminator()->offer_termination()) {
 274         break;


 299 
 300 void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
 301   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 302 
 303   ParCompactionManager* cm =
 304     ParCompactionManager::gc_thread_compaction_manager(which);
 305 
 306   uint which_stack_index;
 307   bool use_all_workers = manager->all_workers_active();
 308   if (use_all_workers) {
 309     which_stack_index = which;
 310     assert(manager->active_workers() == ParallelGCThreads,
 311            "all_workers_active has been incorrectly set: "
 312            " active %d  ParallelGCThreads %u", manager->active_workers(),
 313            ParallelGCThreads);
 314   } else {
 315     which_stack_index = stack_index();
 316   }
 317 
 318   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));








 319 
 320   cm->set_region_stack_index(which_stack_index);
 321 
 322   // Process any regions already in the compaction managers stacks.
 323   cm->drain_region_stacks();
 324 
 325   assert(cm->region_stack()->is_empty(), "Not empty");
 326 
 327   if (!use_all_workers) {
 328     // Always give up the region stack.
 329     assert(cm->region_stack() ==
 330            ParCompactionManager::region_list(cm->region_stack_index()),
 331            "region_stack and region_stack_index are inconsistent");
 332     ParCompactionManager::push_recycled_stack_index(cm->region_stack_index());







 333 
 334     cm->set_region_stack(NULL);
 335     cm->set_region_stack_index((uint)max_uintx);
 336   }
 337 }
< prev index next >