23 */
24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/g1/g1BarrierSet.hpp"
31 #include "gc/g1/g1CodeBlobClosure.hpp"
32 #include "gc/g1/g1CollectedHeap.inline.hpp"
33 #include "gc/g1/g1CollectorState.hpp"
34 #include "gc/g1/g1GCParPhaseTimesTracker.hpp"
35 #include "gc/g1/g1GCPhaseTimes.hpp"
36 #include "gc/g1/g1ParScanThreadState.inline.hpp"
37 #include "gc/g1/g1Policy.hpp"
38 #include "gc/g1/g1RootClosures.hpp"
39 #include "gc/g1/g1RootProcessor.hpp"
40 #include "gc/g1/heapRegion.inline.hpp"
41 #include "gc/shared/oopStorage.inline.hpp"
42 #include "gc/shared/oopStorageSet.hpp"
43 #include "gc/shared/referenceProcessor.hpp"
44 #include "memory/allocation.inline.hpp"
45 #include "memory/universe.hpp"
46 #include "runtime/mutex.hpp"
47 #include "services/management.hpp"
48 #include "utilities/macros.hpp"
49
50 G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h, uint n_workers) :
51 _g1h(g1h),
52 _process_strong_tasks(G1RP_PS_NumElements),
53 _srs(n_workers) {}
54
55 void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_id) {
56 G1GCPhaseTimes* phase_times = _g1h->phase_times();
57
58 G1EvacPhaseTimesTracker timer(phase_times, pss, G1GCPhaseTimes::ExtRootScan, worker_id);
59
60 G1EvacuationRootClosures* closures = pss->closures();
61 process_java_roots(closures, phase_times, worker_id);
62
172 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_id);
173 if (_process_strong_tasks.try_claim_task(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
174 ClassLoaderDataGraph::roots_cld_do(closures->strong_clds(), closures->weak_clds());
175 }
176 }
177 }
178
179 void G1RootProcessor::process_vm_roots(G1RootClosures* closures,
180 G1GCPhaseTimes* phase_times,
181 uint worker_id) {
182 OopClosure* strong_roots = closures->strong_oops();
183
184 {
185 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::UniverseRoots, worker_id);
186 if (_process_strong_tasks.try_claim_task(G1RP_PS_Universe_oops_do)) {
187 Universe::oops_do(strong_roots);
188 }
189 }
190
191 {
192 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JNIRoots, worker_id);
193 if (_process_strong_tasks.try_claim_task(G1RP_PS_JNIHandles_oops_do)) {
194 JNIHandles::oops_do(strong_roots);
195 }
196 }
197
198 {
199 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_id);
200 if (_process_strong_tasks.try_claim_task(G1RP_PS_ObjectSynchronizer_oops_do)) {
201 ObjectSynchronizer::oops_do(strong_roots);
202 }
203 }
204
205 {
206 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_id);
207 if (_process_strong_tasks.try_claim_task(G1RP_PS_Management_oops_do)) {
208 Management::oops_do(strong_roots);
209 }
210 }
211
212 {
213 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_id);
214 if (_process_strong_tasks.try_claim_task(G1RP_PS_jvmti_oops_do)) {
215 JvmtiExport::oops_do(strong_roots);
216 }
217 }
218
219 #if INCLUDE_AOT
220 if (UseAOT) {
221 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_id);
222 if (_process_strong_tasks.try_claim_task(G1RP_PS_aot_oops_do)) {
223 AOTLoader::oops_do(strong_roots);
224 }
225 }
226 #endif
227
228 {
229 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::VMGlobalRoots, worker_id);
230 if (_process_strong_tasks.try_claim_task(G1RP_PS_VMGlobal_oops_do)) {
231 OopStorageSet::vm_global()->oops_do(strong_roots);
232 }
233 }
234 }
235
236 void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure,
237 G1GCPhaseTimes* phase_times,
238 uint worker_id) {
239 if (_process_strong_tasks.try_claim_task(G1RP_PS_CodeCache_oops_do)) {
240 CodeCache::blobs_do(code_closure);
241 }
242 }
243
244 uint G1RootProcessor::n_workers() const {
245 return _srs.n_threads();
246 }
|
23 */
24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/g1/g1BarrierSet.hpp"
31 #include "gc/g1/g1CodeBlobClosure.hpp"
32 #include "gc/g1/g1CollectedHeap.inline.hpp"
33 #include "gc/g1/g1CollectorState.hpp"
34 #include "gc/g1/g1GCParPhaseTimesTracker.hpp"
35 #include "gc/g1/g1GCPhaseTimes.hpp"
36 #include "gc/g1/g1ParScanThreadState.inline.hpp"
37 #include "gc/g1/g1Policy.hpp"
38 #include "gc/g1/g1RootClosures.hpp"
39 #include "gc/g1/g1RootProcessor.hpp"
40 #include "gc/g1/heapRegion.inline.hpp"
41 #include "gc/shared/oopStorage.inline.hpp"
42 #include "gc/shared/oopStorageSet.hpp"
43 #include "gc/shared/oopStorageSetParState.inline.hpp"
44 #include "gc/shared/referenceProcessor.hpp"
45 #include "memory/allocation.inline.hpp"
46 #include "memory/universe.hpp"
47 #include "runtime/mutex.hpp"
48 #include "services/management.hpp"
49 #include "utilities/macros.hpp"
50
51 G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h, uint n_workers) :
52 _g1h(g1h),
53 _process_strong_tasks(G1RP_PS_NumElements),
54 _srs(n_workers) {}
55
56 void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_id) {
57 G1GCPhaseTimes* phase_times = _g1h->phase_times();
58
59 G1EvacPhaseTimesTracker timer(phase_times, pss, G1GCPhaseTimes::ExtRootScan, worker_id);
60
61 G1EvacuationRootClosures* closures = pss->closures();
62 process_java_roots(closures, phase_times, worker_id);
63
173 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_id);
174 if (_process_strong_tasks.try_claim_task(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
175 ClassLoaderDataGraph::roots_cld_do(closures->strong_clds(), closures->weak_clds());
176 }
177 }
178 }
179
180 void G1RootProcessor::process_vm_roots(G1RootClosures* closures,
181 G1GCPhaseTimes* phase_times,
182 uint worker_id) {
183 OopClosure* strong_roots = closures->strong_oops();
184
185 {
186 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::UniverseRoots, worker_id);
187 if (_process_strong_tasks.try_claim_task(G1RP_PS_Universe_oops_do)) {
188 Universe::oops_do(strong_roots);
189 }
190 }
191
192 {
193 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_id);
194 if (_process_strong_tasks.try_claim_task(G1RP_PS_ObjectSynchronizer_oops_do)) {
195 ObjectSynchronizer::oops_do(strong_roots);
196 }
197 }
198
199 {
200 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_id);
201 if (_process_strong_tasks.try_claim_task(G1RP_PS_Management_oops_do)) {
202 Management::oops_do(strong_roots);
203 }
204 }
205
206 {
207 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_id);
208 if (_process_strong_tasks.try_claim_task(G1RP_PS_jvmti_oops_do)) {
209 JvmtiExport::oops_do(strong_roots);
210 }
211 }
212
213 #if INCLUDE_AOT
214 if (UseAOT) {
215 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_id);
216 if (_process_strong_tasks.try_claim_task(G1RP_PS_aot_oops_do)) {
217 AOTLoader::oops_do(strong_roots);
218 }
219 }
220 #endif
221
222 for (int i = 0; i < _oop_storage_set_strong_par_state.par_state_count(); ++i) {
223 G1GCPhaseTimes::GCParPhases phase = G1GCPhaseTimes::GCParPhases(G1GCPhaseTimes::StrongOopStorageSetRoots + i);
224 G1GCParPhaseTimesTracker x(phase_times, phase, worker_id);
225 _oop_storage_set_strong_par_state.par_state(i)->oops_do(closures->strong_oops());
226 }
227 }
228
229 void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure,
230 G1GCPhaseTimes* phase_times,
231 uint worker_id) {
232 if (_process_strong_tasks.try_claim_task(G1RP_PS_CodeCache_oops_do)) {
233 CodeCache::blobs_do(code_closure);
234 }
235 }
236
237 uint G1RootProcessor::n_workers() const {
238 return _srs.n_threads();
239 }
|