author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57777 | 90ead0febf56 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53536
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
52905
diff
changeset
|
2 |
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
26 |
#include "aot/aotLoader.hpp" |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
27 |
#include "classfile/classLoaderDataGraph.hpp" |
24426
0a69c8cdfca9
8038654: Separate SymbolTable and StringTable code
gziemski
parents:
24092
diff
changeset
|
28 |
#include "classfile/stringTable.hpp" |
11753 | 29 |
#include "code/codeCache.hpp" |
30764 | 30 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
31 |
#include "gc/parallel/psAdaptiveSizePolicy.hpp" |
|
52117
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51801
diff
changeset
|
32 |
#include "gc/parallel/psClosure.inline.hpp" |
57772
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
33 |
#include "gc/parallel/psCompactionManager.hpp" |
49982 | 34 |
#include "gc/parallel/psMarkSweepProxy.hpp" |
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
35 |
#include "gc/parallel/psParallelCompact.inline.hpp" |
52117
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51801
diff
changeset
|
36 |
#include "gc/parallel/psPromotionManager.inline.hpp" |
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
37 |
#include "gc/parallel/psRootType.hpp" |
30764 | 38 |
#include "gc/parallel/psScavenge.inline.hpp" |
39 |
#include "gc/shared/gcCause.hpp" |
|
40 |
#include "gc/shared/gcHeapSummary.hpp" |
|
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
41 |
#include "gc/shared/gcId.hpp" |
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49592
diff
changeset
|
42 |
#include "gc/shared/gcLocker.hpp" |
30764 | 43 |
#include "gc/shared/gcTimer.hpp" |
44 |
#include "gc/shared/gcTrace.hpp" |
|
35061 | 45 |
#include "gc/shared/gcTraceTime.inline.hpp" |
30764 | 46 |
#include "gc/shared/isGCActiveMark.hpp" |
47 |
#include "gc/shared/referencePolicy.hpp" |
|
48 |
#include "gc/shared/referenceProcessor.hpp" |
|
50605
7f63c74f0974
8202845: Refactor reference processing for improved parallelism
tschatzl
parents:
50396
diff
changeset
|
49 |
#include "gc/shared/referenceProcessorPhaseTimes.hpp" |
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
50 |
#include "gc/shared/scavengableNMethods.hpp" |
30764 | 51 |
#include "gc/shared/spaceDecorator.hpp" |
47648
226b1fc611b9
8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
47546
diff
changeset
|
52 |
#include "gc/shared/weakProcessor.hpp" |
57767
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
53 |
#include "gc/shared/workerPolicy.hpp" |
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
54 |
#include "gc/shared/workgroup.hpp" |
7397 | 55 |
#include "memory/resourceArea.hpp" |
54786 | 56 |
#include "memory/universe.hpp" |
35061 | 57 |
#include "logging/log.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49389
diff
changeset
|
58 |
#include "oops/access.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49389
diff
changeset
|
59 |
#include "oops/compressedOops.inline.hpp" |
7397 | 60 |
#include "oops/oop.inline.hpp" |
61 |
#include "runtime/biasedLocking.hpp" |
|
62 |
#include "runtime/handles.inline.hpp" |
|
63 |
#include "runtime/threadCritical.hpp" |
|
64 |
#include "runtime/vmThread.hpp" |
|
52877
9e041366c764
8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents:
52117
diff
changeset
|
65 |
#include "runtime/vmOperations.hpp" |
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
66 |
#include "services/management.hpp" |
7397 | 67 |
#include "services/memoryService.hpp" |
68 |
#include "utilities/stack.inline.hpp" |
|
1 | 69 |
|
49964
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
70 |
HeapWord* PSScavenge::_to_space_top_before_gc = NULL; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
71 |
int PSScavenge::_consecutive_skipped_scavenges = 0; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
72 |
SpanSubjectToDiscoveryClosure PSScavenge::_span_based_discoverer; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
73 |
ReferenceProcessor* PSScavenge::_ref_processor = NULL; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
74 |
PSCardTable* PSScavenge::_card_table = NULL; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
75 |
bool PSScavenge::_survivor_overflow = false; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
76 |
uint PSScavenge::_tenuring_threshold = 0; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
77 |
HeapWord* PSScavenge::_young_generation_boundary = NULL; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
78 |
uintptr_t PSScavenge::_young_generation_boundary_compressed = 0; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
79 |
elapsedTimer PSScavenge::_accumulated_time; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
80 |
STWGCTimer PSScavenge::_gc_timer; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
81 |
ParallelScavengeTracer PSScavenge::_gc_tracer; |
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
82 |
CollectorCounters* PSScavenge::_counters = NULL; |
1 | 83 |
|
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
84 |
static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_id) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
85 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
86 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
87 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
88 |
PSScavengeRootsClosure roots_closure(pm); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
89 |
PSPromoteRootsClosure roots_to_old_closure(pm); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
90 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
91 |
switch (root_type) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
92 |
case ParallelRootType::universe: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
93 |
Universe::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
94 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
95 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
96 |
case ParallelRootType::jni_handles: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
97 |
JNIHandles::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
98 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
99 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
100 |
case ParallelRootType::object_synchronizer: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
101 |
ObjectSynchronizer::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
102 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
103 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
104 |
case ParallelRootType::system_dictionary: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
105 |
SystemDictionary::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
106 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
107 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
108 |
case ParallelRootType::class_loader_data: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
109 |
{ |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
110 |
PSScavengeCLDClosure cld_closure(pm); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
111 |
ClassLoaderDataGraph::cld_do(&cld_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
112 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
113 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
114 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
115 |
case ParallelRootType::management: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
116 |
Management::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
117 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
118 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
119 |
case ParallelRootType::jvmti: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
120 |
JvmtiExport::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
121 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
122 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
123 |
case ParallelRootType::code_cache: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
124 |
{ |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
125 |
MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
126 |
ScavengableNMethods::nmethods_do(&code_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
127 |
AOTLoader::oops_do(&roots_closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
128 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
129 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
130 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
131 |
case ParallelRootType::sentinel: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
132 |
DEBUG_ONLY(default:) // DEBUG_ONLY hack will create compile error on release builds (-Wswitch) and runtime check on debug builds |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
133 |
fatal("Bad enumeration value: %u", root_type); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
134 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
135 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
136 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
137 |
// Do the real work |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
138 |
pm->drain_stacks(false); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
139 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
140 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
141 |
static void steal_work(ParallelTaskTerminator& terminator, uint worker_id) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
142 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
143 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
144 |
PSPromotionManager* pm = |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
145 |
PSPromotionManager::gc_thread_promotion_manager(worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
146 |
pm->drain_stacks(true); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
147 |
guarantee(pm->stacks_empty(), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
148 |
"stacks should be empty at this point"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
149 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
150 |
while (true) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
151 |
StarTask p; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
152 |
if (PSPromotionManager::steal_depth(worker_id, p)) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
153 |
TASKQUEUE_STATS_ONLY(pm->record_steal(p)); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
154 |
pm->process_popped_location_depth(p); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
155 |
pm->drain_stacks_depth(true); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
156 |
} else { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
157 |
if (terminator.offer_termination()) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
158 |
break; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
159 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
160 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
161 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
162 |
guarantee(pm->stacks_empty(), "stacks should be empty at this point"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
163 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
164 |
|
1 | 165 |
// Define before use |
166 |
class PSIsAliveClosure: public BoolObjectClosure { |
|
167 |
public: |
|
168 |
bool do_object_b(oop p) { |
|
17852
59b05e1db547
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
17846
diff
changeset
|
169 |
return (!PSScavenge::is_obj_in_young(p)) || p->is_forwarded(); |
1 | 170 |
} |
171 |
}; |
|
172 |
||
173 |
PSIsAliveClosure PSScavenge::_is_alive_closure; |
|
174 |
||
175 |
class PSKeepAliveClosure: public OopClosure { |
|
176 |
protected: |
|
177 |
MutableSpace* _to_space; |
|
178 |
PSPromotionManager* _promotion_manager; |
|
179 |
||
180 |
public: |
|
181 |
PSKeepAliveClosure(PSPromotionManager* pm) : _promotion_manager(pm) { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
182 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 183 |
_to_space = heap->young_gen()->to_space(); |
184 |
||
185 |
assert(_promotion_manager != NULL, "Sanity"); |
|
186 |
} |
|
187 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
188 |
template <class T> void do_oop_work(T* p) { |
50728 | 189 |
assert (oopDesc::is_oop(RawAccess<IS_NOT_NULL>::oop_load(p)), |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
190 |
"expected an oop while scanning weak refs"); |
1 | 191 |
|
192 |
// Weak refs may be visited more than once. |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
193 |
if (PSScavenge::should_scavenge(p, _to_space)) { |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28212
diff
changeset
|
194 |
_promotion_manager->copy_and_push_safe_barrier<T, /*promote_immediately=*/false>(p); |
1 | 195 |
} |
196 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
197 |
virtual void do_oop(oop* p) { PSKeepAliveClosure::do_oop_work(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
198 |
virtual void do_oop(narrowOop* p) { PSKeepAliveClosure::do_oop_work(p); } |
1 | 199 |
}; |
200 |
||
201 |
class PSEvacuateFollowersClosure: public VoidClosure { |
|
202 |
private: |
|
203 |
PSPromotionManager* _promotion_manager; |
|
204 |
public: |
|
205 |
PSEvacuateFollowersClosure(PSPromotionManager* pm) : _promotion_manager(pm) {} |
|
206 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
207 |
virtual void do_void() { |
1 | 208 |
assert(_promotion_manager != NULL, "Sanity"); |
209 |
_promotion_manager->drain_stacks(true); |
|
210 |
guarantee(_promotion_manager->stacks_empty(), |
|
211 |
"stacks should be empty at this point"); |
|
212 |
} |
|
213 |
}; |
|
214 |
||
57772
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
215 |
class PSRefProcTaskExecutor: public AbstractRefProcTaskExecutor { |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
216 |
virtual void execute(ProcessTask& process_task, uint ergo_workers); |
1 | 217 |
}; |
218 |
||
57772
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
219 |
class PSRefProcTask : public AbstractGangTask { |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
220 |
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask; |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
221 |
TaskTerminator _terminator; |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
222 |
ProcessTask& _task; |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
223 |
uint _active_workers; |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
224 |
|
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
225 |
public: |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
226 |
PSRefProcTask(ProcessTask& task, uint active_workers) |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
227 |
: AbstractGangTask("PSRefProcTask"), |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
228 |
_terminator(active_workers, PSPromotionManager::stack_array_depth()), |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
229 |
_task(task), |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
230 |
_active_workers(active_workers) { |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
231 |
} |
1 | 232 |
|
57772
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
233 |
virtual void work(uint worker_id) { |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
234 |
PSPromotionManager* promotion_manager = |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
235 |
PSPromotionManager::gc_thread_promotion_manager(worker_id); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
236 |
assert(promotion_manager != NULL, "sanity check"); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
237 |
PSKeepAliveClosure keep_alive(promotion_manager); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
238 |
PSEvacuateFollowersClosure evac_followers(promotion_manager); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
239 |
PSIsAliveClosure is_alive; |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
240 |
_task.work(worker_id, is_alive, keep_alive, evac_followers); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
241 |
|
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
242 |
if (_task.marks_oops_alive() && _active_workers > 1) { |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
243 |
steal_work(*_terminator.terminator(), worker_id); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
244 |
} |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
245 |
} |
1 | 246 |
}; |
247 |
||
57772
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
248 |
void PSRefProcTaskExecutor::execute(ProcessTask& process_task, uint ergo_workers) { |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
249 |
PSRefProcTask task(process_task, ergo_workers); |
2410b04f074f
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
lkorinth
parents:
57771
diff
changeset
|
250 |
ParallelScavengeHeap::heap()->workers().run_task(&task); |
1 | 251 |
} |
252 |
||
253 |
// This method contains all heap specific policy for invoking scavenge. |
|
254 |
// PSScavenge::invoke_no_policy() will do nothing but attempt to |
|
255 |
// scavenge. It will not clean up after failed promotions, bail out if |
|
256 |
// we've exceeded policy time limits, or any other special behavior. |
|
257 |
// All such policy should be placed here. |
|
258 |
// |
|
259 |
// Note that this method should only be called from the vm_thread while |
|
260 |
// at a safepoint! |
|
11757
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
261 |
bool PSScavenge::invoke() { |
1 | 262 |
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
263 |
assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread"); |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
264 |
assert(!ParallelScavengeHeap::heap()->is_gc_active(), "not reentrant"); |
1 | 265 |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
266 |
ParallelScavengeHeap* const heap = ParallelScavengeHeap::heap(); |
1 | 267 |
PSAdaptiveSizePolicy* policy = heap->size_policy(); |
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
268 |
IsGCActiveMark mark; |
1 | 269 |
|
11757
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
270 |
const bool scavenge_done = PSScavenge::invoke_no_policy(); |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
271 |
const bool need_full_gc = !scavenge_done || |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
272 |
policy->should_full_GC(heap->old_gen()->free_in_bytes()); |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
273 |
bool full_gc_done = false; |
1 | 274 |
|
11757
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
275 |
if (UsePerfData) { |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
276 |
PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters(); |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
277 |
const int ffs_val = need_full_gc ? full_follows_scavenge : not_skipped; |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
278 |
counters->update_full_follows_scavenge(ffs_val); |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
279 |
} |
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
280 |
|
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
281 |
if (need_full_gc) { |
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
282 |
GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy); |
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
48168
diff
changeset
|
283 |
SoftRefPolicy* srp = heap->soft_ref_policy(); |
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
48168
diff
changeset
|
284 |
const bool clear_all_softrefs = srp->should_clear_all_soft_refs(); |
1 | 285 |
|
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
286 |
if (UseParallelOldGC) { |
11757
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
287 |
full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs); |
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
288 |
} else { |
49982 | 289 |
full_gc_done = PSMarkSweepProxy::invoke_no_policy(clear_all_softrefs); |
1 | 290 |
} |
291 |
} |
|
11757
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
292 |
|
cdf6204b114a
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
11753
diff
changeset
|
293 |
return full_gc_done; |
1 | 294 |
} |
295 |
||
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
296 |
class PSThreadRootsTaskClosure : public ThreadClosure { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
297 |
uint _worker_id; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
298 |
public: |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
299 |
PSThreadRootsTaskClosure(uint worker_id) : _worker_id(worker_id) { } |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
300 |
virtual void do_thread(Thread* thread) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
301 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
302 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
303 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(_worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
304 |
PSScavengeRootsClosure roots_closure(pm); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
305 |
MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
306 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
307 |
thread->oops_do(&roots_closure, &roots_in_blobs); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
308 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
309 |
// Do the real work |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
310 |
pm->drain_stacks(false); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
311 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
312 |
}; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
313 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
314 |
class ScavengeRootsTask : public AbstractGangTask { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
315 |
StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
316 |
SequentialSubTasksDone _subtasks; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
317 |
PSOldGen* _old_gen; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
318 |
HeapWord* _gen_top; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
319 |
uint _active_workers; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
320 |
bool _is_empty; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
321 |
TaskTerminator _terminator; |
50058
f7e564cacfbc
8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents:
50049
diff
changeset
|
322 |
|
f7e564cacfbc
8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents:
50049
diff
changeset
|
323 |
public: |
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
324 |
ScavengeRootsTask(PSOldGen* old_gen, |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
325 |
HeapWord* gen_top, |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
326 |
uint active_workers, |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
327 |
bool is_empty) : |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
328 |
AbstractGangTask("ScavengeRootsTask"), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
329 |
_strong_roots_scope(active_workers), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
330 |
_subtasks(), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
331 |
_old_gen(old_gen), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
332 |
_gen_top(gen_top), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
333 |
_active_workers(active_workers), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
334 |
_is_empty(is_empty), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
335 |
_terminator(active_workers, PSPromotionManager::vm_thread_promotion_manager()->stack_array_depth()) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
336 |
_subtasks.set_n_threads(active_workers); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
337 |
_subtasks.set_n_tasks(ParallelRootType::sentinel); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
338 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
339 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
340 |
virtual void work(uint worker_id) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
341 |
ResourceMark rm; |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
342 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
343 |
if (!_is_empty) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
344 |
// There are only old-to-young pointers if there are objects |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
345 |
// in the old gen. |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
346 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
347 |
assert(_old_gen != NULL, "Sanity"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
348 |
// There are no old-to-young pointers if the old gen is empty. |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
349 |
assert(!_old_gen->object_space()->is_empty(), "Should not be called is there is no work"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
350 |
assert(_old_gen->object_space()->contains(_gen_top) || _gen_top == _old_gen->object_space()->top(), "Sanity"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
351 |
assert(worker_id < ParallelGCThreads, "Sanity"); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
352 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
353 |
{ |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
354 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
355 |
PSCardTable* card_table = ParallelScavengeHeap::heap()->card_table(); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
356 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
357 |
card_table->scavenge_contents_parallel(_old_gen->start_array(), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
358 |
_old_gen->object_space(), |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
359 |
_gen_top, |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
360 |
pm, |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
361 |
worker_id, |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
362 |
_active_workers); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
363 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
364 |
// Do the real work |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
365 |
pm->drain_stacks(false); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
366 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
367 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
368 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
369 |
for (uint root_type = 0; _subtasks.try_claim_task(root_type); /* empty */ ) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
370 |
scavenge_roots_work(static_cast<ParallelRootType::Value>(root_type), worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
371 |
} |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
372 |
_subtasks.all_tasks_completed(); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
373 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
374 |
PSThreadRootsTaskClosure closure(worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
375 |
Threads::possibly_parallel_threads_do(true /*parallel */, &closure); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
376 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
377 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
378 |
// If active_workers can exceed 1, add a steal_work(). |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
379 |
// PSPromotionManager::drain_stacks_depth() does not fully drain its |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
380 |
// stacks and expects a steal_work() to complete the draining if |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
381 |
// ParallelGCThreads is > 1. |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
382 |
|
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
383 |
if (_active_workers > 1) { |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
384 |
steal_work(*_terminator.terminator() , worker_id); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
385 |
} |
50058
f7e564cacfbc
8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents:
50049
diff
changeset
|
386 |
} |
f7e564cacfbc
8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents:
50049
diff
changeset
|
387 |
}; |
f7e564cacfbc
8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents:
50049
diff
changeset
|
388 |
|
1 | 389 |
// This method contains no policy. You should probably |
390 |
// be calling invoke() instead. |
|
391 |
bool PSScavenge::invoke_no_policy() { |
|
392 |
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
|
393 |
assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread"); |
|
394 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
20317
diff
changeset
|
395 |
_gc_timer.register_gc_start(); |
18025 | 396 |
|
1 | 397 |
TimeStamp scavenge_entry; |
398 |
TimeStamp scavenge_midpoint; |
|
399 |
TimeStamp scavenge_exit; |
|
400 |
||
401 |
scavenge_entry.update(); |
|
402 |
||
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
35061
diff
changeset
|
403 |
if (GCLocker::check_active_before_gc()) { |
1 | 404 |
return false; |
405 |
} |
|
406 |
||
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
407 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 408 |
GCCause::Cause gc_cause = heap->gc_cause(); |
409 |
||
410 |
// Check for potential problems. |
|
411 |
if (!should_attempt_scavenge()) { |
|
412 |
return false; |
|
413 |
} |
|
414 |
||
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
415 |
GCIdMark gc_id_mark; |
18025 | 416 |
_gc_tracer.report_gc_start(heap->gc_cause(), _gc_timer.gc_start()); |
417 |
||
1 | 418 |
bool promotion_failure_occurred = false; |
419 |
||
420 |
PSYoungGen* young_gen = heap->young_gen(); |
|
421 |
PSOldGen* old_gen = heap->old_gen(); |
|
422 |
PSAdaptiveSizePolicy* size_policy = heap->size_policy(); |
|
18025 | 423 |
|
1 | 424 |
heap->increment_total_collections(); |
425 |
||
31634
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31330
diff
changeset
|
426 |
if (AdaptiveSizePolicy::should_update_eden_stats(gc_cause)) { |
1 | 427 |
// Gather the feedback data for eden occupancy. |
428 |
young_gen->eden_space()->accumulate_statistics(); |
|
429 |
} |
|
430 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11174
diff
changeset
|
431 |
heap->print_heap_before_gc(); |
18025 | 432 |
heap->trace_heap_before_gc(&_gc_tracer); |
1 | 433 |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
57773
diff
changeset
|
434 |
assert(!NeverTenure || _tenuring_threshold == markWord::max_age + 1, "Sanity"); |
1 | 435 |
assert(!AlwaysTenure || _tenuring_threshold == 0, "Sanity"); |
436 |
||
437 |
// Fill in TLABs |
|
438 |
heap->ensure_parsability(true); // retire TLABs |
|
439 |
||
440 |
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { |
|
441 |
HandleMark hm; // Discard invalid handles created during verification |
|
35061 | 442 |
Universe::verify("Before GC"); |
1 | 443 |
} |
444 |
||
445 |
{ |
|
446 |
ResourceMark rm; |
|
447 |
HandleMark hm; |
|
448 |
||
35061 | 449 |
GCTraceCPUTime tcpu; |
450 |
GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true); |
|
1 | 451 |
TraceCollectorStats tcs(counters()); |
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47799
diff
changeset
|
452 |
TraceMemoryManagerStats tms(heap->young_gc_manager(), gc_cause); |
1 | 453 |
|
47546
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
454 |
if (log_is_enabled(Debug, gc, heap, exit)) { |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
455 |
accumulated_time()->start(); |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
456 |
} |
1 | 457 |
|
458 |
// Let the size policy know we're starting |
|
459 |
size_policy->minor_collection_begin(); |
|
460 |
||
461 |
// Verify the object start arrays. |
|
462 |
if (VerifyObjectStartArray && |
|
463 |
VerifyBeforeGC) { |
|
464 |
old_gen->verify_object_start_array(); |
|
465 |
} |
|
466 |
||
467 |
// Verify no unmarked old->young roots |
|
468 |
if (VerifyRememberedSets) { |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49047
diff
changeset
|
469 |
heap->card_table()->verify_all_young_refs_imprecise(); |
1 | 470 |
} |
471 |
||
33227
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
472 |
assert(young_gen->to_space()->is_empty(), |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
473 |
"Attempt to scavenge with live objects in to_space"); |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
474 |
young_gen->to_space()->clear(SpaceDecorator::Mangle); |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
475 |
|
1 | 476 |
save_to_space_top_before_gc(); |
477 |
||
47799 | 478 |
#if COMPILER2_OR_JVMCI |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32623
diff
changeset
|
479 |
DerivedPointerTable::clear(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32623
diff
changeset
|
480 |
#endif |
1 | 481 |
|
28212
647b7d0efb88
8066827: Remove ReferenceProcessor::clean_up_discovered_references()
kbarrett
parents:
27887
diff
changeset
|
482 |
reference_processor()->enable_discovery(); |
1610
5dddd195cc86
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
1606
diff
changeset
|
483 |
reference_processor()->setup_policy(false); |
1 | 484 |
|
57662
f81dbe27a7b1
8227225: ParallelGC: add subspace transitions for young gen for gc+heap=info log lines
tonyp
parents:
55740
diff
changeset
|
485 |
const PreGenGCValues pre_gc_values = heap->get_pre_gc_values(); |
1 | 486 |
|
487 |
// Reset our survivor overflow. |
|
488 |
set_survivor_overflow(false); |
|
489 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
490 |
// We need to save the old top values before |
1 | 491 |
// creating the promotion_manager. We pass the top |
492 |
// values to the card_table, to prevent it from |
|
493 |
// straying into the promotion labs. |
|
494 |
HeapWord* old_top = old_gen->object_space()->top(); |
|
495 |
||
57767
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
496 |
const uint active_workers = |
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
497 |
WorkerPolicy::calc_active_workers(ParallelScavengeHeap::heap()->workers().total_workers(), |
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
498 |
ParallelScavengeHeap::heap()->workers().active_workers(), |
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
499 |
Threads::number_of_non_daemon_threads()); |
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
500 |
ParallelScavengeHeap::heap()->workers().update_active_workers(active_workers); |
b3e44e1b135d
8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)
lkorinth
parents:
57662
diff
changeset
|
501 |
|
1 | 502 |
PSPromotionManager::pre_scavenge(); |
503 |
||
504 |
// We'll use the promotion manager again later. |
|
505 |
PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager(); |
|
506 |
{ |
|
35061 | 507 |
GCTraceTime(Debug, gc, phases) tm("Scavenge", &_gc_timer); |
1 | 508 |
|
57771
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
509 |
ScavengeRootsTask task(old_gen, old_top, active_workers, old_gen->object_space()->is_empty()); |
50c959cc40e8
8224663: Parallel GC: Use WorkGang (5: ScavengeRootsTask)
lkorinth
parents:
57767
diff
changeset
|
510 |
ParallelScavengeHeap::heap()->workers().run_task(&task); |
1 | 511 |
} |
512 |
||
513 |
scavenge_midpoint.update(); |
|
514 |
||
515 |
// Process reference objects discovered during scavenge |
|
516 |
{ |
|
37146 | 517 |
GCTraceTime(Debug, gc, phases) tm("Reference Processing", &_gc_timer); |
18025 | 518 |
|
1610
5dddd195cc86
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
1606
diff
changeset
|
519 |
reference_processor()->setup_policy(false); // not always_clear |
11174
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10670
diff
changeset
|
520 |
reference_processor()->set_active_mt_degree(active_workers); |
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
521 |
PSKeepAliveClosure keep_alive(promotion_manager); |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
522 |
PSEvacuateFollowersClosure evac_followers(promotion_manager); |
18025 | 523 |
ReferenceProcessorStats stats; |
50396
7f48bff40a9a
8204094: assert(worker_i < _length) failed: Worker 15 is greater than max: 11 at ReferenceProcessorPhaseTimes
sangheki
parents:
50071
diff
changeset
|
524 |
ReferenceProcessorPhaseTimes pt(&_gc_timer, reference_processor()->max_num_queues()); |
1 | 525 |
if (reference_processor()->processing_is_mt()) { |
526 |
PSRefProcTaskExecutor task_executor; |
|
18025 | 527 |
stats = reference_processor()->process_discovered_references( |
528 |
&_is_alive_closure, &keep_alive, &evac_followers, &task_executor, |
|
46795
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
40096
diff
changeset
|
529 |
&pt); |
1 | 530 |
} else { |
18025 | 531 |
stats = reference_processor()->process_discovered_references( |
46795
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
40096
diff
changeset
|
532 |
&_is_alive_closure, &keep_alive, &evac_followers, NULL, &pt); |
18025 | 533 |
} |
534 |
||
535 |
_gc_tracer.report_gc_reference_stats(stats); |
|
46795
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
40096
diff
changeset
|
536 |
pt.print_all_references(); |
1 | 537 |
} |
538 |
||
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
539 |
assert(promotion_manager->stacks_empty(),"stacks should be empty at this point"); |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
540 |
|
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
541 |
PSScavengeRootsClosure root_closure(promotion_manager); |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
542 |
|
22205
8ee59199b85d
8027364: PSScavenge accounts too large code section to StringTable unlink
tschatzl
parents:
21767
diff
changeset
|
543 |
{ |
47648
226b1fc611b9
8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
47546
diff
changeset
|
544 |
GCTraceTime(Debug, gc, phases) tm("Weak Processing", &_gc_timer); |
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
545 |
WeakProcessor::weak_oops_do(&_is_alive_closure, &root_closure); |
47648
226b1fc611b9
8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
47546
diff
changeset
|
546 |
} |
226b1fc611b9
8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
47546
diff
changeset
|
547 |
|
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
548 |
// Verify that usage of root_closure didn't copy any objects. |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
549 |
assert(promotion_manager->stacks_empty(),"stacks should be empty at this point"); |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47648
diff
changeset
|
550 |
|
1 | 551 |
// Finally, flush the promotion_manager's labs, and deallocate its stacks. |
18025 | 552 |
promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer); |
1 | 553 |
if (promotion_failure_occurred) { |
554 |
clean_up_failed_promotion(); |
|
38080 | 555 |
log_info(gc, promotion)("Promotion failed"); |
1 | 556 |
} |
557 |
||
33143
2083f82acec8
8139134: Wrong tenuring threshold in young GC trace event
ehelin
parents:
33107
diff
changeset
|
558 |
_gc_tracer.report_tenuring_threshold(tenuring_threshold()); |
2083f82acec8
8139134: Wrong tenuring threshold in young GC trace event
ehelin
parents:
33107
diff
changeset
|
559 |
|
1 | 560 |
// Let the size policy know we're done. Note that we count promotion |
561 |
// failure cleanup time as part of the collection (otherwise, we're |
|
562 |
// implicitly saying it's mutator time). |
|
563 |
size_policy->minor_collection_end(gc_cause); |
|
564 |
||
565 |
if (!promotion_failure_occurred) { |
|
566 |
// Swap the survivor spaces. |
|
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
567 |
young_gen->eden_space()->clear(SpaceDecorator::Mangle); |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
568 |
young_gen->from_space()->clear(SpaceDecorator::Mangle); |
1 | 569 |
young_gen->swap_spaces(); |
570 |
||
571 |
size_t survived = young_gen->from_space()->used_in_bytes(); |
|
35061 | 572 |
size_t promoted = old_gen->used_in_bytes() - pre_gc_values.old_gen_used(); |
1 | 573 |
size_policy->update_averages(_survivor_overflow, survived, promoted); |
574 |
||
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
575 |
// A successful scavenge should restart the GC time limit count which is |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
576 |
// for full GC's. |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
3908
diff
changeset
|
577 |
size_policy->reset_gc_overhead_limit_count(); |
1 | 578 |
if (UseAdaptiveSizePolicy) { |
579 |
// Calculate the new survivor size and tenuring threshold |
|
580 |
||
35061 | 581 |
log_debug(gc, ergo)("AdaptiveSizeStart: collection: %d ", heap->total_collections()); |
582 |
log_trace(gc, ergo)("old_gen_capacity: " SIZE_FORMAT " young_gen_capacity: " SIZE_FORMAT, |
|
583 |
old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes()); |
|
1 | 584 |
|
585 |
if (UsePerfData) { |
|
586 |
PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters(); |
|
587 |
counters->update_old_eden_size( |
|
588 |
size_policy->calculated_eden_size_in_bytes()); |
|
589 |
counters->update_old_promo_size( |
|
590 |
size_policy->calculated_promo_size_in_bytes()); |
|
591 |
counters->update_old_capacity(old_gen->capacity_in_bytes()); |
|
592 |
counters->update_young_capacity(young_gen->capacity_in_bytes()); |
|
593 |
counters->update_survived(survived); |
|
594 |
counters->update_promoted(promoted); |
|
595 |
counters->update_survivor_overflowed(_survivor_overflow); |
|
596 |
} |
|
597 |
||
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
598 |
size_t max_young_size = young_gen->max_size(); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
599 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
600 |
// Deciding a free ratio in the young generation is tricky, so if |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
601 |
// MinHeapFreeRatio or MaxHeapFreeRatio are in use (implicating |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
602 |
// that the old generation size may have been limited because of them) we |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
603 |
// should then limit our young generation size using NewRatio to have it |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
604 |
// follow the old generation size. |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
605 |
if (MinHeapFreeRatio != 0 || MaxHeapFreeRatio != 100) { |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
606 |
max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio, young_gen->max_size()); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
607 |
} |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
608 |
|
1 | 609 |
size_t survivor_limit = |
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
610 |
size_policy->max_survivor_size(max_young_size); |
1 | 611 |
_tenuring_threshold = |
612 |
size_policy->compute_survivor_space_size_and_threshold( |
|
613 |
_survivor_overflow, |
|
614 |
_tenuring_threshold, |
|
615 |
survivor_limit); |
|
616 |
||
35061 | 617 |
log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max threshold " UINTX_FORMAT ")", |
618 |
size_policy->calculated_survivor_size_in_bytes(), |
|
619 |
_tenuring_threshold, MaxTenuringThreshold); |
|
1 | 620 |
|
621 |
if (UsePerfData) { |
|
622 |
PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters(); |
|
623 |
counters->update_tenuring_threshold(_tenuring_threshold); |
|
624 |
counters->update_survivor_size_counters(); |
|
625 |
} |
|
626 |
||
627 |
// Do call at minor collections? |
|
628 |
// Don't check if the size_policy is ready at this |
|
629 |
// level. Let the size_policy check that internally. |
|
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
630 |
if (UseAdaptiveGenerationSizePolicyAtMinorCollection && |
31634
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31330
diff
changeset
|
631 |
(AdaptiveSizePolicy::should_update_eden_stats(gc_cause))) { |
22551 | 632 |
// Calculate optimal free space amounts |
1 | 633 |
assert(young_gen->max_size() > |
634 |
young_gen->from_space()->capacity_in_bytes() + |
|
635 |
young_gen->to_space()->capacity_in_bytes(), |
|
636 |
"Sizes of space in young gen are out-of-bounds"); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
637 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
638 |
size_t young_live = young_gen->used_in_bytes(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
639 |
size_t eden_live = young_gen->eden_space()->used_in_bytes(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
640 |
size_t cur_eden = young_gen->eden_space()->capacity_in_bytes(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
641 |
size_t max_old_gen_size = old_gen->max_gen_size(); |
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
642 |
size_t max_eden_size = max_young_size - |
1 | 643 |
young_gen->from_space()->capacity_in_bytes() - |
644 |
young_gen->to_space()->capacity_in_bytes(); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
645 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
646 |
// Used for diagnostics |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
647 |
size_policy->clear_generation_free_space_flags(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
648 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
649 |
size_policy->compute_eden_space_size(young_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
650 |
eden_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
651 |
cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
652 |
max_eden_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
653 |
false /* not full gc*/); |
1 | 654 |
|
54085
ab87b06dfdc0
8212206: Refactor AdaptiveSizePolicy to separate out code related to GC overhead
manc
parents:
53726
diff
changeset
|
655 |
size_policy->check_gc_overhead_limit(eden_live, |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
656 |
max_old_gen_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
657 |
max_eden_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
658 |
false /* not full gc*/, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
659 |
gc_cause, |
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
48168
diff
changeset
|
660 |
heap->soft_ref_policy()); |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
661 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
17112
diff
changeset
|
662 |
size_policy->decay_supplemental_growth(false /* not full gc*/); |
1 | 663 |
} |
664 |
// Resize the young generation at every collection |
|
665 |
// even if new sizes have not been calculated. This is |
|
666 |
// to allow resizes that may have been inhibited by the |
|
667 |
// relative location of the "to" and "from" spaces. |
|
668 |
||
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
31634
diff
changeset
|
669 |
// Resizing the old gen at young collections can cause increases |
1 | 670 |
// that don't feed back to the generation sizing policy until |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
31634
diff
changeset
|
671 |
// a full collection. Don't resize the old gen here. |
1 | 672 |
|
673 |
heap->resize_young_gen(size_policy->calculated_eden_size_in_bytes(), |
|
674 |
size_policy->calculated_survivor_size_in_bytes()); |
|
675 |
||
35061 | 676 |
log_debug(gc, ergo)("AdaptiveSizeStop: collection: %d ", heap->total_collections()); |
1 | 677 |
} |
678 |
||
679 |
// Update the structure of the eden. With NUMA-eden CPU hotplugging or offlining can |
|
680 |
// cause the change of the heap layout. Make sure eden is reshaped if that's the case. |
|
681 |
// Also update() will case adaptive NUMA chunk resizing. |
|
682 |
assert(young_gen->eden_space()->is_empty(), "eden space should be empty now"); |
|
683 |
young_gen->eden_space()->update(); |
|
684 |
||
685 |
heap->gc_policy_counters()->update_counters(); |
|
686 |
||
687 |
heap->resize_all_tlabs(); |
|
688 |
||
689 |
assert(young_gen->to_space()->is_empty(), "to space should be empty now"); |
|
690 |
} |
|
691 |
||
47799 | 692 |
#if COMPILER2_OR_JVMCI |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32623
diff
changeset
|
693 |
DerivedPointerTable::update_pointers(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32623
diff
changeset
|
694 |
#endif |
1 | 695 |
|
696 |
NOT_PRODUCT(reference_processor()->verify_no_references_recorded()); |
|
697 |
||
698 |
// Re-verify object start arrays |
|
699 |
if (VerifyObjectStartArray && |
|
700 |
VerifyAfterGC) { |
|
701 |
old_gen->verify_object_start_array(); |
|
702 |
} |
|
703 |
||
704 |
// Verify all old -> young cards are now precise |
|
705 |
if (VerifyRememberedSets) { |
|
706 |
// Precise verification will give false positives. Until this is fixed, |
|
707 |
// use imprecise verification. |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49047
diff
changeset
|
708 |
// heap->card_table()->verify_all_young_refs_precise(); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49047
diff
changeset
|
709 |
heap->card_table()->verify_all_young_refs_imprecise(); |
1 | 710 |
} |
711 |
||
47546
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
712 |
if (log_is_enabled(Debug, gc, heap, exit)) { |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
713 |
accumulated_time()->stop(); |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
714 |
} |
1 | 715 |
|
57662
f81dbe27a7b1
8227225: ParallelGC: add subspace transitions for young gen for gc+heap=info log lines
tonyp
parents:
55740
diff
changeset
|
716 |
heap->print_heap_change(pre_gc_values); |
1 | 717 |
|
718 |
// Track memory usage and detect low memory |
|
719 |
MemoryService::track_memory_usage(); |
|
720 |
heap->update_counters(); |
|
721 |
} |
|
722 |
||
723 |
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { |
|
724 |
HandleMark hm; // Discard invalid handles created during verification |
|
35061 | 725 |
Universe::verify("After GC"); |
1 | 726 |
} |
727 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11174
diff
changeset
|
728 |
heap->print_heap_after_gc(); |
18025 | 729 |
heap->trace_heap_after_gc(&_gc_tracer); |
1 | 730 |
|
731 |
scavenge_exit.update(); |
|
732 |
||
35061 | 733 |
log_debug(gc, task, time)("VM-Thread " JLONG_FORMAT " " JLONG_FORMAT " " JLONG_FORMAT, |
734 |
scavenge_entry.ticks(), scavenge_midpoint.ticks(), |
|
735 |
scavenge_exit.ticks()); |
|
1 | 736 |
|
2010
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1610
diff
changeset
|
737 |
#ifdef TRACESPINNING |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1610
diff
changeset
|
738 |
ParallelTaskTerminator::print_termination_counts(); |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1610
diff
changeset
|
739 |
#endif |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1610
diff
changeset
|
740 |
|
35061 | 741 |
AdaptiveSizePolicyOutput::print(size_policy, heap->total_collections()); |
18025 | 742 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
20317
diff
changeset
|
743 |
_gc_timer.register_gc_end(); |
18025 | 744 |
|
745 |
_gc_tracer.report_gc_end(_gc_timer.gc_end(), _gc_timer.time_partitions()); |
|
746 |
||
1 | 747 |
return !promotion_failure_occurred; |
748 |
} |
|
749 |
||
750 |
// This method iterates over all objects in the young generation, |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
36591
diff
changeset
|
751 |
// removing all forwarding references. It then restores any preserved marks. |
1 | 752 |
void PSScavenge::clean_up_failed_promotion() { |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
753 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 754 |
PSYoungGen* young_gen = heap->young_gen(); |
755 |
||
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
36591
diff
changeset
|
756 |
RemoveForwardedPointerClosure remove_fwd_ptr_closure; |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
36591
diff
changeset
|
757 |
young_gen->object_iterate(&remove_fwd_ptr_closure); |
1 | 758 |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
36591
diff
changeset
|
759 |
PSPromotionManager::restore_preserved_marks(); |
1 | 760 |
|
761 |
// Reset the PromotionFailureALot counters. |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
762 |
NOT_PRODUCT(heap->reset_promotion_should_fail();) |
1 | 763 |
} |
764 |
||
765 |
bool PSScavenge::should_attempt_scavenge() { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
766 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 767 |
PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters(); |
768 |
||
769 |
if (UsePerfData) { |
|
770 |
counters->update_scavenge_skipped(not_skipped); |
|
771 |
} |
|
772 |
||
773 |
PSYoungGen* young_gen = heap->young_gen(); |
|
774 |
PSOldGen* old_gen = heap->old_gen(); |
|
775 |
||
33227
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
776 |
// Do not attempt to promote unless to_space is empty |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
777 |
if (!young_gen->to_space()->is_empty()) { |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
778 |
_consecutive_skipped_scavenges++; |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
779 |
if (UsePerfData) { |
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
780 |
counters->update_scavenge_skipped(to_space_not_empty); |
1 | 781 |
} |
33227
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
33143
diff
changeset
|
782 |
return false; |
1 | 783 |
} |
784 |
||
785 |
// Test to see if the scavenge will likely fail. |
|
786 |
PSAdaptiveSizePolicy* policy = heap->size_policy(); |
|
787 |
||
788 |
// A similar test is done in the policy's should_full_GC(). If this is |
|
789 |
// changed, decide if that test should also be changed. |
|
790 |
size_t avg_promoted = (size_t) policy->padded_average_promoted_in_bytes(); |
|
791 |
size_t promotion_estimate = MIN2(avg_promoted, young_gen->used_in_bytes()); |
|
792 |
bool result = promotion_estimate < old_gen->free_in_bytes(); |
|
793 |
||
35061 | 794 |
log_trace(ergo)("%s scavenge: average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT, |
795 |
result ? "Do" : "Skip", (size_t) policy->average_promoted_in_bytes(), |
|
796 |
(size_t) policy->padded_average_promoted_in_bytes(), |
|
797 |
old_gen->free_in_bytes()); |
|
798 |
if (young_gen->used_in_bytes() < (size_t) policy->padded_average_promoted_in_bytes()) { |
|
799 |
log_trace(ergo)(" padded_promoted_average is greater than maximum promotion = " SIZE_FORMAT, young_gen->used_in_bytes()); |
|
1 | 800 |
} |
801 |
||
802 |
if (result) { |
|
803 |
_consecutive_skipped_scavenges = 0; |
|
804 |
} else { |
|
805 |
_consecutive_skipped_scavenges++; |
|
806 |
if (UsePerfData) { |
|
807 |
counters->update_scavenge_skipped(promoted_too_large); |
|
808 |
} |
|
809 |
} |
|
810 |
return result; |
|
811 |
} |
|
812 |
||
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
813 |
// Adaptive size policy support. When the young generation/old generation |
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
814 |
// boundary moves, _young_generation_boundary must be reset |
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
815 |
void PSScavenge::set_young_generation_boundary(HeapWord* v) { |
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
816 |
_young_generation_boundary = v; |
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
817 |
if (UseCompressedOops) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49389
diff
changeset
|
818 |
_young_generation_boundary_compressed = (uintptr_t)CompressedOops::encode((oop)v); |
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
819 |
} |
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
820 |
} |
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
35492
diff
changeset
|
821 |
|
1 | 822 |
void PSScavenge::initialize() { |
823 |
// Arguments must have been parsed |
|
824 |
||
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
22555
diff
changeset
|
825 |
if (AlwaysTenure || NeverTenure) { |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
57773
diff
changeset
|
826 |
assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markWord::max_age + 1, |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
57773
diff
changeset
|
827 |
"MaxTenuringThreshold should be 0 or markWord::max_age + 1, but is %d", (int) MaxTenuringThreshold); |
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
22555
diff
changeset
|
828 |
_tenuring_threshold = MaxTenuringThreshold; |
1 | 829 |
} else { |
830 |
// We want to smooth out our startup times for the AdaptiveSizePolicy |
|
831 |
_tenuring_threshold = (UseAdaptiveSizePolicy) ? InitialTenuringThreshold : |
|
832 |
MaxTenuringThreshold; |
|
833 |
} |
|
834 |
||
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29798
diff
changeset
|
835 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 836 |
PSYoungGen* young_gen = heap->young_gen(); |
837 |
PSOldGen* old_gen = heap->old_gen(); |
|
838 |
||
839 |
// Set boundary between young_gen and old_gen |
|
840 |
assert(old_gen->reserved().end() <= young_gen->eden_space()->bottom(), |
|
841 |
"old above young"); |
|
17852
59b05e1db547
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
17846
diff
changeset
|
842 |
set_young_generation_boundary(young_gen->eden_space()->bottom()); |
1 | 843 |
|
844 |
// Initialize ref handling object for scavenging. |
|
49964
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
845 |
_span_based_discoverer.set_span(young_gen->reserved()); |
8688
493d12ccc6db
6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents:
7658
diff
changeset
|
846 |
_ref_processor = |
49964
99e698e94cc7
8201492: Properly implement non-contiguous generations for Reference discovery
tschatzl
parents:
49594
diff
changeset
|
847 |
new ReferenceProcessor(&_span_based_discoverer, |
8688
493d12ccc6db
6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents:
7658
diff
changeset
|
848 |
ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing |
31330
77061bb01b18
8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents:
31032
diff
changeset
|
849 |
ParallelGCThreads, // mt processing degree |
8688
493d12ccc6db
6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents:
7658
diff
changeset
|
850 |
true, // mt discovery |
31330
77061bb01b18
8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents:
31032
diff
changeset
|
851 |
ParallelGCThreads, // mt discovery degree |
8688
493d12ccc6db
6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents:
7658
diff
changeset
|
852 |
true, // atomic_discovery |
50606
8f1d5d706bdd
8043575: Dynamically parallelize reference processing work
tschatzl
parents:
50605
diff
changeset
|
853 |
NULL, // header provides liveness info |
8f1d5d706bdd
8043575: Dynamically parallelize reference processing work
tschatzl
parents:
50605
diff
changeset
|
854 |
false); |
1 | 855 |
|
856 |
// Cache the cardtable |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49047
diff
changeset
|
857 |
_card_table = heap->card_table(); |
1 | 858 |
|
53726 | 859 |
_counters = new CollectorCounters("Parallel young collection pauses", 0); |
1 | 860 |
} |