1 /* 2 * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP 25 #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP 26 27 #include "memory/iterator.hpp" 28 #include "oops/accessDecorators.hpp" 29 #include "runtime/handshake.hpp" 30 31 class ShenandoahHeap; 32 class ShenandoahMarkingContext; 33 class ShenandoahHeapRegionSet; 34 class Thread; 35 36 class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure { 37 private: 38 ShenandoahMarkingContext* const _mark_context; 39 public: 40 inline ShenandoahForwardedIsAliveClosure(); 41 inline bool do_object_b(oop obj); 42 }; 43 44 class ShenandoahIsAliveClosure: public BoolObjectClosure { 45 private: 46 ShenandoahMarkingContext* const _mark_context; 47 public: 48 inline ShenandoahIsAliveClosure(); 49 inline bool do_object_b(oop obj); 50 }; 51 52 class ShenandoahIsAliveSelector : public StackObj { 53 private: 54 ShenandoahIsAliveClosure _alive_cl; 55 ShenandoahForwardedIsAliveClosure _fwd_alive_cl; 56 public: 57 inline BoolObjectClosure* is_alive_closure(); 58 }; 59 60 class ShenandoahUpdateRefsClosure: public OopClosure { 61 private: 62 ShenandoahHeap* _heap; 63 public: 64 inline ShenandoahUpdateRefsClosure(); 65 inline void do_oop(oop* p); 66 inline void do_oop(narrowOop* p); 67 private: 68 template <class T> 69 inline void do_oop_work(T* p); 70 }; 71 72 template <DecoratorSet MO = MO_UNORDERED> 73 class ShenandoahEvacuateUpdateRootsClosure: public BasicOopIterateClosure { 74 private: 75 ShenandoahHeap* _heap; 76 Thread* _thread; 77 public: 78 inline ShenandoahEvacuateUpdateRootsClosure(); 79 inline void do_oop(oop* p); 80 inline void do_oop(narrowOop* p); 81 82 private: 83 template <class T> 84 inline void do_oop_work(T* p); 85 }; 86 87 class ShenandoahEvacUpdateOopStorageRootsClosure : public BasicOopIterateClosure { 88 private: 89 ShenandoahHeap* _heap; 90 Thread* _thread; 91 public: 92 inline ShenandoahEvacUpdateOopStorageRootsClosure(); 93 inline void do_oop(oop* p); 94 inline void do_oop(narrowOop* p); 95 }; 96 97 template <bool CONCURRENT, typename IsAlive, typename KeepAlive> 98 class ShenandoahCleanUpdateWeakOopsClosure : public OopClosure { 99 private: 100 IsAlive* _is_alive; 101 KeepAlive* _keep_alive; 102 103 public: 104 inline ShenandoahCleanUpdateWeakOopsClosure(IsAlive* is_alive, KeepAlive* keep_alive); 105 inline void do_oop(oop* p); 106 inline void do_oop(narrowOop* p); 107 }; 108 109 class ShenandoahCodeBlobAndDisarmClosure: public CodeBlobToOopClosure { 110 private: 111 BarrierSetNMethod* const _bs; 112 113 public: 114 inline ShenandoahCodeBlobAndDisarmClosure(OopClosure* cl); 115 inline void do_code_blob(CodeBlob* cb); 116 }; 117 118 class ShenandoahRendezvousClosure : public HandshakeClosure { 119 public: 120 inline ShenandoahRendezvousClosure(); 121 inline void do_thread(Thread* thread); 122 }; 123 124 #ifdef ASSERT 125 class ShenandoahAssertNotForwardedClosure : public OopClosure { 126 private: 127 template <class T> 128 inline void do_oop_work(T* p); 129 130 public: 131 inline void do_oop(narrowOop* p); 132 inline void do_oop(oop* p); 133 }; 134 #endif // ASSERT 135 136 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP 137