1 /* 2 * Copyright (c) 2019, Red Hat, Inc. All rights reserved. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP 25 #define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP 26 27 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp" 28 #include "gc_implementation/shenandoah/shenandoahRootProcessor.hpp" 29 #include "gc_implementation/shenandoah/shenandoahUtils.hpp" 30 #include "memory/resourceArea.hpp" 31 #include "runtime/safepoint.hpp" 32 33 template <typename ITR> 34 ShenandoahCodeCacheRoots<ITR>::ShenandoahCodeCacheRoots(ShenandoahPhaseTimings::Phase phase) : 35 _phase(phase) 36 {} 37 38 template <typename ITR> 39 void ShenandoahCodeCacheRoots<ITR>::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) { 40 ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CodeCacheRoots, worker_id); 41 _coderoots_iterator.possibly_parallel_blobs_do(blob_cl); 42 } 43 44 template <typename ITR> 45 ShenandoahRootScanner<ITR>::ShenandoahRootScanner(ShenandoahPhaseTimings::Phase phase) : 46 ShenandoahRootProcessor(phase), 47 _serial_roots(phase), 48 _dict_roots(phase), 49 _cld_roots(phase), 50 _thread_roots(phase), 51 _weak_roots(phase), 52 _dedup_roots(phase), 53 _string_table_roots(phase), 54 _code_roots(phase) 55 { } 56 57 template <typename ITR> 58 void ShenandoahRootScanner<ITR>::roots_do(uint worker_id, OopClosure* oops) { 59 CLDToOopClosure clds_cl(oops); 60 MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations); 61 roots_do(worker_id, oops, &clds_cl, &blobs_cl); 62 } 63 64 template <typename ITR> 65 void ShenandoahRootScanner<ITR>::strong_roots_do(uint worker_id, OopClosure* oops) { 66 CLDToOopClosure clds_cl(oops); 67 MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations); 68 strong_roots_do(worker_id, oops, &clds_cl, &blobs_cl); 69 } 70 71 template <typename ITR> 72 void ShenandoahRootScanner<ITR>::roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code) { 73 assert(!ShenandoahHeap::heap()->unload_classes(), 74 "No class unloading"); 75 ResourceMark rm; 76 _serial_roots.oops_do(oops, worker_id); 77 _dict_roots.oops_do(oops, worker_id); 78 _thread_roots.oops_do(oops, clds, code, worker_id); 79 _cld_roots.cld_do(clds, worker_id); 80 _weak_roots.oops_do(oops, worker_id); 81 _string_table_roots.oops_do(oops, worker_id); 82 _dedup_roots.oops_do(oops, worker_id); 83 } 84 85 template <typename ITR> 86 void ShenandoahRootScanner<ITR>::strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code) { 87 assert(ShenandoahHeap::heap()->unload_classes(), "Should be used during class unloading"); 88 ResourceMark rm; 89 AlwaysTrueClosure always_true; 90 91 _serial_roots.oops_do(oops, worker_id); 92 _dict_roots.strong_oops_do(oops, worker_id); 93 _cld_roots.always_strong_cld_do(clds, worker_id); 94 _thread_roots.oops_do(oops, clds, code, worker_id); 95 } 96 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP