1 /* 2 * Copyright (c) 2017, 2022, Oracle and/or its affiliates. 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 25 #ifndef SHARE_GC_G1_G1FULLGCOOPCLOSURES_HPP 26 #define SHARE_GC_G1_G1FULLGCOOPCLOSURES_HPP 27 28 #include "gc/shared/verifyOption.hpp" 29 #include "memory/iterator.hpp" 30 31 class G1CollectedHeap; 32 class G1FullCollector; 33 class G1CMBitMap; 34 class G1FullGCMarker; 35 36 // Below are closures used by the G1 Full GC. 37 class G1IsAliveClosure : public BoolObjectClosure { 38 G1FullCollector* _collector; 39 G1CMBitMap* _bitmap; 40 41 public: 42 G1IsAliveClosure(G1FullCollector* collector); 43 G1IsAliveClosure(G1FullCollector* collector, G1CMBitMap* bitmap) : 44 _collector(collector), _bitmap(bitmap) { } 45 46 virtual bool do_object_b(oop p); 47 }; 48 49 class G1FullKeepAliveClosure: public OopClosure { 50 G1FullGCMarker* _marker; 51 template <class T> 52 inline void do_oop_work(T* p); 53 54 public: 55 G1FullKeepAliveClosure(G1FullGCMarker* pm) : _marker(pm) { } 56 57 virtual void do_oop(oop* p); 58 virtual void do_oop(narrowOop* p); 59 }; 60 61 class G1MarkAndPushClosure : public ClaimMetadataVisitingOopIterateClosure { 62 G1FullGCMarker* _marker; 63 uint _worker_id; 64 65 public: 66 G1MarkAndPushClosure(uint worker_id, G1FullGCMarker* marker, int claim, ReferenceDiscoverer* ref) : 67 ClaimMetadataVisitingOopIterateClosure(claim, ref), 68 _marker(marker), 69 _worker_id(worker_id) { } 70 71 template <class T> inline void do_oop_work(T* p); 72 virtual void do_oop(oop* p); 73 virtual void do_oop(narrowOop* p); 74 }; 75 76 template <bool ALT_FWD> 77 class G1AdjustClosure : public BasicOopIterateClosure { 78 G1FullCollector* _collector; 79 80 template <class T> inline void adjust_pointer(T* p); 81 public: 82 G1AdjustClosure(G1FullCollector* collector) : _collector(collector) { } 83 template <class T> void do_oop_work(T* p) { adjust_pointer(p); } 84 virtual void do_oop(oop* p); 85 virtual void do_oop(narrowOop* p); 86 87 virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; } 88 }; 89 90 class G1FollowStackClosure: public VoidClosure { 91 G1FullGCMarker* _marker; 92 93 public: 94 G1FollowStackClosure(G1FullGCMarker* marker) : _marker(marker) {} 95 virtual void do_void(); 96 }; 97 98 #endif // SHARE_GC_G1_G1FULLGCOOPCLOSURES_HPP