Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp @ 5964:21595f05bc93
7146246: G1: expose some of the -XX flags that drive which old regions to collect during mixed GCs
Summary: Make two G1 cmd line flags available in product builds: G1HeapWastePercent (previously called: G1OldReclaimableThresholdPercent) and G1MixedGCCountTarget (previous called: G1MaxMixedGCNum). Also changed the default of the former from 1% to 5% and the default for G1OldCSetRegionLiveThresholdPercent to 90%.
Reviewed-by: azeemj, jwilhelm, johnc
author | tonyp |
---|---|
date | Fri, 23 Mar 2012 10:53:19 -0400 |
parents | bca17e38de00 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2177
diff
changeset
|
2 * Copyright (c) 2005, 2011, 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 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "code/codeCache.hpp" | |
28 #include "gc_implementation/parallelScavenge/pcTasks.hpp" | |
29 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" | |
30 #include "gc_interface/collectedHeap.hpp" | |
31 #include "memory/universe.hpp" | |
32 #include "oops/objArrayKlass.inline.hpp" | |
33 #include "oops/oop.inline.hpp" | |
34 #include "oops/oop.pcgc.inline.hpp" | |
35 #include "prims/jvmtiExport.hpp" | |
36 #include "runtime/fprofiler.hpp" | |
37 #include "runtime/jniHandles.hpp" | |
38 #include "runtime/thread.hpp" | |
39 #include "runtime/vmThread.hpp" | |
40 #include "services/management.hpp" | |
0 | 41 |
42 // | |
43 // ThreadRootsMarkingTask | |
44 // | |
45 | |
46 void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) { | |
47 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
48 | |
49 ResourceMark rm; | |
50 | |
51 NOT_PRODUCT(TraceTime tm("ThreadRootsMarkingTask", | |
52 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); | |
53 ParCompactionManager* cm = | |
54 ParCompactionManager::gc_thread_compaction_manager(which); | |
55 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
|
56 CodeBlobToOopClosure mark_and_push_in_blobs(&mark_and_push_closure, /*do_marking=*/ true); |
0 | 57 |
58 if (_java_thread != NULL) | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
59 _java_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
0 | 60 |
61 if (_vm_thread != NULL) | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
62 _vm_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
0 | 63 |
64 // Do the real work | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
65 cm->follow_marking_stacks(); |
0 | 66 } |
67 | |
68 | |
69 void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { | |
70 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
71 | |
72 NOT_PRODUCT(TraceTime tm("MarkFromRootsTask", | |
73 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); | |
74 ParCompactionManager* cm = | |
75 ParCompactionManager::gc_thread_compaction_manager(which); | |
76 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); | |
77 | |
78 switch (_root_type) { | |
79 case universe: | |
80 Universe::oops_do(&mark_and_push_closure); | |
81 break; | |
82 | |
83 case jni_handles: | |
84 JNIHandles::oops_do(&mark_and_push_closure); | |
85 break; | |
86 | |
87 case threads: | |
88 { | |
89 ResourceMark rm; | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
90 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
|
91 Threads::oops_do(&mark_and_push_closure, &each_active_code_blob); |
0 | 92 } |
93 break; | |
94 | |
95 case object_synchronizer: | |
96 ObjectSynchronizer::oops_do(&mark_and_push_closure); | |
97 break; | |
98 | |
99 case flat_profiler: | |
100 FlatProfiler::oops_do(&mark_and_push_closure); | |
101 break; | |
102 | |
103 case management: | |
104 Management::oops_do(&mark_and_push_closure); | |
105 break; | |
106 | |
107 case jvmti: | |
108 JvmtiExport::oops_do(&mark_and_push_closure); | |
109 break; | |
110 | |
111 case system_dictionary: | |
112 SystemDictionary::always_strong_oops_do(&mark_and_push_closure); | |
113 break; | |
114 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
115 case code_cache: |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
116 // 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
|
117 //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
|
118 break; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
375
diff
changeset
|
119 |
0 | 120 default: |
121 fatal("Unknown root type"); | |
122 } | |
123 | |
124 // Do the real work | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
125 cm->follow_marking_stacks(); |
0 | 126 } |
127 | |
128 | |
129 // | |
130 // RefProcTaskProxy | |
131 // | |
132 | |
133 void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which) | |
134 { | |
135 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
136 | |
137 NOT_PRODUCT(TraceTime tm("RefProcTask", | |
138 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); | |
139 ParCompactionManager* cm = | |
140 ParCompactionManager::gc_thread_compaction_manager(which); | |
141 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); | |
142 PSParallelCompact::FollowStackClosure follow_stack_closure(cm); | |
143 _rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(), | |
144 mark_and_push_closure, follow_stack_closure); | |
145 } | |
146 | |
147 // | |
148 // RefProcTaskExecutor | |
149 // | |
150 | |
151 void RefProcTaskExecutor::execute(ProcessTask& task) | |
152 { | |
153 ParallelScavengeHeap* heap = PSParallelCompact::gc_heap(); | |
154 uint parallel_gc_threads = heap->gc_task_manager()->workers(); | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
155 uint active_gc_threads = heap->gc_task_manager()->active_workers(); |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
156 RegionTaskQueueSet* qset = ParCompactionManager::region_array(); |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
157 ParallelTaskTerminator terminator(active_gc_threads, qset); |
0 | 158 GCTaskQueue* q = GCTaskQueue::create(); |
159 for(uint i=0; i<parallel_gc_threads; i++) { | |
160 q->enqueue(new RefProcTaskProxy(task, i)); | |
161 } | |
162 if (task.marks_oops_alive()) { | |
163 if (parallel_gc_threads>1) { | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
164 for (uint j=0; j<active_gc_threads; j++) { |
0 | 165 q->enqueue(new StealMarkingTask(&terminator)); |
166 } | |
167 } | |
168 } | |
169 PSParallelCompact::gc_task_manager()->execute_and_wait(q); | |
170 } | |
171 | |
172 void RefProcTaskExecutor::execute(EnqueueTask& task) | |
173 { | |
174 ParallelScavengeHeap* heap = PSParallelCompact::gc_heap(); | |
175 uint parallel_gc_threads = heap->gc_task_manager()->workers(); | |
176 GCTaskQueue* q = GCTaskQueue::create(); | |
177 for(uint i=0; i<parallel_gc_threads; i++) { | |
178 q->enqueue(new RefEnqueueTaskProxy(task, i)); | |
179 } | |
180 PSParallelCompact::gc_task_manager()->execute_and_wait(q); | |
181 } | |
182 | |
183 // | |
184 // StealMarkingTask | |
185 // | |
186 | |
187 StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) : | |
188 _terminator(t) {} | |
189 | |
190 void StealMarkingTask::do_it(GCTaskManager* manager, uint which) { | |
191 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
192 | |
193 NOT_PRODUCT(TraceTime tm("StealMarkingTask", | |
194 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); | |
195 | |
196 ParCompactionManager* cm = | |
197 ParCompactionManager::gc_thread_compaction_manager(which); | |
198 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); | |
199 | |
200 oop obj = NULL; | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
201 ObjArrayTask task; |
0 | 202 int random_seed = 17; |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
203 do { |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
204 while (ParCompactionManager::steal_objarray(which, &random_seed, task)) { |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
205 objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
206 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
|
207 cm->follow_marking_stacks(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
208 } |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
209 while (ParCompactionManager::steal(which, &random_seed, obj)) { |
0 | 210 obj->follow_contents(cm); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
211 cm->follow_marking_stacks(); |
0 | 212 } |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
213 } while (!terminator()->offer_termination()); |
0 | 214 } |
215 | |
216 // | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
217 // StealRegionCompactionTask |
0 | 218 // |
219 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
220 StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t): |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
221 _terminator(t) {} |
0 | 222 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
223 void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) { |
0 | 224 assert(Universe::heap()->is_gc_active(), "called outside gc"); |
225 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
226 NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask", |
0 | 227 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); |
228 | |
229 ParCompactionManager* cm = | |
230 ParCompactionManager::gc_thread_compaction_manager(which); | |
231 | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
232 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
233 // If not all threads are active, get a draining stack |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
234 // from the list. Else, just use this threads draining stack. |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
235 uint which_stack_index; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
236 bool use_all_workers = manager->all_workers_active(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
237 if (use_all_workers) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
238 which_stack_index = which; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
239 assert(manager->active_workers() == ParallelGCThreads, |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
240 err_msg("all_workers_active has been incorrectly set: " |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
241 " active %d ParallelGCThreads %d", manager->active_workers(), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
242 ParallelGCThreads)); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
243 } else { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
244 which_stack_index = ParCompactionManager::pop_recycled_stack_index(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
245 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
246 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
247 cm->set_region_stack_index(which_stack_index); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
248 cm->set_region_stack(ParCompactionManager::region_list(which_stack_index)); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
249 if (TraceDynamicGCThreads) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
250 gclog_or_tty->print_cr("StealRegionCompactionTask::do_it " |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
251 "region_stack_index %d region_stack = 0x%x " |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
252 " empty (%d) use all workers %d", |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
253 which_stack_index, ParCompactionManager::region_list(which_stack_index), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
254 cm->region_stack()->is_empty(), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
255 use_all_workers); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
256 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
257 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
258 // Has to drain stacks first because there may be regions on |
0 | 259 // preloaded onto the stack and this thread may never have |
260 // done a draining task. Are the draining tasks needed? | |
261 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
262 cm->drain_region_stacks(); |
0 | 263 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
264 size_t region_index = 0; |
0 | 265 int random_seed = 17; |
266 | |
267 // If we're the termination task, try 10 rounds of stealing before | |
268 // setting the termination flag | |
269 | |
270 while(true) { | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
271 if (ParCompactionManager::steal(which, &random_seed, region_index)) { |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
272 PSParallelCompact::fill_and_update_region(cm, region_index); |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
273 cm->drain_region_stacks(); |
0 | 274 } else { |
275 if (terminator()->offer_termination()) { | |
276 break; | |
277 } | |
278 // Go around again. | |
279 } | |
280 } | |
281 return; | |
282 } | |
283 | |
284 UpdateDensePrefixTask::UpdateDensePrefixTask( | |
285 PSParallelCompact::SpaceId space_id, | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
286 size_t region_index_start, |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
287 size_t region_index_end) : |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
288 _space_id(space_id), _region_index_start(region_index_start), |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
289 _region_index_end(region_index_end) {} |
0 | 290 |
291 void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { | |
292 | |
293 NOT_PRODUCT(TraceTime tm("UpdateDensePrefixTask", | |
294 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); | |
295 | |
296 ParCompactionManager* cm = | |
297 ParCompactionManager::gc_thread_compaction_manager(which); | |
298 | |
299 PSParallelCompact::update_and_deadwood_in_dense_prefix(cm, | |
300 _space_id, | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
301 _region_index_start, |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
302 _region_index_end); |
0 | 303 } |
304 | |
305 void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) { | |
306 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
307 | |
308 NOT_PRODUCT(TraceTime tm("DrainStacksCompactionTask", | |
309 PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); | |
310 | |
311 ParCompactionManager* cm = | |
312 ParCompactionManager::gc_thread_compaction_manager(which); | |
313 | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
314 uint which_stack_index; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
315 bool use_all_workers = manager->all_workers_active(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
316 if (use_all_workers) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
317 which_stack_index = which; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
318 assert(manager->active_workers() == ParallelGCThreads, |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
319 err_msg("all_workers_active has been incorrectly set: " |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
320 " active %d ParallelGCThreads %d", manager->active_workers(), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
321 ParallelGCThreads)); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
322 } else { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
323 which_stack_index = stack_index(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
324 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
325 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
326 cm->set_region_stack(ParCompactionManager::region_list(which_stack_index)); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
327 if (TraceDynamicGCThreads) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
328 gclog_or_tty->print_cr("DrainStacksCompactionTask::do_it which = %d " |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
329 "which_stack_index = %d/empty(%d) " |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
330 "use all workers %d", |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
331 which, which_stack_index, |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
332 cm->region_stack()->is_empty(), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
333 use_all_workers); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
334 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
335 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
336 cm->set_region_stack_index(which_stack_index); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
337 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
338 // Process any regions already in the compaction managers stacks. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
196
diff
changeset
|
339 cm->drain_region_stacks(); |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
340 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
341 assert(cm->region_stack()->is_empty(), "Not empty"); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
342 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
343 if (!use_all_workers) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
344 // Always give up the region stack. |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
345 assert(cm->region_stack() == |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
346 ParCompactionManager::region_list(cm->region_stack_index()), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
347 "region_stack and region_stack_index are inconsistent"); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
348 ParCompactionManager::push_recycled_stack_index(cm->region_stack_index()); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
349 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
350 if (TraceDynamicGCThreads) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
351 void* old_region_stack = (void*) cm->region_stack(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
352 int old_region_stack_index = cm->region_stack_index(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
353 gclog_or_tty->print_cr("Pushing region stack 0x%x/%d", |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
354 old_region_stack, old_region_stack_index); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
355 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
356 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
357 cm->set_region_stack(NULL); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
358 cm->set_region_stack_index((uint)max_uintx); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
359 } |
0 | 360 } |