author | kvn |
Thu, 27 May 2010 18:01:56 -0700 | |
changeset 5694 | 1e0532a6abff |
parent 5076 | 8b74a4b60b31 |
child 5547 | f4b087cbb361 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
3795 | 2 |
* Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. |
1 | 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 |
# include "incls/_precompiled.incl" |
|
26 |
# include "incls/_pcTasks.cpp.incl" |
|
27 |
||
28 |
// |
|
29 |
// ThreadRootsMarkingTask |
|
30 |
// |
|
31 |
||
32 |
void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) { |
|
33 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
34 |
||
35 |
ResourceMark rm; |
|
36 |
||
37 |
NOT_PRODUCT(TraceTime tm("ThreadRootsMarkingTask", |
|
38 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
|
39 |
ParCompactionManager* cm = |
|
40 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
41 |
PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
42 |
CodeBlobToOopClosure mark_and_push_in_blobs(&mark_and_push_closure, /*do_marking=*/ true); |
1 | 43 |
|
44 |
if (_java_thread != NULL) |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
45 |
_java_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
1 | 46 |
|
47 |
if (_vm_thread != NULL) |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
48 |
_vm_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
1 | 49 |
|
50 |
// Do the real work |
|
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
51 |
cm->follow_marking_stacks(); |
1 | 52 |
} |
53 |
||
54 |
||
55 |
void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { |
|
56 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
57 |
||
58 |
NOT_PRODUCT(TraceTime tm("MarkFromRootsTask", |
|
59 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
|
60 |
ParCompactionManager* cm = |
|
61 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
62 |
assert(cm->stacks_have_been_allocated(), |
|
3696 | 63 |
"Stack space has not been allocated"); |
1 | 64 |
PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); |
65 |
||
66 |
switch (_root_type) { |
|
67 |
case universe: |
|
68 |
Universe::oops_do(&mark_and_push_closure); |
|
69 |
break; |
|
70 |
||
71 |
case reference_processing: |
|
72 |
ReferenceProcessor::oops_do(&mark_and_push_closure); |
|
73 |
break; |
|
74 |
||
75 |
case jni_handles: |
|
76 |
JNIHandles::oops_do(&mark_and_push_closure); |
|
77 |
break; |
|
78 |
||
79 |
case threads: |
|
80 |
{ |
|
81 |
ResourceMark rm; |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
82 |
CodeBlobToOopClosure each_active_code_blob(&mark_and_push_closure, /*do_marking=*/ true); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
83 |
Threads::oops_do(&mark_and_push_closure, &each_active_code_blob); |
1 | 84 |
} |
85 |
break; |
|
86 |
||
87 |
case object_synchronizer: |
|
88 |
ObjectSynchronizer::oops_do(&mark_and_push_closure); |
|
89 |
break; |
|
90 |
||
91 |
case flat_profiler: |
|
92 |
FlatProfiler::oops_do(&mark_and_push_closure); |
|
93 |
break; |
|
94 |
||
95 |
case management: |
|
96 |
Management::oops_do(&mark_and_push_closure); |
|
97 |
break; |
|
98 |
||
99 |
case jvmti: |
|
100 |
JvmtiExport::oops_do(&mark_and_push_closure); |
|
101 |
break; |
|
102 |
||
103 |
case system_dictionary: |
|
104 |
SystemDictionary::always_strong_oops_do(&mark_and_push_closure); |
|
105 |
break; |
|
106 |
||
107 |
case vm_symbols: |
|
108 |
vmSymbols::oops_do(&mark_and_push_closure); |
|
109 |
break; |
|
110 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
111 |
case code_cache: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
112 |
// Do not treat nmethods as strong roots for mark/sweep, since we can unload them. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
113 |
//CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure)); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
114 |
break; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
115 |
|
1 | 116 |
default: |
117 |
fatal("Unknown root type"); |
|
118 |
} |
|
119 |
||
120 |
// Do the real work |
|
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
121 |
cm->follow_marking_stacks(); |
1 | 122 |
// cm->deallocate_stacks(); |
123 |
} |
|
124 |
||
125 |
||
126 |
// |
|
127 |
// RefProcTaskProxy |
|
128 |
// |
|
129 |
||
130 |
void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which) |
|
131 |
{ |
|
132 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
133 |
||
134 |
NOT_PRODUCT(TraceTime tm("RefProcTask", |
|
135 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
|
136 |
ParCompactionManager* cm = |
|
137 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
138 |
assert(cm->stacks_have_been_allocated(), |
|
3696 | 139 |
"Stack space has not been allocated"); |
1 | 140 |
PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); |
141 |
PSParallelCompact::FollowStackClosure follow_stack_closure(cm); |
|
142 |
_rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(), |
|
143 |
mark_and_push_closure, follow_stack_closure); |
|
144 |
} |
|
145 |
||
146 |
// |
|
147 |
// RefProcTaskExecutor |
|
148 |
// |
|
149 |
||
150 |
void RefProcTaskExecutor::execute(ProcessTask& task) |
|
151 |
{ |
|
152 |
ParallelScavengeHeap* heap = PSParallelCompact::gc_heap(); |
|
153 |
uint parallel_gc_threads = heap->gc_task_manager()->workers(); |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
154 |
RegionTaskQueueSet* qset = ParCompactionManager::region_array(); |
1 | 155 |
ParallelTaskTerminator terminator(parallel_gc_threads, qset); |
156 |
GCTaskQueue* q = GCTaskQueue::create(); |
|
157 |
for(uint i=0; i<parallel_gc_threads; i++) { |
|
158 |
q->enqueue(new RefProcTaskProxy(task, i)); |
|
159 |
} |
|
160 |
if (task.marks_oops_alive()) { |
|
161 |
if (parallel_gc_threads>1) { |
|
162 |
for (uint j=0; j<parallel_gc_threads; j++) { |
|
163 |
q->enqueue(new StealMarkingTask(&terminator)); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
PSParallelCompact::gc_task_manager()->execute_and_wait(q); |
|
168 |
} |
|
169 |
||
170 |
void RefProcTaskExecutor::execute(EnqueueTask& task) |
|
171 |
{ |
|
172 |
ParallelScavengeHeap* heap = PSParallelCompact::gc_heap(); |
|
173 |
uint parallel_gc_threads = heap->gc_task_manager()->workers(); |
|
174 |
GCTaskQueue* q = GCTaskQueue::create(); |
|
175 |
for(uint i=0; i<parallel_gc_threads; i++) { |
|
176 |
q->enqueue(new RefEnqueueTaskProxy(task, i)); |
|
177 |
} |
|
178 |
PSParallelCompact::gc_task_manager()->execute_and_wait(q); |
|
179 |
} |
|
180 |
||
181 |
// |
|
182 |
// StealMarkingTask |
|
183 |
// |
|
184 |
||
185 |
StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) : |
|
186 |
_terminator(t) {} |
|
187 |
||
188 |
void StealMarkingTask::do_it(GCTaskManager* manager, uint which) { |
|
189 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
190 |
||
191 |
NOT_PRODUCT(TraceTime tm("StealMarkingTask", |
|
192 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
|
193 |
||
194 |
ParCompactionManager* cm = |
|
195 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
196 |
PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); |
|
197 |
||
198 |
oop obj = NULL; |
|
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
199 |
ObjArrayTask task; |
1 | 200 |
int random_seed = 17; |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
201 |
do { |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
202 |
while (ParCompactionManager::steal_objarray(which, &random_seed, task)) { |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
203 |
objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint(); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
204 |
k->oop_follow_contents(cm, task.obj(), task.index()); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
205 |
cm->follow_marking_stacks(); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
206 |
} |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
207 |
while (ParCompactionManager::steal(which, &random_seed, obj)) { |
1 | 208 |
obj->follow_contents(cm); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
209 |
cm->follow_marking_stacks(); |
1 | 210 |
} |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
211 |
} while (!terminator()->offer_termination()); |
1 | 212 |
} |
213 |
||
214 |
// |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
215 |
// StealRegionCompactionTask |
1 | 216 |
// |
217 |
||
218 |
||
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
219 |
StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t): |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
220 |
_terminator(t) {} |
1 | 221 |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
222 |
void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) { |
1 | 223 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
224 |
||
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
225 |
NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask", |
1 | 226 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
227 |
||
228 |
ParCompactionManager* cm = |
|
229 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
230 |
||
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
231 |
// Has to drain stacks first because there may be regions on |
1 | 232 |
// preloaded onto the stack and this thread may never have |
233 |
// done a draining task. Are the draining tasks needed? |
|
234 |
||
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
235 |
cm->drain_region_stacks(); |
1 | 236 |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
237 |
size_t region_index = 0; |
1 | 238 |
int random_seed = 17; |
239 |
||
240 |
// If we're the termination task, try 10 rounds of stealing before |
|
241 |
// setting the termination flag |
|
242 |
||
243 |
while(true) { |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
244 |
if (ParCompactionManager::steal(which, &random_seed, region_index)) { |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
245 |
PSParallelCompact::fill_and_update_region(cm, region_index); |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
246 |
cm->drain_region_stacks(); |
1 | 247 |
} else { |
248 |
if (terminator()->offer_termination()) { |
|
249 |
break; |
|
250 |
} |
|
251 |
// Go around again. |
|
252 |
} |
|
253 |
} |
|
254 |
return; |
|
255 |
} |
|
256 |
||
257 |
UpdateDensePrefixTask::UpdateDensePrefixTask( |
|
258 |
PSParallelCompact::SpaceId space_id, |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
259 |
size_t region_index_start, |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
260 |
size_t region_index_end) : |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
261 |
_space_id(space_id), _region_index_start(region_index_start), |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
262 |
_region_index_end(region_index_end) {} |
1 | 263 |
|
264 |
void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { |
|
265 |
||
266 |
NOT_PRODUCT(TraceTime tm("UpdateDensePrefixTask", |
|
267 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
|
268 |
||
269 |
ParCompactionManager* cm = |
|
270 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
271 |
||
272 |
PSParallelCompact::update_and_deadwood_in_dense_prefix(cm, |
|
273 |
_space_id, |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
274 |
_region_index_start, |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
275 |
_region_index_end); |
1 | 276 |
} |
277 |
||
278 |
void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) { |
|
279 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
280 |
||
281 |
NOT_PRODUCT(TraceTime tm("DrainStacksCompactionTask", |
|
282 |
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
|
283 |
||
284 |
ParCompactionManager* cm = |
|
285 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
286 |
||
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
287 |
// Process any regions already in the compaction managers stacks. |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
288 |
cm->drain_region_stacks(); |
1 | 289 |
} |