27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/parallel/parallelScavengeHeap.hpp"
31 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
32 #include "gc/parallel/psClosure.inline.hpp"
33 #include "gc/parallel/psCompactionManager.hpp"
34 #include "gc/parallel/psParallelCompact.inline.hpp"
35 #include "gc/parallel/psPromotionManager.inline.hpp"
36 #include "gc/parallel/psRootType.hpp"
37 #include "gc/parallel/psScavenge.inline.hpp"
38 #include "gc/shared/gcCause.hpp"
39 #include "gc/shared/gcHeapSummary.hpp"
40 #include "gc/shared/gcId.hpp"
41 #include "gc/shared/gcLocker.hpp"
42 #include "gc/shared/gcTimer.hpp"
43 #include "gc/shared/gcTrace.hpp"
44 #include "gc/shared/gcTraceTime.inline.hpp"
45 #include "gc/shared/isGCActiveMark.hpp"
46 #include "gc/shared/oopStorage.inline.hpp"
47 #include "gc/shared/oopStorageSet.hpp"
48 #include "gc/shared/referencePolicy.hpp"
49 #include "gc/shared/referenceProcessor.hpp"
50 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
51 #include "gc/shared/scavengableNMethods.hpp"
52 #include "gc/shared/spaceDecorator.inline.hpp"
53 #include "gc/shared/taskTerminator.hpp"
54 #include "gc/shared/weakProcessor.hpp"
55 #include "gc/shared/workerPolicy.hpp"
56 #include "gc/shared/workgroup.hpp"
57 #include "memory/iterator.hpp"
58 #include "memory/resourceArea.hpp"
59 #include "memory/universe.hpp"
60 #include "logging/log.hpp"
61 #include "oops/access.inline.hpp"
62 #include "oops/compressedOops.inline.hpp"
63 #include "oops/oop.inline.hpp"
64 #include "runtime/biasedLocking.hpp"
65 #include "runtime/handles.inline.hpp"
66 #include "runtime/threadCritical.hpp"
67 #include "runtime/vmThread.hpp"
79 uint PSScavenge::_tenuring_threshold = 0;
80 HeapWord* PSScavenge::_young_generation_boundary = NULL;
81 uintptr_t PSScavenge::_young_generation_boundary_compressed = 0;
82 elapsedTimer PSScavenge::_accumulated_time;
83 STWGCTimer PSScavenge::_gc_timer;
84 ParallelScavengeTracer PSScavenge::_gc_tracer;
85 CollectorCounters* PSScavenge::_counters = NULL;
86
87 static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_id) {
88 assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
89
90 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id);
91 PSScavengeRootsClosure roots_closure(pm);
92 PSPromoteRootsClosure roots_to_old_closure(pm);
93
94 switch (root_type) {
95 case ParallelRootType::universe:
96 Universe::oops_do(&roots_closure);
97 break;
98
99 case ParallelRootType::jni_handles:
100 JNIHandles::oops_do(&roots_closure);
101 break;
102
103 case ParallelRootType::object_synchronizer:
104 ObjectSynchronizer::oops_do(&roots_closure);
105 break;
106
107 case ParallelRootType::vm_global:
108 OopStorageSet::vm_global()->oops_do(&roots_closure);
109 break;
110
111 case ParallelRootType::class_loader_data:
112 {
113 PSScavengeCLDClosure cld_closure(pm);
114 ClassLoaderDataGraph::cld_do(&cld_closure);
115 }
116 break;
117
118 case ParallelRootType::management:
119 Management::oops_do(&roots_closure);
120 break;
121
122 case ParallelRootType::jvmti:
123 JvmtiExport::oops_do(&roots_closure);
124 break;
125
126 case ParallelRootType::code_cache:
127 {
128 MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);
129 ScavengableNMethods::nmethods_do(&code_closure);
130 AOTLoader::oops_do(&roots_closure);
295 class PSThreadRootsTaskClosure : public ThreadClosure {
296 uint _worker_id;
297 public:
298 PSThreadRootsTaskClosure(uint worker_id) : _worker_id(worker_id) { }
299 virtual void do_thread(Thread* thread) {
300 assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
301
302 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(_worker_id);
303 PSScavengeRootsClosure roots_closure(pm);
304 MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations);
305
306 thread->oops_do(&roots_closure, &roots_in_blobs);
307
308 // Do the real work
309 pm->drain_stacks(false);
310 }
311 };
312
313 class ScavengeRootsTask : public AbstractGangTask {
314 StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do
315 SequentialSubTasksDone _subtasks;
316 PSOldGen* _old_gen;
317 HeapWord* _gen_top;
318 uint _active_workers;
319 bool _is_empty;
320 TaskTerminator _terminator;
321
322 public:
323 ScavengeRootsTask(PSOldGen* old_gen,
324 HeapWord* gen_top,
325 uint active_workers,
326 bool is_empty) :
327 AbstractGangTask("ScavengeRootsTask"),
328 _strong_roots_scope(active_workers),
329 _subtasks(),
330 _old_gen(old_gen),
331 _gen_top(gen_top),
332 _active_workers(active_workers),
333 _is_empty(is_empty),
334 _terminator(active_workers, PSPromotionManager::vm_thread_promotion_manager()->stack_array_depth()) {
356 card_table->scavenge_contents_parallel(_old_gen->start_array(),
357 _old_gen->object_space(),
358 _gen_top,
359 pm,
360 worker_id,
361 _active_workers);
362
363 // Do the real work
364 pm->drain_stacks(false);
365 }
366 }
367
368 for (uint root_type = 0; _subtasks.try_claim_task(root_type); /* empty */ ) {
369 scavenge_roots_work(static_cast<ParallelRootType::Value>(root_type), worker_id);
370 }
371 _subtasks.all_tasks_completed();
372
373 PSThreadRootsTaskClosure closure(worker_id);
374 Threads::possibly_parallel_threads_do(true /*parallel */, &closure);
375
376
377 // If active_workers can exceed 1, add a steal_work().
378 // PSPromotionManager::drain_stacks_depth() does not fully drain its
379 // stacks and expects a steal_work() to complete the draining if
380 // ParallelGCThreads is > 1.
381
382 if (_active_workers > 1) {
383 steal_work(_terminator, worker_id);
384 }
385 }
386 };
387
388 // This method contains no policy. You should probably
389 // be calling invoke() instead.
390 bool PSScavenge::invoke_no_policy() {
391 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
392 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
393
394 _gc_timer.register_gc_start();
395
|
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/parallel/parallelScavengeHeap.hpp"
31 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
32 #include "gc/parallel/psClosure.inline.hpp"
33 #include "gc/parallel/psCompactionManager.hpp"
34 #include "gc/parallel/psParallelCompact.inline.hpp"
35 #include "gc/parallel/psPromotionManager.inline.hpp"
36 #include "gc/parallel/psRootType.hpp"
37 #include "gc/parallel/psScavenge.inline.hpp"
38 #include "gc/shared/gcCause.hpp"
39 #include "gc/shared/gcHeapSummary.hpp"
40 #include "gc/shared/gcId.hpp"
41 #include "gc/shared/gcLocker.hpp"
42 #include "gc/shared/gcTimer.hpp"
43 #include "gc/shared/gcTrace.hpp"
44 #include "gc/shared/gcTraceTime.inline.hpp"
45 #include "gc/shared/isGCActiveMark.hpp"
46 #include "gc/shared/oopStorage.inline.hpp"
47 #include "gc/shared/oopStorageSetParState.inline.hpp"
48 #include "gc/shared/oopStorageParState.inline.hpp"
49 #include "gc/shared/referencePolicy.hpp"
50 #include "gc/shared/referenceProcessor.hpp"
51 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
52 #include "gc/shared/scavengableNMethods.hpp"
53 #include "gc/shared/spaceDecorator.inline.hpp"
54 #include "gc/shared/taskTerminator.hpp"
55 #include "gc/shared/weakProcessor.hpp"
56 #include "gc/shared/workerPolicy.hpp"
57 #include "gc/shared/workgroup.hpp"
58 #include "memory/iterator.hpp"
59 #include "memory/resourceArea.hpp"
60 #include "memory/universe.hpp"
61 #include "logging/log.hpp"
62 #include "oops/access.inline.hpp"
63 #include "oops/compressedOops.inline.hpp"
64 #include "oops/oop.inline.hpp"
65 #include "runtime/biasedLocking.hpp"
66 #include "runtime/handles.inline.hpp"
67 #include "runtime/threadCritical.hpp"
68 #include "runtime/vmThread.hpp"
80 uint PSScavenge::_tenuring_threshold = 0;
81 HeapWord* PSScavenge::_young_generation_boundary = NULL;
82 uintptr_t PSScavenge::_young_generation_boundary_compressed = 0;
83 elapsedTimer PSScavenge::_accumulated_time;
84 STWGCTimer PSScavenge::_gc_timer;
85 ParallelScavengeTracer PSScavenge::_gc_tracer;
86 CollectorCounters* PSScavenge::_counters = NULL;
87
88 static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_id) {
89 assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
90
91 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id);
92 PSScavengeRootsClosure roots_closure(pm);
93 PSPromoteRootsClosure roots_to_old_closure(pm);
94
95 switch (root_type) {
96 case ParallelRootType::universe:
97 Universe::oops_do(&roots_closure);
98 break;
99
100 case ParallelRootType::object_synchronizer:
101 ObjectSynchronizer::oops_do(&roots_closure);
102 break;
103
104 case ParallelRootType::class_loader_data:
105 {
106 PSScavengeCLDClosure cld_closure(pm);
107 ClassLoaderDataGraph::cld_do(&cld_closure);
108 }
109 break;
110
111 case ParallelRootType::management:
112 Management::oops_do(&roots_closure);
113 break;
114
115 case ParallelRootType::jvmti:
116 JvmtiExport::oops_do(&roots_closure);
117 break;
118
119 case ParallelRootType::code_cache:
120 {
121 MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);
122 ScavengableNMethods::nmethods_do(&code_closure);
123 AOTLoader::oops_do(&roots_closure);
288 class PSThreadRootsTaskClosure : public ThreadClosure {
289 uint _worker_id;
290 public:
291 PSThreadRootsTaskClosure(uint worker_id) : _worker_id(worker_id) { }
292 virtual void do_thread(Thread* thread) {
293 assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
294
295 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(_worker_id);
296 PSScavengeRootsClosure roots_closure(pm);
297 MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations);
298
299 thread->oops_do(&roots_closure, &roots_in_blobs);
300
301 // Do the real work
302 pm->drain_stacks(false);
303 }
304 };
305
306 class ScavengeRootsTask : public AbstractGangTask {
307 StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do
308 OopStorageSetStrongParState<false /* concurrent */, false /* is_const */> _oop_storage_strong_par_state;
309 SequentialSubTasksDone _subtasks;
310 PSOldGen* _old_gen;
311 HeapWord* _gen_top;
312 uint _active_workers;
313 bool _is_empty;
314 TaskTerminator _terminator;
315
316 public:
317 ScavengeRootsTask(PSOldGen* old_gen,
318 HeapWord* gen_top,
319 uint active_workers,
320 bool is_empty) :
321 AbstractGangTask("ScavengeRootsTask"),
322 _strong_roots_scope(active_workers),
323 _subtasks(),
324 _old_gen(old_gen),
325 _gen_top(gen_top),
326 _active_workers(active_workers),
327 _is_empty(is_empty),
328 _terminator(active_workers, PSPromotionManager::vm_thread_promotion_manager()->stack_array_depth()) {
350 card_table->scavenge_contents_parallel(_old_gen->start_array(),
351 _old_gen->object_space(),
352 _gen_top,
353 pm,
354 worker_id,
355 _active_workers);
356
357 // Do the real work
358 pm->drain_stacks(false);
359 }
360 }
361
362 for (uint root_type = 0; _subtasks.try_claim_task(root_type); /* empty */ ) {
363 scavenge_roots_work(static_cast<ParallelRootType::Value>(root_type), worker_id);
364 }
365 _subtasks.all_tasks_completed();
366
367 PSThreadRootsTaskClosure closure(worker_id);
368 Threads::possibly_parallel_threads_do(true /*parallel */, &closure);
369
370 // Scavenge OopStorages
371 {
372 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id);
373 PSScavengeRootsClosure closure(pm);
374 _oop_storage_strong_par_state.oops_do(&closure);
375 // Do the real work
376 pm->drain_stacks(false);
377 }
378
379 // If active_workers can exceed 1, add a steal_work().
380 // PSPromotionManager::drain_stacks_depth() does not fully drain its
381 // stacks and expects a steal_work() to complete the draining if
382 // ParallelGCThreads is > 1.
383
384 if (_active_workers > 1) {
385 steal_work(_terminator, worker_id);
386 }
387 }
388 };
389
390 // This method contains no policy. You should probably
391 // be calling invoke() instead.
392 bool PSScavenge::invoke_no_policy() {
393 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
394 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
395
396 _gc_timer.register_gc_start();
397
|