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 "memory/sharedHeap.hpp" 30 #include "gc_implementation/shenandoah/shenandoahHeap.hpp" 31 #include "gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp" 32 #include "gc_implementation/shenandoah/shenandoahCodeRoots.hpp" 33 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp" 34 #include "memory/allocation.hpp" 35 #include "runtime/mutex.hpp" 36 37 class CLDClosure; 38 class CodeBlobClosure; 39 class G1CollectedHeap; 40 class G1GCPhaseTimes; 41 class G1ParPushHeapRSClosure; 42 class Monitor; 43 class OopClosure; 44 class SubTasksDone; 45 46 class ParallelCLDRootIterator VALUE_OBJ_CLASS_SPEC { 47 public: 48 ParallelCLDRootIterator(); 49 void root_cld_do(CLDClosure* strong, CLDClosure* weak); 50 }; 51 52 enum Shenandoah_process_roots_tasks { 53 SHENANDOAH_RP_PS_Universe_oops_do, 54 SHENANDOAH_RP_PS_JNIHandles_oops_do, 55 SHENANDOAH_RP_PS_JNIHandles_weak_oops_do, 56 SHENANDOAH_RP_PS_ObjectSynchronizer_oops_do, 57 SHENANDOAH_RP_PS_FlatProfiler_oops_do, 58 SHENANDOAH_RP_PS_Management_oops_do, 59 SHENANDOAH_RP_PS_SystemDictionary_oops_do, 60 SHENANDOAH_RP_PS_ClassLoaderDataGraph_oops_do, 61 SHENANDOAH_RP_PS_jvmti_oops_do, 62 SHENANDOAH_RP_PS_CodeCache_oops_do, 63 SHENANDOAH_RP_PS_ReferenceProcessor_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 SharedHeap::StrongRootsScope _srs; 71 ShenandoahPhaseTimings::Phase _phase; 72 ParallelCLDRootIterator _cld_iterator; 73 ShenandoahAllCodeRootsIterator _coderoots_all_iterator; 74 ParallelObjectSynchronizerIterator _om_iterator; 75 76 void process_java_roots(OopClosure* scan_non_heap_roots, 77 CLDClosure* thread_clds, 78 CLDClosure* scan_strong_clds, 79 CLDClosure* scan_weak_clds, 80 CodeBlobClosure* scan_strong_code, 81 uint worker_i); 82 83 void process_vm_roots(OopClosure* scan_non_heap_roots, 84 OopClosure* scan_non_heap_weak_roots, 85 OopClosure* weak_jni_roots, 86 uint worker_i); 87 88 public: 89 ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers, 90 ShenandoahPhaseTimings::Phase phase); 91 ~ShenandoahRootProcessor(); 92 93 // Apply oops, clds and blobs to all strongly reachable roots in the system 94 void process_strong_roots(OopClosure* oops, OopClosure* weak_oops, 95 CLDClosure* clds, 96 CLDClosure* weak_clds, 97 CodeBlobClosure* blobs, 98 ThreadClosure* thread_cl, 99 uint worker_id); 100 101 // Apply oops, clds and blobs to strongly and weakly reachable roots in the system 102 void process_all_roots(OopClosure* oops, OopClosure* weak_oops, 103 CLDClosure* clds, 104 CodeBlobClosure* blobs, 105 ThreadClosure* thread_cl, 106 uint worker_id); 107 108 // For slow debug/verification code 109 void process_all_roots_slow(OopClosure* oops); 110 111 // Number of worker threads used by the root processor. 112 uint n_workers() const; 113 }; 114 115 class ShenandoahRootEvacuator : public StackObj { 116 SharedHeap::StrongRootsScope _srs; 117 ShenandoahPhaseTimings::Phase _phase; 118 ShenandoahCsetCodeRootsIterator _coderoots_cset_iterator; 119 120 public: 121 ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers, 122 ShenandoahPhaseTimings::Phase phase); 123 ~ShenandoahRootEvacuator(); 124 125 void process_evacuate_roots(OopClosure* oops, 126 CodeBlobClosure* blobs, 127 uint worker_id); 128 129 // Number of worker threads used by the root processor. 130 uint n_workers() const; 131 }; 132 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP