src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp

Thu, 16 Jun 2011 15:51:57 -0400

author
tonyp
date
Thu, 16 Jun 2011 15:51:57 -0400
changeset 2971
c9ca3f51cf41
parent 2708
1d1603768966
child 3115
c2bf0120ee5d
permissions
-rw-r--r--

6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
Summary: Remove two unused parameters from the mem_allocate() method and update its uses accordingly.
Reviewed-by: stefank, johnc

     1 /*
     2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    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  */
    25 #include "precompiled.hpp"
    26 #include "classfile/systemDictionary.hpp"
    27 #include "code/codeCache.hpp"
    28 #include "gc_implementation/parallelScavenge/pcTasks.hpp"
    29 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
    30 #include "gc_interface/collectedHeap.hpp"
    31 #include "memory/universe.hpp"
    32 #include "oops/objArrayKlass.inline.hpp"
    33 #include "oops/oop.inline.hpp"
    34 #include "oops/oop.pcgc.inline.hpp"
    35 #include "prims/jvmtiExport.hpp"
    36 #include "runtime/fprofiler.hpp"
    37 #include "runtime/jniHandles.hpp"
    38 #include "runtime/thread.hpp"
    39 #include "runtime/vmThread.hpp"
    40 #include "services/management.hpp"
    42 //
    43 // ThreadRootsMarkingTask
    44 //
    46 void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
    47   assert(Universe::heap()->is_gc_active(), "called outside gc");
    49   ResourceMark rm;
    51   NOT_PRODUCT(TraceTime tm("ThreadRootsMarkingTask",
    52     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
    53   ParCompactionManager* cm =
    54     ParCompactionManager::gc_thread_compaction_manager(which);
    55   PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
    56   CodeBlobToOopClosure mark_and_push_in_blobs(&mark_and_push_closure, /*do_marking=*/ true);
    58   if (_java_thread != NULL)
    59     _java_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs);
    61   if (_vm_thread != NULL)
    62     _vm_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs);
    64   // Do the real work
    65   cm->follow_marking_stacks();
    66 }
    69 void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) {
    70   assert(Universe::heap()->is_gc_active(), "called outside gc");
    72   NOT_PRODUCT(TraceTime tm("MarkFromRootsTask",
    73     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
    74   ParCompactionManager* cm =
    75     ParCompactionManager::gc_thread_compaction_manager(which);
    76   PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
    78   switch (_root_type) {
    79     case universe:
    80       Universe::oops_do(&mark_and_push_closure);
    81       break;
    83     case reference_processing:
    84       ReferenceProcessor::oops_do(&mark_and_push_closure);
    85       break;
    87     case jni_handles:
    88       JNIHandles::oops_do(&mark_and_push_closure);
    89       break;
    91     case threads:
    92     {
    93       ResourceMark rm;
    94       CodeBlobToOopClosure each_active_code_blob(&mark_and_push_closure, /*do_marking=*/ true);
    95       Threads::oops_do(&mark_and_push_closure, &each_active_code_blob);
    96     }
    97     break;
    99     case object_synchronizer:
   100       ObjectSynchronizer::oops_do(&mark_and_push_closure);
   101       break;
   103     case flat_profiler:
   104       FlatProfiler::oops_do(&mark_and_push_closure);
   105       break;
   107     case management:
   108       Management::oops_do(&mark_and_push_closure);
   109       break;
   111     case jvmti:
   112       JvmtiExport::oops_do(&mark_and_push_closure);
   113       break;
   115     case system_dictionary:
   116       SystemDictionary::always_strong_oops_do(&mark_and_push_closure);
   117       break;
   119     case code_cache:
   120       // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
   121       //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure));
   122       break;
   124     default:
   125       fatal("Unknown root type");
   126   }
   128   // Do the real work
   129   cm->follow_marking_stacks();
   130 }
   133 //
   134 // RefProcTaskProxy
   135 //
   137 void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
   138 {
   139   assert(Universe::heap()->is_gc_active(), "called outside gc");
   141   NOT_PRODUCT(TraceTime tm("RefProcTask",
   142     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
   143   ParCompactionManager* cm =
   144     ParCompactionManager::gc_thread_compaction_manager(which);
   145   PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
   146   PSParallelCompact::FollowStackClosure follow_stack_closure(cm);
   147   _rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(),
   148                 mark_and_push_closure, follow_stack_closure);
   149 }
   151 //
   152 // RefProcTaskExecutor
   153 //
   155 void RefProcTaskExecutor::execute(ProcessTask& task)
   156 {
   157   ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
   158   uint parallel_gc_threads = heap->gc_task_manager()->workers();
   159   RegionTaskQueueSet* qset = ParCompactionManager::region_array();
   160   ParallelTaskTerminator terminator(parallel_gc_threads, qset);
   161   GCTaskQueue* q = GCTaskQueue::create();
   162   for(uint i=0; i<parallel_gc_threads; i++) {
   163     q->enqueue(new RefProcTaskProxy(task, i));
   164   }
   165   if (task.marks_oops_alive()) {
   166     if (parallel_gc_threads>1) {
   167       for (uint j=0; j<parallel_gc_threads; j++) {
   168         q->enqueue(new StealMarkingTask(&terminator));
   169       }
   170     }
   171   }
   172   PSParallelCompact::gc_task_manager()->execute_and_wait(q);
   173 }
   175 void RefProcTaskExecutor::execute(EnqueueTask& task)
   176 {
   177   ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
   178   uint parallel_gc_threads = heap->gc_task_manager()->workers();
   179   GCTaskQueue* q = GCTaskQueue::create();
   180   for(uint i=0; i<parallel_gc_threads; i++) {
   181     q->enqueue(new RefEnqueueTaskProxy(task, i));
   182   }
   183   PSParallelCompact::gc_task_manager()->execute_and_wait(q);
   184 }
   186 //
   187 // StealMarkingTask
   188 //
   190 StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) :
   191   _terminator(t) {}
   193 void StealMarkingTask::do_it(GCTaskManager* manager, uint which) {
   194   assert(Universe::heap()->is_gc_active(), "called outside gc");
   196   NOT_PRODUCT(TraceTime tm("StealMarkingTask",
   197     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
   199   ParCompactionManager* cm =
   200     ParCompactionManager::gc_thread_compaction_manager(which);
   201   PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
   203   oop obj = NULL;
   204   ObjArrayTask task;
   205   int random_seed = 17;
   206   do {
   207     while (ParCompactionManager::steal_objarray(which, &random_seed, task)) {
   208       objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint();
   209       k->oop_follow_contents(cm, task.obj(), task.index());
   210       cm->follow_marking_stacks();
   211     }
   212     while (ParCompactionManager::steal(which, &random_seed, obj)) {
   213       obj->follow_contents(cm);
   214       cm->follow_marking_stacks();
   215     }
   216   } while (!terminator()->offer_termination());
   217 }
   219 //
   220 // StealRegionCompactionTask
   221 //
   224 StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t):
   225   _terminator(t) {}
   227 void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) {
   228   assert(Universe::heap()->is_gc_active(), "called outside gc");
   230   NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask",
   231     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
   233   ParCompactionManager* cm =
   234     ParCompactionManager::gc_thread_compaction_manager(which);
   236   // Has to drain stacks first because there may be regions on
   237   // preloaded onto the stack and this thread may never have
   238   // done a draining task.  Are the draining tasks needed?
   240   cm->drain_region_stacks();
   242   size_t region_index = 0;
   243   int random_seed = 17;
   245   // If we're the termination task, try 10 rounds of stealing before
   246   // setting the termination flag
   248   while(true) {
   249     if (ParCompactionManager::steal(which, &random_seed, region_index)) {
   250       PSParallelCompact::fill_and_update_region(cm, region_index);
   251       cm->drain_region_stacks();
   252     } else {
   253       if (terminator()->offer_termination()) {
   254         break;
   255       }
   256       // Go around again.
   257     }
   258   }
   259   return;
   260 }
   262 UpdateDensePrefixTask::UpdateDensePrefixTask(
   263                                    PSParallelCompact::SpaceId space_id,
   264                                    size_t region_index_start,
   265                                    size_t region_index_end) :
   266   _space_id(space_id), _region_index_start(region_index_start),
   267   _region_index_end(region_index_end) {}
   269 void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
   271   NOT_PRODUCT(TraceTime tm("UpdateDensePrefixTask",
   272     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
   274   ParCompactionManager* cm =
   275     ParCompactionManager::gc_thread_compaction_manager(which);
   277   PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
   278                                                          _space_id,
   279                                                          _region_index_start,
   280                                                          _region_index_end);
   281 }
   283 void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
   284   assert(Universe::heap()->is_gc_active(), "called outside gc");
   286   NOT_PRODUCT(TraceTime tm("DrainStacksCompactionTask",
   287     PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
   289   ParCompactionManager* cm =
   290     ParCompactionManager::gc_thread_compaction_manager(which);
   292   // Process any regions already in the compaction managers stacks.
   293   cm->drain_region_stacks();
   294 }

mercurial