< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp

Print this page

  1 /*
  2  * Copyright (c) 2015, 2022, 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 
 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP
 27 
 28 #include "gc/shared/stringdedup/stringDedup.hpp"
 29 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
 30 #include "gc/shenandoah/shenandoahGenerationType.hpp"
 31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 32 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
 33 #include "gc/shenandoah/shenandoahUtils.hpp"
 34 #include "memory/iterator.hpp"
 35 #include "runtime/javaThread.hpp"
 36 
 37 class ShenandoahMarkRefsSuperClosure : public MetadataVisitingOopIterateClosure {
 38 private:
 39   ShenandoahObjToScanQueue* _queue;

 40   ShenandoahMarkingContext* const _mark_context;
 41   bool _weak;
 42 
 43 protected:
 44   template <class T, ShenandoahGenerationType GENERATION>
 45   void work(T *p);
 46 
 47 public:
 48   ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp);
 49 
 50   bool is_weak() const {
 51     return _weak;
 52   }
 53 
 54   void set_weak(bool weak) {
 55     _weak = weak;
 56   }
 57 
 58   virtual void do_nmethod(nmethod* nm) {
 59     assert(!is_weak(), "Can't handle weak marking of nmethods");
 60     nm->run_nmethod_entry_barrier();
 61   }
 62 };
 63 
 64 class ShenandoahMarkUpdateRefsSuperClosure : public ShenandoahMarkRefsSuperClosure {
 65 protected:
 66   ShenandoahHeap* const _heap;
 67 
 68   template <class T, ShenandoahGenerationType GENERATION>
 69   inline void work(T* p);
 70 
 71 public:
 72   ShenandoahMarkUpdateRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
 73     ShenandoahMarkRefsSuperClosure(q, rp),
 74     _heap(ShenandoahHeap::heap()) {
 75     assert(_heap->is_stw_gc_in_progress(), "Can only be used for STW GC");
 76   };
 77 };
 78 
 79 template <ShenandoahGenerationType GENERATION>
 80 class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkUpdateRefsSuperClosure {
 81 private:
 82   template <class T>
 83   inline void do_oop_work(T* p)     { work<T, GENERATION>(p); }
 84 
 85 public:
 86   ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
 87     ShenandoahMarkUpdateRefsSuperClosure(q, rp) {}
 88 
 89   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 90   virtual void do_oop(oop* p)       { do_oop_work(p); }
 91 };
 92 
 93 template <ShenandoahGenerationType GENERATION>
 94 class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure {
 95 private:
 96   template <class T>
 97   inline void do_oop_work(T* p)     { work<T, GENERATION>(p); }
 98 
 99 public:
100   ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
101     ShenandoahMarkRefsSuperClosure(q, rp) {};
102 
103   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
104   virtual void do_oop(oop* p)       { do_oop_work(p); }
105 };
106 
107 
108 class ShenandoahUpdateRefsSuperClosure : public ShenandoahOopClosureBase {
109 protected:
110   ShenandoahHeap* _heap;
111 
112 public:
113   ShenandoahUpdateRefsSuperClosure() :  _heap(ShenandoahHeap::heap()) {}
114 };
115 
116 class ShenandoahSTWUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure {
117 private:
118   template<class T>
119   inline void work(T* p);
120 
121 public:
122   ShenandoahSTWUpdateRefsClosure() : ShenandoahUpdateRefsSuperClosure() {
123     assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must only be used at safepoints");
124   }
125 
126   virtual void do_oop(narrowOop* p) { work(p); }
127   virtual void do_oop(oop* p)       { work(p); }

  1 /*
  2  * Copyright (c) 2015, 2022, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP
 27 #define SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP
 28 
 29 #include "gc/shared/stringdedup/stringDedup.hpp"
 30 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
 31 #include "gc/shenandoah/shenandoahGenerationType.hpp"
 32 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 33 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
 34 #include "gc/shenandoah/shenandoahUtils.hpp"
 35 #include "memory/iterator.hpp"
 36 #include "runtime/javaThread.hpp"
 37 
 38 class ShenandoahMarkRefsSuperClosure : public MetadataVisitingOopIterateClosure {
 39 private:
 40   ShenandoahObjToScanQueue* _queue;
 41   ShenandoahObjToScanQueue* _old_queue;
 42   ShenandoahMarkingContext* const _mark_context;
 43   bool _weak;
 44 
 45 protected:
 46   template <class T, ShenandoahGenerationType GENERATION>
 47   void work(T *p);
 48 
 49 public:
 50   ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old_q);
 51 
 52   bool is_weak() const {
 53     return _weak;
 54   }
 55 
 56   void set_weak(bool weak) {
 57     _weak = weak;
 58   }
 59 
 60   virtual void do_nmethod(nmethod* nm) {
 61     assert(!is_weak(), "Can't handle weak marking of nmethods");
 62     nm->run_nmethod_entry_barrier();
 63   }
 64 };
 65 
 66 class ShenandoahMarkUpdateRefsSuperClosure : public ShenandoahMarkRefsSuperClosure {
 67 protected:
 68   ShenandoahHeap* const _heap;
 69 
 70   template <class T, ShenandoahGenerationType GENERATION>
 71   inline void work(T* p);
 72 
 73 public:
 74   ShenandoahMarkUpdateRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old_q) :
 75     ShenandoahMarkRefsSuperClosure(q, rp, old_q),
 76     _heap(ShenandoahHeap::heap()) {
 77     assert(_heap->is_stw_gc_in_progress(), "Can only be used for STW GC");
 78   };
 79 };
 80 
 81 template <ShenandoahGenerationType GENERATION>
 82 class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkUpdateRefsSuperClosure {
 83 private:
 84   template <class T>
 85   inline void do_oop_work(T* p)     { work<T, GENERATION>(p); }
 86 
 87 public:
 88   ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old_q) :
 89     ShenandoahMarkUpdateRefsSuperClosure(q, rp, old_q) {}
 90 
 91   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 92   virtual void do_oop(oop* p)       { do_oop_work(p); }
 93 };
 94 
 95 template <ShenandoahGenerationType GENERATION>
 96 class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure {
 97 private:
 98   template <class T>
 99   inline void do_oop_work(T* p)     { work<T, GENERATION>(p); }
100 
101 public:
102   ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old_q) :
103     ShenandoahMarkRefsSuperClosure(q, rp, old_q) {};
104 
105   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
106   virtual void do_oop(oop* p)       { do_oop_work(p); }
107 };
108 

109 class ShenandoahUpdateRefsSuperClosure : public ShenandoahOopClosureBase {
110 protected:
111   ShenandoahHeap* _heap;
112 
113 public:
114   ShenandoahUpdateRefsSuperClosure() :  _heap(ShenandoahHeap::heap()) {}
115 };
116 
117 class ShenandoahSTWUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure {
118 private:
119   template<class T>
120   inline void work(T* p);
121 
122 public:
123   ShenandoahSTWUpdateRefsClosure() : ShenandoahUpdateRefsSuperClosure() {
124     assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must only be used at safepoints");
125   }
126 
127   virtual void do_oop(narrowOop* p) { work(p); }
128   virtual void do_oop(oop* p)       { work(p); }
< prev index next >