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