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 BarrierSetNMethod; 32 class ShenandoahBarrierSet; 33 class ShenandoahHeap; 34 class ShenandoahMarkingContext; 35 class ShenandoahHeapRegionSet; 36 class Thread; 37 38 class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure { 39 private: 40 ShenandoahMarkingContext* const _mark_context; 41 public: 42 inline ShenandoahForwardedIsAliveClosure(); 43 inline bool do_object_b(oop obj); 44 }; 45 46 class ShenandoahIsAliveClosure: public BoolObjectClosure { 47 private: 48 ShenandoahMarkingContext* const _mark_context; 49 public: 50 inline ShenandoahIsAliveClosure(); 51 inline bool do_object_b(oop obj); 52 }; 53 54 class ShenandoahIsAliveSelector : public StackObj { 55 private: 56 ShenandoahIsAliveClosure _alive_cl; 57 ShenandoahForwardedIsAliveClosure _fwd_alive_cl; 58 public: 59 inline BoolObjectClosure* is_alive_closure(); 60 }; 61 62 class ShenandoahKeepAliveClosure : public OopClosure { 63 private: 64 ShenandoahBarrierSet* const _bs; 65 public: 66 inline ShenandoahKeepAliveClosure(); 67 inline void do_oop(oop* p); 68 inline void do_oop(narrowOop* p); 69 private: 70 template <typename T> 71 void do_oop_work(T* p); 72 }; 73 74 class ShenandoahUpdateRefsClosure: public OopClosure { 75 private: 76 ShenandoahHeap* _heap; 77 public: 78 inline ShenandoahUpdateRefsClosure(); 79 inline void do_oop(oop* p); 80 inline void do_oop(narrowOop* p); 81 private: 82 template <class T> 83 inline void do_oop_work(T* p); 84 }; 85 86 template <DecoratorSet MO = MO_UNORDERED> 87 class ShenandoahEvacuateUpdateMetadataClosure: public BasicOopIterateClosure { 88 private: 89 ShenandoahHeap* const _heap; 90 Thread* const _thread; 91 public: 92 inline ShenandoahEvacuateUpdateMetadataClosure(); 93 inline void do_oop(oop* p); 94 inline void do_oop(narrowOop* p); 95 96 private: 97 template <class T> 98 inline void do_oop_work(T* p); 99 }; 100 101 // Context free version, cannot cache calling thread 102 class ShenandoahEvacuateUpdateRootsClosure : public BasicOopIterateClosure { 103 private: 104 ShenandoahHeap* const _heap; 105 public: 106 inline ShenandoahEvacuateUpdateRootsClosure(); 107 inline void do_oop(oop* p); 108 inline void do_oop(narrowOop* p); 109 protected: 110 template <typename T> 111 inline void do_oop_work(T* p, Thread* thr); 112 }; 113 114 class ShenandoahContextEvacuateUpdateRootsClosure : public ShenandoahEvacuateUpdateRootsClosure { 115 private: 116 Thread* const _thread; 117 public: 118 inline ShenandoahContextEvacuateUpdateRootsClosure(); 119 inline void do_oop(oop* p); 120 inline void do_oop(narrowOop* p); 121 }; 122 123 template <bool CONCURRENT, typename IsAlive, typename KeepAlive> 124 class ShenandoahCleanUpdateWeakOopsClosure : public OopClosure { 125 private: 126 IsAlive* _is_alive; 127 KeepAlive* _keep_alive; 128 129 public: 130 inline ShenandoahCleanUpdateWeakOopsClosure(IsAlive* is_alive, KeepAlive* keep_alive); 131 inline void do_oop(oop* p); 132 inline void do_oop(narrowOop* p); 133 }; 134 135 class ShenandoahCodeBlobAndDisarmClosure: public CodeBlobToOopClosure { 136 private: 137 BarrierSetNMethod* const _bs; 138 139 public: 140 inline ShenandoahCodeBlobAndDisarmClosure(OopClosure* cl); 141 inline void do_code_blob(CodeBlob* cb); 142 }; 143 144 #ifdef ASSERT 145 class ShenandoahAssertNotForwardedClosure : public OopClosure { 146 private: 147 template <class T> 148 inline void do_oop_work(T* p); 149 150 public: 151 inline void do_oop(narrowOop* p); 152 inline void do_oop(oop* p); 153 }; 154 #endif // ASSERT 155 156 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP 157