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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "code/codeCache.hpp"
31 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
32 #include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
33 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
34 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
35 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
36 #include "gc/shenandoah/shenandoahStringDedup.hpp"
37 #include "gc/shenandoah/shenandoahVMOperations.hpp"
38 #include "jfr/jfr.hpp"
39 #include "memory/iterator.hpp"
40 #include "memory/resourceArea.hpp"
41 #include "memory/universe.hpp"
42 #include "runtime/thread.hpp"
43 #include "services/management.hpp"
44
45 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do,
46 ShenandoahPhaseTimings::Phase phase, ShenandoahPhaseTimings::ParPhase par_phase) :
47 _oops_do(oops_do), _phase(phase), _par_phase(par_phase) {
48 }
49
50 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
182 void ShenandoahCodeCacheRoots::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) {
183 ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
184 _coderoots_iterator.possibly_parallel_blobs_do(blob_cl);
185 }
186
187 ShenandoahCodeCacheRoots::~ShenandoahCodeCacheRoots() {
188 nmethod::oops_do_marking_epilogue();
189 }
190
191 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase) :
192 _heap(ShenandoahHeap::heap()),
193 _phase(phase),
194 _worker_phase(phase) {
195 assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
196 }
197
198 ShenandoahRootScanner::ShenandoahRootScanner(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
199 ShenandoahRootProcessor(phase),
200 _serial_roots(phase),
201 _thread_roots(phase, n_workers > 1),
202 _code_roots(phase),
203 _vm_roots(phase),
204 _dedup_roots(phase),
205 _cld_roots(phase) {
206 }
207
208 void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops) {
209 CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
210 MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
211 roots_do(worker_id, oops, &clds_cl, &blobs_cl);
212 }
213
214 void ShenandoahRootScanner::strong_roots_do(uint worker_id, OopClosure* oops) {
215 CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
216 MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
217 strong_roots_do(worker_id, oops, &clds_cl, &blobs_cl);
218 }
219
220 void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure *tc) {
221 assert(!ShenandoahSafepoint::is_at_shenandoah_safepoint() ||
222 !ShenandoahHeap::heap()->unload_classes(),
223 "Expect class unloading when Shenandoah cycle is running");
224 ResourceMark rm;
225
226 _serial_roots.oops_do(oops, worker_id);
227 _vm_roots.oops_do(oops, worker_id);
228
229 assert(clds != NULL, "Only possible with CLD closure");
230 _cld_roots.cld_do(clds, worker_id);
231
232 ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
233 _thread_roots.threads_do(&tc_cl, worker_id);
234
235 AlwaysTrueClosure always_true;
236 _dedup_roots.oops_do(&always_true, oops, worker_id);
237 }
238
239 void ShenandoahRootScanner::strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc) {
240 assert(ShenandoahHeap::heap()->unload_classes(), "Should be used during class unloading");
241 ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
242 ResourceMark rm;
243
244 _serial_roots.oops_do(oops, worker_id);
245 _vm_roots.oops_do(oops, worker_id);
246 _cld_roots.always_strong_cld_do(clds, worker_id);
247 _thread_roots.threads_do(&tc_cl, worker_id);
248 }
249
250 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers,
251 ShenandoahPhaseTimings::Phase phase,
252 bool stw_roots_processing,
253 bool stw_class_unloading) :
254 ShenandoahRootProcessor(phase),
255 _serial_roots(phase),
256 _vm_roots(phase),
257 _cld_roots(phase),
258 _thread_roots(phase, n_workers > 1),
259 _serial_weak_roots(phase),
260 _weak_roots(phase),
261 _dedup_roots(phase),
262 _code_roots(phase),
263 _stw_roots_processing(stw_roots_processing),
264 _stw_class_unloading(stw_class_unloading) {
265 }
266
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "code/codeCache.hpp"
31 #include "code/nmethod.hpp"
32 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
33 #include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
34 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
35 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
36 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
37 #include "gc/shenandoah/shenandoahStringDedup.hpp"
38 #include "gc/shenandoah/shenandoahVMOperations.hpp"
39 #include "jfr/jfr.hpp"
40 #include "memory/iterator.hpp"
41 #include "memory/resourceArea.hpp"
42 #include "memory/universe.hpp"
43 #include "runtime/thread.hpp"
44 #include "services/management.hpp"
45
46 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do,
47 ShenandoahPhaseTimings::Phase phase, ShenandoahPhaseTimings::ParPhase par_phase) :
48 _oops_do(oops_do), _phase(phase), _par_phase(par_phase) {
49 }
50
51 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
183 void ShenandoahCodeCacheRoots::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) {
184 ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
185 _coderoots_iterator.possibly_parallel_blobs_do(blob_cl);
186 }
187
188 ShenandoahCodeCacheRoots::~ShenandoahCodeCacheRoots() {
189 nmethod::oops_do_marking_epilogue();
190 }
191
192 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase) :
193 _heap(ShenandoahHeap::heap()),
194 _phase(phase),
195 _worker_phase(phase) {
196 assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
197 }
198
199 ShenandoahRootScanner::ShenandoahRootScanner(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
200 ShenandoahRootProcessor(phase),
201 _serial_roots(phase),
202 _thread_roots(phase, n_workers > 1),
203 _dedup_roots(phase) {
204 nmethod::oops_do_marking_prologue();
205 }
206
207 ShenandoahRootScanner::~ShenandoahRootScanner() {
208 nmethod::oops_do_marking_epilogue();
209 }
210
211 void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops) {
212 CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
213 MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
214 roots_do(worker_id, oops, &clds_cl, &blobs_cl);
215 }
216
217 void ShenandoahRootScanner::strong_roots_do(uint worker_id, OopClosure* oops) {
218 CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
219 MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
220 strong_roots_do(worker_id, oops, &clds_cl, &blobs_cl);
221 }
222
223 void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure *tc) {
224 assert(!ShenandoahSafepoint::is_at_shenandoah_safepoint() ||
225 !ShenandoahHeap::heap()->unload_classes(),
226 "Expect class unloading when Shenandoah cycle is running");
227 ResourceMark rm;
228
229 _serial_roots.oops_do(oops, worker_id);
230 ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
231 _thread_roots.threads_do(&tc_cl, worker_id);
232
233 AlwaysTrueClosure always_true;
234 _dedup_roots.oops_do(&always_true, oops, worker_id);
235 }
236
237 void ShenandoahRootScanner::strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc) {
238 assert(ShenandoahHeap::heap()->unload_classes(), "Should be used during class unloading");
239 ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
240 ResourceMark rm;
241
242 _serial_roots.oops_do(oops, worker_id);
243 _thread_roots.threads_do(&tc_cl, worker_id);
244 }
245
246 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers,
247 ShenandoahPhaseTimings::Phase phase,
248 bool stw_roots_processing,
249 bool stw_class_unloading) :
250 ShenandoahRootProcessor(phase),
251 _serial_roots(phase),
252 _vm_roots(phase),
253 _cld_roots(phase),
254 _thread_roots(phase, n_workers > 1),
255 _serial_weak_roots(phase),
256 _weak_roots(phase),
257 _dedup_roots(phase),
258 _code_roots(phase),
259 _stw_roots_processing(stw_roots_processing),
260 _stw_class_unloading(stw_class_unloading) {
261 }
262
|