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

changeset 0
f90c822e73f8
child 1
2d8a650513c2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,183 @@
     1.4 +/*
     1.5 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
    1.29 +#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
    1.30 +
    1.31 +#include "memory/allocation.hpp"
    1.32 +#include "utilities/growableArray.hpp"
    1.33 +
    1.34 +//
    1.35 +// psTasks.hpp is a collection of GCTasks used by the
    1.36 +// parallelScavenge collector.
    1.37 +//
    1.38 +
    1.39 +class GCTask;
    1.40 +class OopClosure;
    1.41 +class OopStack;
    1.42 +class ObjectStartArray;
    1.43 +class ParallelTaskTerminator;
    1.44 +class MutableSpace;
    1.45 +class PSOldGen;
    1.46 +class Thread;
    1.47 +class VMThread;
    1.48 +
    1.49 +//
    1.50 +// ScavengeRootsTask
    1.51 +//
    1.52 +// This task scans all the roots of a given type.
    1.53 +//
    1.54 +//
    1.55 +
    1.56 +class ScavengeRootsTask : public GCTask {
    1.57 + public:
    1.58 +  enum RootType {
    1.59 +    universe              = 1,
    1.60 +    jni_handles           = 2,
    1.61 +    threads               = 3,
    1.62 +    object_synchronizer   = 4,
    1.63 +    flat_profiler         = 5,
    1.64 +    system_dictionary     = 6,
    1.65 +    class_loader_data     = 7,
    1.66 +    management            = 8,
    1.67 +    jvmti                 = 9,
    1.68 +    code_cache            = 10
    1.69 +  };
    1.70 + private:
    1.71 +  RootType _root_type;
    1.72 + public:
    1.73 +  ScavengeRootsTask(RootType value) : _root_type(value) {}
    1.74 +
    1.75 +  char* name() { return (char *)"scavenge-roots-task"; }
    1.76 +
    1.77 +  virtual void do_it(GCTaskManager* manager, uint which);
    1.78 +};
    1.79 +
    1.80 +//
    1.81 +// ThreadRootsTask
    1.82 +//
    1.83 +// This task scans the roots of a single thread. This task
    1.84 +// enables scanning of thread roots in parallel.
    1.85 +//
    1.86 +
    1.87 +class ThreadRootsTask : public GCTask {
    1.88 + private:
    1.89 +  JavaThread* _java_thread;
    1.90 +  VMThread* _vm_thread;
    1.91 + public:
    1.92 +  ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
    1.93 +  ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
    1.94 +
    1.95 +  char* name() { return (char *)"thread-roots-task"; }
    1.96 +
    1.97 +  virtual void do_it(GCTaskManager* manager, uint which);
    1.98 +};
    1.99 +
   1.100 +//
   1.101 +// StealTask
   1.102 +//
   1.103 +// This task is used to distribute work to idle threads.
   1.104 +//
   1.105 +
   1.106 +class StealTask : public GCTask {
   1.107 + private:
   1.108 +   ParallelTaskTerminator* const _terminator;
   1.109 + public:
   1.110 +  char* name() { return (char *)"steal-task"; }
   1.111 +
   1.112 +  StealTask(ParallelTaskTerminator* t);
   1.113 +
   1.114 +  ParallelTaskTerminator* terminator() { return _terminator; }
   1.115 +
   1.116 +  virtual void do_it(GCTaskManager* manager, uint which);
   1.117 +};
   1.118 +
   1.119 +//
   1.120 +// OldToYoungRootsTask
   1.121 +//
   1.122 +// This task is used to scan old to young roots in parallel
   1.123 +//
   1.124 +// A GC thread executing this tasks divides the generation (old gen)
   1.125 +// into slices and takes a stripe in the slice as its part of the
   1.126 +// work.
   1.127 +//
   1.128 +//      +===============+        slice 0
   1.129 +//      |  stripe 0     |
   1.130 +//      +---------------+
   1.131 +//      |  stripe 1     |
   1.132 +//      +---------------+
   1.133 +//      |  stripe 2     |
   1.134 +//      +---------------+
   1.135 +//      |  stripe 3     |
   1.136 +//      +===============+        slice 1
   1.137 +//      |  stripe 0     |
   1.138 +//      +---------------+
   1.139 +//      |  stripe 1     |
   1.140 +//      +---------------+
   1.141 +//      |  stripe 2     |
   1.142 +//      +---------------+
   1.143 +//      |  stripe 3     |
   1.144 +//      +===============+        slice 2
   1.145 +//      ...
   1.146 +//
   1.147 +// A task is created for each stripe.  In this case there are 4 tasks
   1.148 +// created.  A GC thread first works on its stripe within slice 0
   1.149 +// and then moves to its stripe in the next slice until all stripes
   1.150 +// exceed the top of the generation.  Note that having fewer GC threads
   1.151 +// than stripes works because all the tasks are executed so all stripes
   1.152 +// will be covered.  In this example if 4 tasks have been created to cover
   1.153 +// all the stripes and there are only 3 threads, one of the threads will
   1.154 +// get the tasks with the 4th stripe.  However, there is a dependence in
   1.155 +// CardTableExtension::scavenge_contents_parallel() on the number
   1.156 +// of tasks created.  In scavenge_contents_parallel the distance
   1.157 +// to the next stripe is calculated based on the number of tasks.
   1.158 +// If the stripe width is ssize, a task's next stripe is at
   1.159 +// ssize * number_of_tasks (= slice_stride).  In this case after
   1.160 +// finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
   1.161 +// by adding slice_stride to the start of stripe 0 in slice 0 to get
   1.162 +// to the start of stride 0 in slice 1.
   1.163 +
   1.164 +class OldToYoungRootsTask : public GCTask {
   1.165 + private:
   1.166 +  PSOldGen* _gen;
   1.167 +  HeapWord* _gen_top;
   1.168 +  uint _stripe_number;
   1.169 +  uint _stripe_total;
   1.170 +
   1.171 + public:
   1.172 +  OldToYoungRootsTask(PSOldGen *gen,
   1.173 +                      HeapWord* gen_top,
   1.174 +                      uint stripe_number,
   1.175 +                      uint stripe_total) :
   1.176 +    _gen(gen),
   1.177 +    _gen_top(gen_top),
   1.178 +    _stripe_number(stripe_number),
   1.179 +    _stripe_total(stripe_total) { }
   1.180 +
   1.181 +  char* name() { return (char *)"old-to-young-roots-task"; }
   1.182 +
   1.183 +  virtual void do_it(GCTaskManager* manager, uint which);
   1.184 +};
   1.185 +
   1.186 +#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP

mercurial