1 /* 2 * Copyright (c) 2019, 2020, 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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP 24 #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP 25 26 #include "memory/iterator.hpp" 27 28 class ShenandoahHeap; 29 class ShenandoahMarkingContext; 30 class ShenandoahHeapRegionSet; 31 class Thread; 32 33 class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure { 34 private: 35 ShenandoahHeap* const _heap; 36 ShenandoahMarkingContext* const _mark_context; 37 public: 38 inline ShenandoahForwardedIsAliveClosure(); 39 inline bool do_object_b(oop obj); 40 }; 41 42 class ShenandoahForwardedIsAliveNoCSetCheckClosure: public BoolObjectClosure { 43 private: 44 ShenandoahMarkingContext* const _mark_context; 45 public: 46 inline ShenandoahForwardedIsAliveNoCSetCheckClosure(); 47 inline bool do_object_b(oop obj); 48 }; 49 50 51 class ShenandoahIsAliveClosure: public BoolObjectClosure { 52 private: 53 ShenandoahMarkingContext* const _mark_context; 54 public: 55 inline ShenandoahIsAliveClosure(); 56 inline bool do_object_b(oop obj); 57 }; 58 59 class ShenandoahIsAliveSelector : public StackObj { 60 private: 61 ShenandoahIsAliveClosure _alive_cl; 62 ShenandoahForwardedIsAliveClosure _fwd_alive_cl; 63 public: 64 inline BoolObjectClosure* is_alive_closure(); 65 }; 66 67 class ShenandoahUpdateRefsClosure: public OopClosure { 68 private: 69 ShenandoahHeap* _heap; 70 public: 71 inline ShenandoahUpdateRefsClosure(); 72 inline void do_oop(oop* p); 73 inline void do_oop(narrowOop* p); 74 private: 75 template <class T> 76 inline void do_oop_work(T* p); 77 }; 78 79 class ShenandoahTraversalUpdateRefsClosure: public OopClosure { 80 private: 81 ShenandoahHeap* const _heap; 82 ShenandoahHeapRegionSet* const _traversal_set; 83 84 public: 85 inline ShenandoahTraversalUpdateRefsClosure(); 86 inline void do_oop(oop* p); 87 inline void do_oop(narrowOop* p); 88 private: 89 template <class T> 90 inline void do_oop_work(T* p); 91 }; 92 93 class ShenandoahEvacuateUpdateRootsClosure: public BasicOopIterateClosure { 94 private: 95 ShenandoahHeap* _heap; 96 Thread* _thread; 97 public: 98 inline ShenandoahEvacuateUpdateRootsClosure(); 99 inline void do_oop(oop* p); 100 inline void do_oop(narrowOop* p); 101 102 private: 103 template <class T> 104 inline void do_oop_work(T* p); 105 }; 106 107 class ShenandoahEvacUpdateOopStorageRootsClosure : public BasicOopIterateClosure { 108 private: 109 ShenandoahHeap* _heap; 110 Thread* _thread; 111 public: 112 inline ShenandoahEvacUpdateOopStorageRootsClosure(); 113 inline void do_oop(oop* p); 114 inline void do_oop(narrowOop* p); 115 }; 116 117 class ShenandoahCodeBlobAndDisarmClosure: public CodeBlobToOopClosure { 118 private: 119 BarrierSetNMethod* const _bs; 120 121 public: 122 inline ShenandoahCodeBlobAndDisarmClosure(OopClosure* cl); 123 inline void do_code_blob(CodeBlob* cb); 124 }; 125 126 #ifdef ASSERT 127 class ShenandoahAssertNotForwardedClosure : public OopClosure { 128 private: 129 template <class T> 130 inline void do_oop_work(T* p); 131 132 public: 133 inline void do_oop(narrowOop* p); 134 inline void do_oop(oop* p); 135 }; 136 #endif // ASSERT 137 138 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP