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

Fri, 10 May 2013 08:27:30 -0700

author
minqi
date
Fri, 10 May 2013 08:27:30 -0700
changeset 5097
92ef81e2f571
parent 4128
f81a7c0c618d
child 5194
eda078b01c65
permissions
-rw-r--r--

8003557: NPG: Klass* const k should be const Klass* k.
Summary: With NPG, const KlassOop klass which is in fact a definition converted to Klass* const, which is not the original intention. The right usage is converting them to const Klass*.
Reviewed-by: coleenp, kvn
Contributed-by: yumin.qi@oracle.com

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "utilities/growableArray.hpp"
stefank@2314 30
duke@435 31 //
duke@435 32 // psTasks.hpp is a collection of GCTasks used by the
duke@435 33 // parallelScavenge collector.
duke@435 34 //
duke@435 35
duke@435 36 class GCTask;
duke@435 37 class OopClosure;
duke@435 38 class OopStack;
duke@435 39 class ObjectStartArray;
duke@435 40 class ParallelTaskTerminator;
duke@435 41 class MutableSpace;
duke@435 42 class PSOldGen;
duke@435 43 class Thread;
duke@435 44 class VMThread;
duke@435 45
duke@435 46 //
duke@435 47 // ScavengeRootsTask
duke@435 48 //
duke@435 49 // This task scans all the roots of a given type.
duke@435 50 //
duke@435 51 //
duke@435 52
duke@435 53 class ScavengeRootsTask : public GCTask {
duke@435 54 public:
duke@435 55 enum RootType {
duke@435 56 universe = 1,
duke@435 57 jni_handles = 2,
duke@435 58 threads = 3,
duke@435 59 object_synchronizer = 4,
duke@435 60 flat_profiler = 5,
duke@435 61 system_dictionary = 6,
duke@435 62 management = 7,
jrose@1424 63 jvmti = 8,
jrose@1424 64 code_cache = 9
duke@435 65 };
duke@435 66 private:
duke@435 67 RootType _root_type;
duke@435 68 public:
duke@435 69 ScavengeRootsTask(RootType value) : _root_type(value) {}
duke@435 70
duke@435 71 char* name() { return (char *)"scavenge-roots-task"; }
duke@435 72
duke@435 73 virtual void do_it(GCTaskManager* manager, uint which);
duke@435 74 };
duke@435 75
duke@435 76 //
duke@435 77 // ThreadRootsTask
duke@435 78 //
duke@435 79 // This task scans the roots of a single thread. This task
duke@435 80 // enables scanning of thread roots in parallel.
duke@435 81 //
duke@435 82
duke@435 83 class ThreadRootsTask : public GCTask {
duke@435 84 private:
duke@435 85 JavaThread* _java_thread;
duke@435 86 VMThread* _vm_thread;
duke@435 87 public:
duke@435 88 ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
duke@435 89 ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
duke@435 90
duke@435 91 char* name() { return (char *)"thread-roots-task"; }
duke@435 92
duke@435 93 virtual void do_it(GCTaskManager* manager, uint which);
duke@435 94 };
duke@435 95
duke@435 96 //
duke@435 97 // StealTask
duke@435 98 //
duke@435 99 // This task is used to distribute work to idle threads.
duke@435 100 //
duke@435 101
duke@435 102 class StealTask : public GCTask {
duke@435 103 private:
duke@435 104 ParallelTaskTerminator* const _terminator;
duke@435 105 public:
duke@435 106 char* name() { return (char *)"steal-task"; }
duke@435 107
duke@435 108 StealTask(ParallelTaskTerminator* t);
duke@435 109
duke@435 110 ParallelTaskTerminator* terminator() { return _terminator; }
duke@435 111
duke@435 112 virtual void do_it(GCTaskManager* manager, uint which);
duke@435 113 };
duke@435 114
duke@435 115 //
duke@435 116 // OldToYoungRootsTask
duke@435 117 //
duke@435 118 // This task is used to scan old to young roots in parallel
jmasa@3294 119 //
jmasa@3294 120 // A GC thread executing this tasks divides the generation (old gen)
jmasa@3294 121 // into slices and takes a stripe in the slice as its part of the
jmasa@3294 122 // work.
jmasa@3294 123 //
jmasa@3294 124 // +===============+ slice 0
jmasa@3294 125 // | stripe 0 |
jmasa@3294 126 // +---------------+
jmasa@3294 127 // | stripe 1 |
jmasa@3294 128 // +---------------+
jmasa@3294 129 // | stripe 2 |
jmasa@3294 130 // +---------------+
jmasa@3294 131 // | stripe 3 |
jmasa@3294 132 // +===============+ slice 1
jmasa@3294 133 // | stripe 0 |
jmasa@3294 134 // +---------------+
jmasa@3294 135 // | stripe 1 |
jmasa@3294 136 // +---------------+
jmasa@3294 137 // | stripe 2 |
jmasa@3294 138 // +---------------+
jmasa@3294 139 // | stripe 3 |
jmasa@3294 140 // +===============+ slice 2
jmasa@3294 141 // ...
jmasa@3294 142 //
jmasa@3294 143 // A task is created for each stripe. In this case there are 4 tasks
jmasa@3294 144 // created. A GC thread first works on its stripe within slice 0
jmasa@3294 145 // and then moves to its stripe in the next slice until all stripes
jmasa@3294 146 // exceed the top of the generation. Note that having fewer GC threads
jmasa@3294 147 // than stripes works because all the tasks are executed so all stripes
jmasa@3294 148 // will be covered. In this example if 4 tasks have been created to cover
jmasa@3294 149 // all the stripes and there are only 3 threads, one of the threads will
jmasa@3294 150 // get the tasks with the 4th stripe. However, there is a dependence in
jmasa@3294 151 // CardTableExtension::scavenge_contents_parallel() on the number
jmasa@3294 152 // of tasks created. In scavenge_contents_parallel the distance
jmasa@3294 153 // to the next stripe is calculated based on the number of tasks.
jmasa@3294 154 // If the stripe width is ssize, a task's next stripe is at
jmasa@3294 155 // ssize * number_of_tasks (= slice_stride). In this case after
jmasa@3294 156 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
jmasa@3294 157 // by adding slice_stride to the start of stripe 0 in slice 0 to get
jmasa@3294 158 // to the start of stride 0 in slice 1.
duke@435 159
duke@435 160 class OldToYoungRootsTask : public GCTask {
duke@435 161 private:
duke@435 162 PSOldGen* _gen;
duke@435 163 HeapWord* _gen_top;
duke@435 164 uint _stripe_number;
jmasa@3294 165 uint _stripe_total;
duke@435 166
duke@435 167 public:
jmasa@3294 168 OldToYoungRootsTask(PSOldGen *gen,
jmasa@3294 169 HeapWord* gen_top,
jmasa@3294 170 uint stripe_number,
jmasa@3294 171 uint stripe_total) :
jmasa@3294 172 _gen(gen),
jmasa@3294 173 _gen_top(gen_top),
jmasa@3294 174 _stripe_number(stripe_number),
jmasa@3294 175 _stripe_total(stripe_total) { }
duke@435 176
duke@435 177 char* name() { return (char *)"old-to-young-roots-task"; }
duke@435 178
duke@435 179 virtual void do_it(GCTaskManager* manager, uint which);
duke@435 180 };
stefank@2314 181
stefank@2314 182 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP

mercurial