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

Mon, 20 Sep 2010 14:38:38 -0700

author
jmasa
date
Mon, 20 Sep 2010 14:38:38 -0700
changeset 2188
8b10f48633dc
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6984287: Regularize how GC parallel workers are specified.
Summary: Associate number of GC workers with the workgang as opposed to the task.
Reviewed-by: johnc, ysr

     1 /*
     2  * Copyright (c) 2005, 2010, 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  */
    26 // Tasks for parallel compaction of the old generation
    27 //
    28 // Tasks are created and enqueued on a task queue. The
    29 // tasks for parallel old collector for marking objects
    30 // are MarkFromRootsTask and ThreadRootsMarkingTask.
    31 //
    32 // MarkFromRootsTask's are created
    33 // with a root group (e.g., jni_handles) and when the do_it()
    34 // method of a MarkFromRootsTask is executed, it starts marking
    35 // form it's root group.
    36 //
    37 // ThreadRootsMarkingTask's are created for each Java thread.  When
    38 // the do_it() method of a ThreadRootsMarkingTask is executed, it
    39 // starts marking from the thread's roots.
    40 //
    41 // The enqueuing of the MarkFromRootsTask and ThreadRootsMarkingTask
    42 // do little more than create the task and put it on a queue.  The
    43 // queue is a GCTaskQueue and threads steal tasks from this GCTaskQueue.
    44 //
    45 // In addition to the MarkFromRootsTask and ThreadRootsMarkingTask
    46 // tasks there are StealMarkingTask tasks.  The StealMarkingTask's
    47 // steal a reference from the marking stack of another
    48 // thread and transitively marks the object of the reference
    49 // and internal references.  After successfully stealing a reference
    50 // and marking it, the StealMarkingTask drains its marking stack
    51 // stack before attempting another steal.
    52 //
    53 // ThreadRootsMarkingTask
    54 //
    55 // This task marks from the roots of a single thread. This task
    56 // enables marking of thread roots in parallel.
    57 //
    59 class ParallelTaskTerminator;
    61 class ThreadRootsMarkingTask : public GCTask {
    62  private:
    63   JavaThread* _java_thread;
    64   VMThread* _vm_thread;
    65  public:
    66   ThreadRootsMarkingTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
    67   ThreadRootsMarkingTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
    69   char* name() { return (char *)"thread-roots-marking-task"; }
    71   virtual void do_it(GCTaskManager* manager, uint which);
    72 };
    75 //
    76 // MarkFromRootsTask
    77 //
    78 // This task marks from all the roots to all live
    79 // objects.
    80 //
    81 //
    83 class MarkFromRootsTask : public GCTask {
    84  public:
    85   enum RootType {
    86     universe              = 1,
    87     jni_handles           = 2,
    88     threads               = 3,
    89     object_synchronizer   = 4,
    90     flat_profiler         = 5,
    91     management            = 6,
    92     jvmti                 = 7,
    93     system_dictionary     = 8,
    94     vm_symbols            = 9,
    95     reference_processing  = 10,
    96     code_cache            = 11
    97   };
    98  private:
    99   RootType _root_type;
   100  public:
   101   MarkFromRootsTask(RootType value) : _root_type(value) {}
   103   char* name() { return (char *)"mark-from-roots-task"; }
   105   virtual void do_it(GCTaskManager* manager, uint which);
   106 };
   108 //
   109 // RefProcTaskProxy
   110 //
   111 // This task is used as a proxy to parallel reference processing tasks .
   112 //
   114 class RefProcTaskProxy : public GCTask {
   115   typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
   116   ProcessTask & _rp_task;
   117   uint          _work_id;
   118 public:
   119   RefProcTaskProxy(ProcessTask & rp_task, uint work_id)
   120     : _rp_task(rp_task),
   121       _work_id(work_id)
   122   { }
   124 private:
   125   virtual char* name() { return (char *)"Process referents by policy in parallel"; }
   127   virtual void do_it(GCTaskManager* manager, uint which);
   128 };
   132 //
   133 // RefEnqueueTaskProxy
   134 //
   135 // This task is used as a proxy to parallel reference processing tasks .
   136 //
   138 class RefEnqueueTaskProxy: public GCTask {
   139   typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
   140   EnqueueTask& _enq_task;
   141   uint         _work_id;
   143 public:
   144   RefEnqueueTaskProxy(EnqueueTask& enq_task, uint work_id)
   145     : _enq_task(enq_task),
   146       _work_id(work_id)
   147   { }
   149   virtual char* name() { return (char *)"Enqueue reference objects in parallel"; }
   150   virtual void do_it(GCTaskManager* manager, uint which)
   151   {
   152     _enq_task.work(_work_id);
   153   }
   154 };
   157 //
   158 // RefProcTaskExecutor
   159 //
   160 // Task executor is an interface for the reference processor to run
   161 // tasks using GCTaskManager.
   162 //
   164 class RefProcTaskExecutor: public AbstractRefProcTaskExecutor {
   165   virtual void execute(ProcessTask& task);
   166   virtual void execute(EnqueueTask& task);
   167 };
   170 //
   171 // StealMarkingTask
   172 //
   173 // This task is used to distribute work to idle threads.
   174 //
   176 class StealMarkingTask : public GCTask {
   177  private:
   178    ParallelTaskTerminator* const _terminator;
   179  private:
   181  public:
   182   char* name() { return (char *)"steal-marking-task"; }
   184   StealMarkingTask(ParallelTaskTerminator* t);
   186   ParallelTaskTerminator* terminator() { return _terminator; }
   188   virtual void do_it(GCTaskManager* manager, uint which);
   189 };
   191 //
   192 // StealRegionCompactionTask
   193 //
   194 // This task is used to distribute work to idle threads.
   195 //
   197 class StealRegionCompactionTask : public GCTask {
   198  private:
   199    ParallelTaskTerminator* const _terminator;
   200  public:
   201   StealRegionCompactionTask(ParallelTaskTerminator* t);
   203   char* name() { return (char *)"steal-region-task"; }
   204   ParallelTaskTerminator* terminator() { return _terminator; }
   206   virtual void do_it(GCTaskManager* manager, uint which);
   207 };
   209 //
   210 // UpdateDensePrefixTask
   211 //
   212 // This task is used to update the dense prefix
   213 // of a space.
   214 //
   216 class UpdateDensePrefixTask : public GCTask {
   217  private:
   218   PSParallelCompact::SpaceId _space_id;
   219   size_t _region_index_start;
   220   size_t _region_index_end;
   222  public:
   223   char* name() { return (char *)"update-dense_prefix-task"; }
   225   UpdateDensePrefixTask(PSParallelCompact::SpaceId space_id,
   226                         size_t region_index_start,
   227                         size_t region_index_end);
   229   virtual void do_it(GCTaskManager* manager, uint which);
   230 };
   232 //
   233 // DrainStacksCompactionTask
   234 //
   235 // This task processes regions that have been added to the stacks of each
   236 // compaction manager.
   237 //
   238 // Trying to use one draining thread does not work because there are no
   239 // guarantees about which task will be picked up by which thread.  For example,
   240 // if thread A gets all the preloaded regions, thread A may not get a draining
   241 // task (they may all be done by other threads).
   242 //
   244 class DrainStacksCompactionTask : public GCTask {
   245  uint _stack_index;
   246  uint stack_index() { return _stack_index; }
   247  public:
   248   DrainStacksCompactionTask(uint stack_index) : GCTask(),
   249                                                 _stack_index(stack_index) {};
   250   char* name() { return (char *)"drain-region-task"; }
   251   virtual void do_it(GCTaskManager* manager, uint which);
   252 };

mercurial