1 /* 2 * Copyright (c) 2015, Red Hat, Inc. and/or its affiliates. 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_VM_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP 26 27 #include "classfile/classLoaderData.hpp" 28 #include "code/codeCache.hpp" 29 #include "gc/shenandoah/shenandoahHeap.hpp" 30 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" 31 #include "gc/shared/strongRootsScope.hpp" 32 #include "gc/shared/workgroup.hpp" 33 #include "memory/allocation.hpp" 34 #include "runtime/mutex.hpp" 35 36 class CLDClosure; 37 class CodeBlobClosure; 38 class G1CollectedHeap; 39 class G1GCPhaseTimes; 40 class G1ParPushHeapRSClosure; 41 class Monitor; 42 class OopClosure; 43 class SubTasksDone; 44 45 46 class ParallelCLDRootIterator VALUE_OBJ_CLASS_SPEC { 47 public: 48 ParallelCLDRootIterator(); 49 void root_cld_do(CLDClosure* strong, CLDClosure* weak); 50 }; 51 52 53 enum Shenandoah_process_roots_tasks { 54 SHENANDOAH_RP_PS_Universe_oops_do, 55 SHENANDOAH_RP_PS_JNIHandles_oops_do, 56 SHENANDOAH_RP_PS_JNIHandles_weak_oops_do, 57 SHENANDOAH_RP_PS_ObjectSynchronizer_oops_do, 58 SHENANDOAH_RP_PS_FlatProfiler_oops_do, 59 SHENANDOAH_RP_PS_Management_oops_do, 60 SHENANDOAH_RP_PS_SystemDictionary_oops_do, 61 SHENANDOAH_RP_PS_ClassLoaderDataGraph_oops_do, 62 SHENANDOAH_RP_PS_jvmti_oops_do, 63 SHENANDOAH_RP_PS_CodeCache_oops_do, 64 // Leave this one last. 65 SHENANDOAH_RP_PS_NumElements 66 }; 67 68 class ShenandoahRootProcessor : public StackObj { 69 SubTasksDone* _process_strong_tasks; 70 StrongRootsScope _srs; 71 ShenandoahCollectorPolicy::TimingPhase _phase; 72 ParallelCLDRootIterator _cld_iterator; 73 ParallelCodeCacheIterator _codecache_iterator; 74 ParallelObjectSynchronizerIterator _om_iterator; 75 76 void process_java_roots(OopClosure* scan_non_heap_roots, 77 CLDClosure* scan_strong_clds, 78 CLDClosure* scan_weak_clds, 79 CodeBlobClosure* scan_strong_code, 80 uint worker_i); 81 82 void process_vm_roots(OopClosure* scan_non_heap_roots, 83 OopClosure* scan_non_heap_weak_roots, 84 OopClosure* weak_jni_roots, 85 uint worker_i); 86 87 public: 88 ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers, 89 ShenandoahCollectorPolicy::TimingPhase phase); 90 ~ShenandoahRootProcessor(); 91 92 // Apply oops, clds and blobs to all strongly reachable roots in the system 93 void process_strong_roots(OopClosure* oops, OopClosure* weak_oops, 94 CLDClosure* clds, 95 CodeBlobClosure* blobs, 96 uint worker_id); 97 98 // Apply oops, clds and blobs to strongly and weakly reachable roots in the system 99 void process_all_roots(OopClosure* oops, OopClosure* weak_oops, 100 CLDClosure* clds, 101 CodeBlobClosure* blobs, 102 uint worker_id); 103 104 // Number of worker threads used by the root processor. 105 uint n_workers() const; 106 }; 107 108 class ShenandoahRootEvacuator : public StackObj { 109 SubTasksDone* _process_strong_tasks; 110 StrongRootsScope _srs; 111 ShenandoahCollectorPolicy::TimingPhase _phase; 112 ParallelCodeCacheIterator _codecache_iterator; 113 114 public: 115 ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers, 116 ShenandoahCollectorPolicy::TimingPhase phase); 117 ~ShenandoahRootEvacuator(); 118 119 void process_evacuate_roots(OopClosure* oops, 120 CodeBlobClosure* blobs, 121 uint worker_id); 122 123 // Number of worker threads used by the root processor. 124 uint n_workers() const; 125 }; 126 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP