25 #include "precompiled.hpp"
26 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
27 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
28 #include "gc_implementation/parNew/parNewGeneration.hpp"
29 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
30 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
31 #include "gc_implementation/shared/ageTable.hpp"
32 #include "gc_implementation/shared/copyFailedInfo.hpp"
33 #include "gc_implementation/shared/gcHeapSummary.hpp"
34 #include "gc_implementation/shared/gcTimer.hpp"
35 #include "gc_implementation/shared/gcTrace.hpp"
36 #include "gc_implementation/shared/gcTraceTime.hpp"
37 #include "gc_implementation/shared/parGCAllocBuffer.inline.hpp"
38 #include "gc_implementation/shared/spaceDecorator.hpp"
39 #include "memory/defNewGeneration.inline.hpp"
40 #include "memory/genCollectedHeap.hpp"
41 #include "memory/genOopClosures.inline.hpp"
42 #include "memory/generation.hpp"
43 #include "memory/referencePolicy.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "memory/sharedHeap.hpp"
46 #include "memory/space.hpp"
47 #include "oops/objArrayOop.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "runtime/atomic.inline.hpp"
50 #include "runtime/handles.hpp"
51 #include "runtime/handles.inline.hpp"
52 #include "runtime/java.hpp"
53 #include "runtime/thread.inline.hpp"
54 #include "utilities/copy.hpp"
55 #include "utilities/globalDefinitions.hpp"
56 #include "utilities/workgroup.hpp"
57
58 #ifdef _MSC_VER
59 #pragma warning( push )
60 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
61 #endif
62 ParScanThreadState::ParScanThreadState(Space* to_space_,
63 ParNewGeneration* gen_,
64 Generation* old_gen_,
65 int thread_num_,
957 int n_workers = active_workers;
958
959 // Set the correct parallelism (number of queues) in the reference processor
960 ref_processor()->set_active_mt_degree(n_workers);
961
962 // Always set the terminator for the active number of workers
963 // because only those workers go through the termination protocol.
964 ParallelTaskTerminator _term(n_workers, task_queues());
965 ParScanThreadStateSet thread_state_set(workers->active_workers(),
966 *to(), *this, *_old_gen, *task_queues(),
967 _overflow_stacks, desired_plab_sz(), _term);
968
969 ParNewGenTask tsk(this, _old_gen, reserved().end(), &thread_state_set);
970 gch->set_par_threads(n_workers);
971 gch->rem_set()->prepare_for_younger_refs_iterate(true);
972 // It turns out that even when we're using 1 thread, doing the work in a
973 // separate thread causes wide variance in run times. We can't help this
974 // in the multi-threaded case, but we special-case n=1 here to get
975 // repeatable measurements of the 1-thread overhead of the parallel code.
976 if (n_workers > 1) {
977 GenCollectedHeap::StrongRootsScope srs(gch);
978 workers->run_task(&tsk);
979 } else {
980 GenCollectedHeap::StrongRootsScope srs(gch);
981 tsk.work(0);
982 }
983 thread_state_set.reset(0 /* Bad value in debug if not reset */,
984 promotion_failed());
985
986 // Trace and reset failed promotion info.
987 if (promotion_failed()) {
988 thread_state_set.trace_promotion_failed(gc_tracer());
989 }
990
991 // Process (weak) reference objects found during scavenge.
992 ReferenceProcessor* rp = ref_processor();
993 IsAliveClosure is_alive(this);
994 ScanWeakRefClosure scan_weak_ref(this);
995 KeepAliveClosure keep_alive(&scan_weak_ref);
996 ScanClosure scan_without_gc_barrier(this, false);
997 ScanClosureWithParBarrier scan_with_gc_barrier(this, true);
998 set_promo_failure_scan_stack_closure(&scan_without_gc_barrier);
999 EvacuateFollowersClosureGeneral evacuate_followers(gch, _level,
1000 &scan_without_gc_barrier, &scan_with_gc_barrier);
|
25 #include "precompiled.hpp"
26 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
27 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
28 #include "gc_implementation/parNew/parNewGeneration.hpp"
29 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
30 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
31 #include "gc_implementation/shared/ageTable.hpp"
32 #include "gc_implementation/shared/copyFailedInfo.hpp"
33 #include "gc_implementation/shared/gcHeapSummary.hpp"
34 #include "gc_implementation/shared/gcTimer.hpp"
35 #include "gc_implementation/shared/gcTrace.hpp"
36 #include "gc_implementation/shared/gcTraceTime.hpp"
37 #include "gc_implementation/shared/parGCAllocBuffer.inline.hpp"
38 #include "gc_implementation/shared/spaceDecorator.hpp"
39 #include "memory/defNewGeneration.inline.hpp"
40 #include "memory/genCollectedHeap.hpp"
41 #include "memory/genOopClosures.inline.hpp"
42 #include "memory/generation.hpp"
43 #include "memory/referencePolicy.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "memory/strongRootsScope.hpp"
46 #include "memory/space.hpp"
47 #include "oops/objArrayOop.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "runtime/atomic.inline.hpp"
50 #include "runtime/handles.hpp"
51 #include "runtime/handles.inline.hpp"
52 #include "runtime/java.hpp"
53 #include "runtime/thread.inline.hpp"
54 #include "utilities/copy.hpp"
55 #include "utilities/globalDefinitions.hpp"
56 #include "utilities/workgroup.hpp"
57
58 #ifdef _MSC_VER
59 #pragma warning( push )
60 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
61 #endif
62 ParScanThreadState::ParScanThreadState(Space* to_space_,
63 ParNewGeneration* gen_,
64 Generation* old_gen_,
65 int thread_num_,
957 int n_workers = active_workers;
958
959 // Set the correct parallelism (number of queues) in the reference processor
960 ref_processor()->set_active_mt_degree(n_workers);
961
962 // Always set the terminator for the active number of workers
963 // because only those workers go through the termination protocol.
964 ParallelTaskTerminator _term(n_workers, task_queues());
965 ParScanThreadStateSet thread_state_set(workers->active_workers(),
966 *to(), *this, *_old_gen, *task_queues(),
967 _overflow_stacks, desired_plab_sz(), _term);
968
969 ParNewGenTask tsk(this, _old_gen, reserved().end(), &thread_state_set);
970 gch->set_par_threads(n_workers);
971 gch->rem_set()->prepare_for_younger_refs_iterate(true);
972 // It turns out that even when we're using 1 thread, doing the work in a
973 // separate thread causes wide variance in run times. We can't help this
974 // in the multi-threaded case, but we special-case n=1 here to get
975 // repeatable measurements of the 1-thread overhead of the parallel code.
976 if (n_workers > 1) {
977 StrongRootsScope srs;
978 workers->run_task(&tsk);
979 } else {
980 StrongRootsScope srs;
981 tsk.work(0);
982 }
983 thread_state_set.reset(0 /* Bad value in debug if not reset */,
984 promotion_failed());
985
986 // Trace and reset failed promotion info.
987 if (promotion_failed()) {
988 thread_state_set.trace_promotion_failed(gc_tracer());
989 }
990
991 // Process (weak) reference objects found during scavenge.
992 ReferenceProcessor* rp = ref_processor();
993 IsAliveClosure is_alive(this);
994 ScanWeakRefClosure scan_weak_ref(this);
995 KeepAliveClosure keep_alive(&scan_weak_ref);
996 ScanClosure scan_without_gc_barrier(this, false);
997 ScanClosureWithParBarrier scan_with_gc_barrier(this, true);
998 set_promo_failure_scan_stack_closure(&scan_without_gc_barrier);
999 EvacuateFollowersClosureGeneral evacuate_followers(gch, _level,
1000 &scan_without_gc_barrier, &scan_with_gc_barrier);
|