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

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 3294
bca17e38de00
child 4128
f81a7c0c618d
permissions
-rw-r--r--

6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>

     1 /*
     2  * Copyright (c) 2002, 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  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
    28 #include "memory/allocation.hpp"
    29 #include "utilities/growableArray.hpp"
    31 //
    32 // psTasks.hpp is a collection of GCTasks used by the
    33 // parallelScavenge collector.
    34 //
    36 class GCTask;
    37 class OopClosure;
    38 class OopStack;
    39 class ObjectStartArray;
    40 class ParallelTaskTerminator;
    41 class MutableSpace;
    42 class PSOldGen;
    43 class Thread;
    44 class VMThread;
    46 //
    47 // ScavengeRootsTask
    48 //
    49 // This task scans all the roots of a given type.
    50 //
    51 //
    53 class ScavengeRootsTask : public GCTask {
    54  public:
    55   enum RootType {
    56     universe              = 1,
    57     jni_handles           = 2,
    58     threads               = 3,
    59     object_synchronizer   = 4,
    60     flat_profiler         = 5,
    61     system_dictionary     = 6,
    62     management            = 7,
    63     jvmti                 = 8,
    64     code_cache            = 9
    65   };
    66  private:
    67   RootType _root_type;
    68  public:
    69   ScavengeRootsTask(RootType value) : _root_type(value) {}
    71   char* name() { return (char *)"scavenge-roots-task"; }
    73   virtual void do_it(GCTaskManager* manager, uint which);
    74 };
    76 //
    77 // ThreadRootsTask
    78 //
    79 // This task scans the roots of a single thread. This task
    80 // enables scanning of thread roots in parallel.
    81 //
    83 class ThreadRootsTask : public GCTask {
    84  private:
    85   JavaThread* _java_thread;
    86   VMThread* _vm_thread;
    87  public:
    88   ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
    89   ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
    91   char* name() { return (char *)"thread-roots-task"; }
    93   virtual void do_it(GCTaskManager* manager, uint which);
    94 };
    96 //
    97 // StealTask
    98 //
    99 // This task is used to distribute work to idle threads.
   100 //
   102 class StealTask : public GCTask {
   103  private:
   104    ParallelTaskTerminator* const _terminator;
   105  public:
   106   char* name() { return (char *)"steal-task"; }
   108   StealTask(ParallelTaskTerminator* t);
   110   ParallelTaskTerminator* terminator() { return _terminator; }
   112   virtual void do_it(GCTaskManager* manager, uint which);
   113 };
   115 //
   116 // SerialOldToYoungRootsTask
   117 //
   118 // This task is used to scan for roots in the perm gen
   120 class SerialOldToYoungRootsTask : public GCTask {
   121  private:
   122   PSOldGen* _gen;
   123   HeapWord* _gen_top;
   125  public:
   126   SerialOldToYoungRootsTask(PSOldGen *gen, HeapWord* gen_top) :
   127     _gen(gen), _gen_top(gen_top) { }
   129   char* name() { return (char *)"serial-old-to-young-roots-task"; }
   131   virtual void do_it(GCTaskManager* manager, uint which);
   132 };
   134 //
   135 // OldToYoungRootsTask
   136 //
   137 // This task is used to scan old to young roots in parallel
   138 //
   139 // A GC thread executing this tasks divides the generation (old gen)
   140 // into slices and takes a stripe in the slice as its part of the
   141 // work.
   142 //
   143 //      +===============+        slice 0
   144 //      |  stripe 0     |
   145 //      +---------------+
   146 //      |  stripe 1     |
   147 //      +---------------+
   148 //      |  stripe 2     |
   149 //      +---------------+
   150 //      |  stripe 3     |
   151 //      +===============+        slice 1
   152 //      |  stripe 0     |
   153 //      +---------------+
   154 //      |  stripe 1     |
   155 //      +---------------+
   156 //      |  stripe 2     |
   157 //      +---------------+
   158 //      |  stripe 3     |
   159 //      +===============+        slice 2
   160 //      ...
   161 //
   162 // A task is created for each stripe.  In this case there are 4 tasks
   163 // created.  A GC thread first works on its stripe within slice 0
   164 // and then moves to its stripe in the next slice until all stripes
   165 // exceed the top of the generation.  Note that having fewer GC threads
   166 // than stripes works because all the tasks are executed so all stripes
   167 // will be covered.  In this example if 4 tasks have been created to cover
   168 // all the stripes and there are only 3 threads, one of the threads will
   169 // get the tasks with the 4th stripe.  However, there is a dependence in
   170 // CardTableExtension::scavenge_contents_parallel() on the number
   171 // of tasks created.  In scavenge_contents_parallel the distance
   172 // to the next stripe is calculated based on the number of tasks.
   173 // If the stripe width is ssize, a task's next stripe is at
   174 // ssize * number_of_tasks (= slice_stride).  In this case after
   175 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
   176 // by adding slice_stride to the start of stripe 0 in slice 0 to get
   177 // to the start of stride 0 in slice 1.
   179 class OldToYoungRootsTask : public GCTask {
   180  private:
   181   PSOldGen* _gen;
   182   HeapWord* _gen_top;
   183   uint _stripe_number;
   184   uint _stripe_total;
   186  public:
   187   OldToYoungRootsTask(PSOldGen *gen,
   188                       HeapWord* gen_top,
   189                       uint stripe_number,
   190                       uint stripe_total) :
   191     _gen(gen),
   192     _gen_top(gen_top),
   193     _stripe_number(stripe_number),
   194     _stripe_total(stripe_total) { }
   196   char* name() { return (char *)"old-to-young-roots-task"; }
   198   virtual void do_it(GCTaskManager* manager, uint which);
   199 };
   201 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP

mercurial