Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp @ 1562:dfe27f03244a
Merge
author | trims |
---|---|
date | Tue, 01 Jun 2010 11:48:33 -0700 |
parents | c18cbe5936b8 |
children | 894b1d7c7e01 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1311
diff
changeset
|
2 * Copyright (c) 2005, 2009, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1311
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1311
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1311
diff
changeset
|
21 * questions. |
0 | 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); | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
42 CodeBlobToOopClosure mark_and_push_in_blobs(&mark_and_push_closure, /*do_marking=*/ true); |
0 | 43 |
44 if (_java_thread != NULL) | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
45 _java_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
0 | 46 |
47 if (_vm_thread != NULL) | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
48 _vm_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
0 | 49 |
50 // Do the real work | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
51 cm->follow_marking_stacks(); |
0 | 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(), | |
941 | 63 "Stack space has not been allocated"); |
0 | 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; | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
82 CodeBlobToOopClosure each_active_code_blob(&mark_and_push_closure, /*do_marking=*/ true); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
83 Threads::oops_do(&mark_and_push_closure, &each_active_code_blob); |
0 | 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 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
111 case code_cache: |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
112 // Do not treat nmethods as strong roots for mark/sweep, since we can unload them. |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
113 //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure)); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
114 break; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
115 |
0 | 116 default: |
117 fatal("Unknown root type"); | |
118 } | |
119 | |
120 // Do the real work | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
121 cm->follow_marking_stacks(); |
0 | 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(), | |
941 | 139 "Stack space has not been allocated"); |
0 | 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(); | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
154 RegionTaskQueueSet* qset = ParCompactionManager::region_array(); |
0 | 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; | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
199 ObjArrayTask task; |
0 | 200 int random_seed = 17; |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
201 do { |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
202 while (ParCompactionManager::steal_objarray(which, &random_seed, task)) { |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
203 objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
204 k->oop_follow_contents(cm, task.obj(), task.index()); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
205 cm->follow_marking_stacks(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
206 } |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
207 while (ParCompactionManager::steal(which, &random_seed, obj)) { |
0 | 208 obj->follow_contents(cm); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
209 cm->follow_marking_stacks(); |
0 | 210 } |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
211 } while (!terminator()->offer_termination()); |
0 | 212 } |
213 | |
214 // | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
215 // StealRegionCompactionTask |
0 | 216 // |
217 | |
218 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
219 StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t): |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
220 _terminator(t) {} |
0 | 221 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
222 void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) { |
0 | 223 assert(Universe::heap()->is_gc_active(), "called outside gc"); |
224 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
225 NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask", |
0 | 226 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
227 | |
228 ParCompactionManager* cm = | |
229 ParCompactionManager::gc_thread_compaction_manager(which); | |
230 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
231 // Has to drain stacks first because there may be regions on |
0 | 232 // preloaded onto the stack and this thread may never have |
233 // done a draining task. Are the draining tasks needed? | |
234 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
235 cm->drain_region_stacks(); |
0 | 236 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
237 size_t region_index = 0; |
0 | 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) { | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
244 if (ParCompactionManager::steal(which, &random_seed, region_index)) { |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
245 PSParallelCompact::fill_and_update_region(cm, region_index); |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
246 cm->drain_region_stacks(); |
0 | 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, | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
259 size_t region_index_start, |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
260 size_t region_index_end) : |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
261 _space_id(space_id), _region_index_start(region_index_start), |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
262 _region_index_end(region_index_end) {} |
0 | 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, | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
274 _region_index_start, |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
275 _region_index_end); |
0 | 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 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
287 // Process any regions already in the compaction managers stacks. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
288 cm->drain_region_stacks(); |
0 | 289 } |