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 "code/codeCache.hpp" 28 #include "gc/shared/oopStorageParState.hpp" 29 #include "gc/shenandoah/shenandoahCodeRoots.hpp" 30 #include "gc/shenandoah/shenandoahHeap.hpp" 31 #include "gc/shenandoah/shenandoahPhaseTimings.hpp" 32 #include "gc/shared/strongRootsScope.hpp" 33 #include "gc/shared/workgroup.hpp" 34 #include "memory/allocation.hpp" 35 #include "memory/iterator.hpp" 36 37 class ParallelCLDRootIterator { 38 public: 39 ParallelCLDRootIterator(); 40 void root_cld_do(CLDClosure* strong, CLDClosure* weak); 41 }; 42 43 enum Shenandoah_process_roots_tasks { 44 SHENANDOAH_RP_PS_Universe_oops_do, 45 SHENANDOAH_RP_PS_JNIHandles_oops_do, 46 SHENANDOAH_RP_PS_JNIHandles_weak_oops_do, 47 SHENANDOAH_RP_PS_ObjectSynchronizer_oops_do, 48 SHENANDOAH_RP_PS_Management_oops_do, 49 SHENANDOAH_RP_PS_SystemDictionary_oops_do, 50 SHENANDOAH_RP_PS_jvmti_oops_do, 51 // Leave this one last. 52 SHENANDOAH_RP_PS_NumElements 53 }; 54 55 class ShenandoahRootProcessor : public StackObj { 56 SubTasksDone* _process_strong_tasks; 57 StrongRootsScope _srs; 58 ShenandoahPhaseTimings::Phase _phase; 59 ParallelCLDRootIterator _cld_iterator; 60 ShenandoahAllCodeRootsIterator _coderoots_all_iterator; 61 CodeBlobClosure* _threads_nmethods_cl; 62 63 void process_java_roots(OopClosure* scan_non_heap_roots, 64 CLDClosure* scan_strong_clds, 65 CLDClosure* scan_weak_clds, 66 CodeBlobClosure* scan_strong_code, 67 ThreadClosure* thread_cl, 68 uint worker_i); 69 70 void process_vm_roots(OopClosure* scan_non_heap_roots, 71 OopClosure* scan_non_heap_weak_roots, 72 OopClosure* weak_jni_roots, 73 uint worker_i); 74 75 public: 76 ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers, 77 ShenandoahPhaseTimings::Phase phase); 78 ~ShenandoahRootProcessor(); 79 80 // Apply oops, clds and blobs to all strongly reachable roots in the system 81 void process_strong_roots(OopClosure* oops, OopClosure* weak_oops, 82 CLDClosure* clds, 83 CLDClosure* weak_clds, 84 CodeBlobClosure* blobs, 85 ThreadClosure* thread_cl, 86 uint worker_id); 87 88 // Apply oops, clds and blobs to strongly and weakly reachable roots in the system 89 void process_all_roots(OopClosure* oops, OopClosure* weak_oops, 90 CLDClosure* clds, 91 CodeBlobClosure* blobs, 92 ThreadClosure* thread_cl, 93 uint worker_id); 94 95 // For slow debug/verification code 96 void process_all_roots_slow(OopClosure* oops); 97 98 // Number of worker threads used by the root processor. 99 uint n_workers() const; 100 }; 101 102 class ShenandoahRootEvacuator : public StackObj { 103 StrongRootsScope _srs; 104 ShenandoahPhaseTimings::Phase _phase; 105 ShenandoahCsetCodeRootsIterator _coderoots_cset_iterator; 106 107 public: 108 ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers, 109 ShenandoahPhaseTimings::Phase phase); 110 ~ShenandoahRootEvacuator(); 111 112 void process_evacuate_roots(OopClosure* oops, 113 CodeBlobClosure* blobs, 114 uint worker_id); 115 116 // Number of worker threads used by the root processor. 117 uint n_workers() const; 118 }; 119 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP