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

Thu, 11 Dec 2008 12:05:21 -0800

author
jcoomes
date
Thu, 11 Dec 2008 12:05:21 -0800
changeset 918
0f773163217d
parent 810
81cd571500b0
child 905
ad8c8ca4ab0f
permissions
-rw-r--r--

6765954: par compact - stress mode for splitting young gen spaces
Reviewed-by: jmasa

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

mercurial