1 /*
   2  * Copyright (c) 2002, 2005, 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  */
  24 
  25 //
  26 // psTasks.hpp is a collection of GCTasks used by the
  27 // parallelScavenge collector.
  28 //
  29 
  30 class GCTask;
  31 class OopClosure;
  32 class OopStack;
  33 class ObjectStartArray;
  34 class ParallelTaskTerminator;
  35 class MutableSpace;
  36 class PSOldGen;
  37 class Thread;
  38 class VMThread;
  39 
  40 //
  41 // ScavengeRootsTask
  42 //
  43 // This task scans all the roots of a given type.
  44 //
  45 //
  46 
  47 class ScavengeRootsTask : public GCTask {
  48  public:
  49   enum RootType {
  50     universe              = 1,
  51     jni_handles           = 2,
  52     threads               = 3,
  53     object_synchronizer   = 4,
  54     flat_profiler         = 5,
  55     system_dictionary     = 6,
  56     management            = 7,
  57     jvmti                 = 8,
  58     code_cache            = 9
  59   };
  60  private:
  61   RootType _root_type;
  62  public:
  63   ScavengeRootsTask(RootType value) : _root_type(value) {}
  64 
  65   char* name() { return (char *)"scavenge-roots-task"; }
  66 
  67   virtual void do_it(GCTaskManager* manager, uint which);
  68 };
  69 
  70 //
  71 // ThreadRootsTask
  72 //
  73 // This task scans the roots of a single thread. This task
  74 // enables scanning of thread roots in parallel.
  75 //
  76 
  77 class ThreadRootsTask : public GCTask {
  78  private:
  79   JavaThread* _java_thread;
  80   VMThread* _vm_thread;
  81  public:
  82   ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
  83   ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
  84 
  85   char* name() { return (char *)"thread-roots-task"; }
  86 
  87   virtual void do_it(GCTaskManager* manager, uint which);
  88 };
  89 
  90 //
  91 // StealTask
  92 //
  93 // This task is used to distribute work to idle threads.
  94 //
  95 
  96 class StealTask : public GCTask {
  97  private:
  98    ParallelTaskTerminator* const _terminator;
  99  public:
 100   char* name() { return (char *)"steal-task"; }
 101 
 102   StealTask(ParallelTaskTerminator* t);
 103 
 104   ParallelTaskTerminator* terminator() { return _terminator; }
 105 
 106   virtual void do_it(GCTaskManager* manager, uint which);
 107 };
 108 
 109 //
 110 // SerialOldToYoungRootsTask
 111 //
 112 // This task is used to scan for roots in the perm gen
 113 
 114 class SerialOldToYoungRootsTask : public GCTask {
 115  private:
 116   PSOldGen* _gen;
 117   HeapWord* _gen_top;
 118 
 119  public:
 120   SerialOldToYoungRootsTask(PSOldGen *gen, HeapWord* gen_top) :
 121     _gen(gen), _gen_top(gen_top) { }
 122 
 123   char* name() { return (char *)"serial-old-to-young-roots-task"; }
 124 
 125   virtual void do_it(GCTaskManager* manager, uint which);
 126 };
 127 
 128 //
 129 // OldToYoungRootsTask
 130 //
 131 // This task is used to scan old to young roots in parallel
 132 
 133 class OldToYoungRootsTask : public GCTask {
 134  private:
 135   PSOldGen* _gen;
 136   HeapWord* _gen_top;
 137   uint _stripe_number;
 138 
 139  public:
 140   OldToYoungRootsTask(PSOldGen *gen, HeapWord* gen_top, uint stripe_number) :
 141     _gen(gen), _gen_top(gen_top), _stripe_number(stripe_number) { }
 142 
 143   char* name() { return (char *)"old-to-young-roots-task"; }
 144 
 145   virtual void do_it(GCTaskManager* manager, uint which);
 146 };