author | kbarrett |
Thu, 18 Jul 2019 14:57:32 -0400 | |
changeset 55740 | b3ff56f955c8 |
parent 54669 | ad45b3802d4e |
child 57767 | b3e44e1b135d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54122
diff
changeset
|
2 |
* Copyright (c) 2005, 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:
5076
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5076
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:
5076
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
42650 | 26 |
#include "aot/aotLoader.hpp" |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51470
diff
changeset
|
27 |
#include "classfile/classLoaderDataGraph.hpp" |
7397 | 28 |
#include "classfile/systemDictionary.hpp" |
29 |
#include "code/codeCache.hpp" |
|
30764 | 30 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
31 |
#include "gc/parallel/pcTasks.hpp" |
|
32 |
#include "gc/parallel/psCompactionManager.inline.hpp" |
|
46502
116a09d8f142
8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents:
42650
diff
changeset
|
33 |
#include "gc/parallel/psParallelCompact.inline.hpp" |
30764 | 34 |
#include "gc/shared/collectedHeap.hpp" |
35 |
#include "gc/shared/gcTimer.hpp" |
|
35061 | 36 |
#include "gc/shared/gcTraceTime.inline.hpp" |
37 |
#include "logging/log.hpp" |
|
52118
49f627781c2a
8211446: Replace oop_pc_follow_contents with oop_iterate and closure
lkorinth
parents:
51959
diff
changeset
|
38 |
#include "memory/iterator.inline.hpp" |
37248 | 39 |
#include "memory/resourceArea.hpp" |
7397 | 40 |
#include "memory/universe.hpp" |
41 |
#include "oops/objArrayKlass.inline.hpp" |
|
42 |
#include "oops/oop.inline.hpp" |
|
43 |
#include "prims/jvmtiExport.hpp" |
|
44 |
#include "runtime/jniHandles.hpp" |
|
45 |
#include "runtime/thread.hpp" |
|
46 |
#include "runtime/vmThread.hpp" |
|
47 |
#include "services/management.hpp" |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29798
diff
changeset
|
48 |
#include "utilities/stack.inline.hpp" |
1 | 49 |
|
50 |
// |
|
51 |
// ThreadRootsMarkingTask |
|
52 |
// |
|
53 |
||
54 |
void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
55 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
1 | 56 |
|
57 |
ResourceMark rm; |
|
58 |
||
59 |
ParCompactionManager* cm = |
|
60 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
14582
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13952
diff
changeset
|
61 |
|
52118
49f627781c2a
8211446: Replace oop_pc_follow_contents with oop_iterate and closure
lkorinth
parents:
51959
diff
changeset
|
62 |
PCMarkAndPushClosure mark_and_push_closure(cm); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
63 |
MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations); |
1 | 64 |
|
50058
f7e564cacfbc
8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents:
47580
diff
changeset
|
65 |
_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs); |
1 | 66 |
|
67 |
// Do the real work |
|
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
68 |
cm->follow_marking_stacks(); |
1 | 69 |
} |
70 |
||
71 |
||
72 |
void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
73 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
1 | 74 |
|
75 |
ParCompactionManager* cm = |
|
76 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
52118
49f627781c2a
8211446: Replace oop_pc_follow_contents with oop_iterate and closure
lkorinth
parents:
51959
diff
changeset
|
77 |
PCMarkAndPushClosure mark_and_push_closure(cm); |
1 | 78 |
|
79 |
switch (_root_type) { |
|
80 |
case universe: |
|
81 |
Universe::oops_do(&mark_and_push_closure); |
|
82 |
break; |
|
83 |
||
84 |
case jni_handles: |
|
85 |
JNIHandles::oops_do(&mark_and_push_closure); |
|
86 |
break; |
|
87 |
||
88 |
case threads: |
|
89 |
{ |
|
90 |
ResourceMark rm; |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
91 |
MarkingCodeBlobClosure each_active_code_blob(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations); |
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
37260
diff
changeset
|
92 |
Threads::oops_do(&mark_and_push_closure, &each_active_code_blob); |
1 | 93 |
} |
94 |
break; |
|
95 |
||
96 |
case object_synchronizer: |
|
97 |
ObjectSynchronizer::oops_do(&mark_and_push_closure); |
|
98 |
break; |
|
99 |
||
100 |
case management: |
|
101 |
Management::oops_do(&mark_and_push_closure); |
|
102 |
break; |
|
103 |
||
104 |
case jvmti: |
|
105 |
JvmtiExport::oops_do(&mark_and_push_closure); |
|
106 |
break; |
|
107 |
||
108 |
case system_dictionary: |
|
50297
580744d900c8
8202813: Move vm_weak processing from SystemDictionary to WeakProcessor
coleenp
parents:
50071
diff
changeset
|
109 |
SystemDictionary::oops_do(&mark_and_push_closure); |
17844
28ca9179db98
8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents:
17370
diff
changeset
|
110 |
break; |
28ca9179db98
8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents:
17370
diff
changeset
|
111 |
|
51470
84d3126858d5
8209738: Remove ClassLoaderDataGraph::*oops_do functions
coleenp
parents:
51292
diff
changeset
|
112 |
case class_loader_data: { |
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
52118
diff
changeset
|
113 |
CLDToOopClosure cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_strong); |
51470
84d3126858d5
8209738: Remove ClassLoaderDataGraph::*oops_do functions
coleenp
parents:
51292
diff
changeset
|
114 |
ClassLoaderDataGraph::always_strong_cld_do(&cld_closure); |
84d3126858d5
8209738: Remove ClassLoaderDataGraph::*oops_do functions
coleenp
parents:
51292
diff
changeset
|
115 |
} |
1 | 116 |
break; |
117 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
118 |
case code_cache: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
119 |
// Do not treat nmethods as strong roots for mark/sweep, since we can unload them. |
54122
4b1426ed1c44
8220343: Move scavenge_root_nmethods from shared code
stefank
parents:
52905
diff
changeset
|
120 |
//ScavengableNMethods::scavengable_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure)); |
42650 | 121 |
AOTLoader::oops_do(&mark_and_push_closure); |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
122 |
break; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1407
diff
changeset
|
123 |
|
1 | 124 |
default: |
125 |
fatal("Unknown root type"); |
|
126 |
} |
|
127 |
||
128 |
// Do the real work |
|
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
129 |
cm->follow_marking_stacks(); |
1 | 130 |
} |
131 |
||
132 |
||
133 |
// |
|
134 |
// RefProcTaskProxy |
|
135 |
// |
|
136 |
||
137 |
void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which) |
|
138 |
{ |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
139 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
1 | 140 |
|
141 |
ParCompactionManager* cm = |
|
142 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
52118
49f627781c2a
8211446: Replace oop_pc_follow_contents with oop_iterate and closure
lkorinth
parents:
51959
diff
changeset
|
143 |
PCMarkAndPushClosure mark_and_push_closure(cm); |
30556
750fee2bdb45
8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents:
30173
diff
changeset
|
144 |
ParCompactionManager::FollowStackClosure follow_stack_closure(cm); |
1 | 145 |
_rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(), |
146 |
mark_and_push_closure, follow_stack_closure); |
|
147 |
} |
|
148 |
||
149 |
// |
|
150 |
// RefProcTaskExecutor |
|
151 |
// |
|
152 |
||
50606
8f1d5d706bdd
8043575: Dynamically parallelize reference processing work
tschatzl
parents:
50501
diff
changeset
|
153 |
void RefProcTaskExecutor::execute(ProcessTask& task, uint ergo_workers) |
1 | 154 |
{ |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
155 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
11174
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
156 |
uint active_gc_threads = heap->gc_task_manager()->active_workers(); |
50606
8f1d5d706bdd
8043575: Dynamically parallelize reference processing work
tschatzl
parents:
50501
diff
changeset
|
157 |
assert(active_gc_threads == ergo_workers, |
8f1d5d706bdd
8043575: Dynamically parallelize reference processing work
tschatzl
parents:
50501
diff
changeset
|
158 |
"Ergonomically chosen workers (%u) must be equal to active workers (%u)", |
8f1d5d706bdd
8043575: Dynamically parallelize reference processing work
tschatzl
parents:
50501
diff
changeset
|
159 |
ergo_workers, active_gc_threads); |
37260
664b7520c44b
8153176: ParOldGC: Use correct TaskQueueSet for ParallelTaskTerminator in marking.
mgerdin
parents:
37248
diff
changeset
|
160 |
OopTaskQueueSet* qset = ParCompactionManager::stack_array(); |
52905
bec57b4a6d69
8204947: Port ShenandoahTaskTerminator to mainline and make it default
zgu
parents:
52141
diff
changeset
|
161 |
TaskTerminator terminator(active_gc_threads, qset); |
bec57b4a6d69
8204947: Port ShenandoahTaskTerminator to mainline and make it default
zgu
parents:
52141
diff
changeset
|
162 |
|
1 | 163 |
GCTaskQueue* q = GCTaskQueue::create(); |
50501
3787e9158925
8204618: The parallel GC reference processing task executor enqueues a wrong number of tasks into the queue
tschatzl
parents:
50297
diff
changeset
|
164 |
for(uint i=0; i<active_gc_threads; i++) { |
1 | 165 |
q->enqueue(new RefProcTaskProxy(task, i)); |
166 |
} |
|
50501
3787e9158925
8204618: The parallel GC reference processing task executor enqueues a wrong number of tasks into the queue
tschatzl
parents:
50297
diff
changeset
|
167 |
if (task.marks_oops_alive() && (active_gc_threads>1)) { |
3787e9158925
8204618: The parallel GC reference processing task executor enqueues a wrong number of tasks into the queue
tschatzl
parents:
50297
diff
changeset
|
168 |
for (uint j=0; j<active_gc_threads; j++) { |
52905
bec57b4a6d69
8204947: Port ShenandoahTaskTerminator to mainline and make it default
zgu
parents:
52141
diff
changeset
|
169 |
q->enqueue(new StealMarkingTask(terminator.terminator())); |
1 | 170 |
} |
171 |
} |
|
172 |
PSParallelCompact::gc_task_manager()->execute_and_wait(q); |
|
173 |
} |
|
174 |
||
175 |
// |
|
176 |
// StealMarkingTask |
|
177 |
// |
|
178 |
||
179 |
StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) : |
|
180 |
_terminator(t) {} |
|
181 |
||
182 |
void StealMarkingTask::do_it(GCTaskManager* manager, uint which) { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
183 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
1 | 184 |
|
185 |
ParCompactionManager* cm = |
|
186 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
187 |
||
188 |
oop obj = NULL; |
|
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
189 |
ObjArrayTask task; |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
190 |
do { |
51292
0538a5cdb474
8205921: Optimizing best-of-2 work stealing queue selection
zgu
parents:
50606
diff
changeset
|
191 |
while (ParCompactionManager::steal_objarray(which, task)) { |
52118
49f627781c2a
8211446: Replace oop_pc_follow_contents with oop_iterate and closure
lkorinth
parents:
51959
diff
changeset
|
192 |
cm->follow_array((objArrayOop)task.obj(), task.index()); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
193 |
cm->follow_marking_stacks(); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
194 |
} |
51292
0538a5cdb474
8205921: Optimizing best-of-2 work stealing queue selection
zgu
parents:
50606
diff
changeset
|
195 |
while (ParCompactionManager::steal(which, obj)) { |
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29701
diff
changeset
|
196 |
cm->follow_contents(obj); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
197 |
cm->follow_marking_stacks(); |
1 | 198 |
} |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
199 |
} while (!terminator()->offer_termination()); |
1 | 200 |
} |
201 |
||
202 |
// |
|
38250
37d739fb07fc
8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task.
jmasa
parents:
38170
diff
changeset
|
203 |
// CompactionWithStealingTask |
1 | 204 |
// |
205 |
||
38250
37d739fb07fc
8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task.
jmasa
parents:
38170
diff
changeset
|
206 |
CompactionWithStealingTask::CompactionWithStealingTask(ParallelTaskTerminator* t): |
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
207 |
_terminator(t) {} |
1 | 208 |
|
38250
37d739fb07fc
8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task.
jmasa
parents:
38170
diff
changeset
|
209 |
void CompactionWithStealingTask::do_it(GCTaskManager* manager, uint which) { |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
210 |
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); |
1 | 211 |
|
212 |
ParCompactionManager* cm = |
|
213 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
214 |
||
38170
ff88a25a7799
8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents:
38074
diff
changeset
|
215 |
// Drain the stacks that have been preloaded with regions |
ff88a25a7799
8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents:
38074
diff
changeset
|
216 |
// that are ready to fill. |
1 | 217 |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
218 |
cm->drain_region_stacks(); |
1 | 219 |
|
38170
ff88a25a7799
8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents:
38074
diff
changeset
|
220 |
guarantee(cm->region_stack()->is_empty(), "Not empty"); |
ff88a25a7799
8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents:
38074
diff
changeset
|
221 |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
222 |
size_t region_index = 0; |
1 | 223 |
|
224 |
while(true) { |
|
51292
0538a5cdb474
8205921: Optimizing best-of-2 work stealing queue selection
zgu
parents:
50606
diff
changeset
|
225 |
if (ParCompactionManager::steal(which, region_index)) { |
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
226 |
PSParallelCompact::fill_and_update_region(cm, region_index); |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
227 |
cm->drain_region_stacks(); |
1 | 228 |
} else { |
229 |
if (terminator()->offer_termination()) { |
|
230 |
break; |
|
231 |
} |
|
232 |
// Go around again. |
|
233 |
} |
|
234 |
} |
|
235 |
return; |
|
236 |
} |
|
237 |
||
238 |
UpdateDensePrefixTask::UpdateDensePrefixTask( |
|
239 |
PSParallelCompact::SpaceId space_id, |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
240 |
size_t region_index_start, |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
241 |
size_t region_index_end) : |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
242 |
_space_id(space_id), _region_index_start(region_index_start), |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
243 |
_region_index_end(region_index_end) {} |
1 | 244 |
|
245 |
void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { |
|
246 |
||
247 |
ParCompactionManager* cm = |
|
248 |
ParCompactionManager::gc_thread_compaction_manager(which); |
|
249 |
||
250 |
PSParallelCompact::update_and_deadwood_in_dense_prefix(cm, |
|
251 |
_space_id, |
|
1407
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
252 |
_region_index_start, |
9006b01ba3fd
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
670
diff
changeset
|
253 |
_region_index_end); |
1 | 254 |
} |