annotate src/hotspot/share/gc/shared/genOopClosures.hpp @ 50590:4fa726f796f5

8202781: Fix typo in DiscoveredListIterator::complete_enqeue Reviewed-by: kbarrett
author tschatzl
date Tue, 08 May 2018 16:49:20 +0200
parents a4672513d6e3
children 4216de02077e
rev   line source
duke@1 1 /*
pliden@50322 2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
pliden@30764 25 #ifndef SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
pliden@30764 26 #define SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
stefank@7397 27
stefank@7397 28 #include "memory/iterator.hpp"
stefank@7397 29 #include "oops/oop.hpp"
stefank@7397 30
duke@1 31 class Generation;
duke@1 32 class HeapWord;
duke@1 33 class CardTableRS;
eosterlund@49920 34 class CardTableBarrierSet;
duke@1 35 class DefNewGeneration;
coleenp@13728 36 class KlassRemSet;
duke@1 37
duke@1 38 // Closure for iterating roots from a particular generation
duke@1 39 // Note: all classes deriving from this MUST call this do_barrier
duke@1 40 // method at the end of their own do_oop method!
duke@1 41 // Note: no do_oop defined, this is an abstract class.
duke@1 42
coleenp@13728 43 class OopsInGenClosure : public ExtendedOopClosure {
duke@1 44 private:
coleenp@360 45 Generation* _orig_gen; // generation originally set in ctor
coleenp@360 46 Generation* _gen; // generation being scanned
duke@1 47
duke@1 48 protected:
duke@1 49 // Some subtypes need access.
coleenp@360 50 HeapWord* _gen_boundary; // start of generation
coleenp@360 51 CardTableRS* _rs; // remembered set
duke@1 52
duke@1 53 // For assertions
duke@1 54 Generation* generation() { return _gen; }
duke@1 55 CardTableRS* rs() { return _rs; }
duke@1 56
duke@1 57 // Derived classes that modify oops so that they might be old-to-young
duke@1 58 // pointers must call the method below.
coleenp@360 59 template <class T> void do_barrier(T* p);
duke@1 60
ysr@1374 61 // Version for use by closures that may be called in parallel code.
ysr@3262 62 template <class T> void par_do_barrier(T* p);
ysr@1374 63
duke@1 64 public:
coleenp@13728 65 OopsInGenClosure() : ExtendedOopClosure(NULL),
duke@1 66 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
duke@1 67
duke@1 68 OopsInGenClosure(Generation* gen);
duke@1 69 void set_generation(Generation* gen);
duke@1 70
duke@1 71 void reset_generation() { _gen = _orig_gen; }
duke@1 72
duke@1 73 // Problem with static closures: must have _gen_boundary set at some point,
duke@1 74 // but cannot do this until after the heap is initialized.
duke@1 75 void set_orig_generation(Generation* gen) {
duke@1 76 _orig_gen = gen;
duke@1 77 set_generation(gen);
duke@1 78 }
duke@1 79
duke@1 80 HeapWord* gen_boundary() { return _gen_boundary; }
coleenp@13728 81
coleenp@13728 82 };
coleenp@13728 83
coleenp@47735 84 // Super class for scan closures. It contains code to dirty scanned class loader data.
coleenp@47735 85 class OopsInClassLoaderDataOrGenClosure: public OopsInGenClosure {
coleenp@47735 86 ClassLoaderData* _scanned_cld;
coleenp@13728 87 public:
coleenp@47735 88 OopsInClassLoaderDataOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_cld(NULL) {}
coleenp@47735 89 void set_scanned_cld(ClassLoaderData* cld) {
coleenp@47735 90 assert(cld == NULL || _scanned_cld == NULL, "Must be");
coleenp@47735 91 _scanned_cld = cld;
coleenp@13728 92 }
coleenp@47735 93 bool is_scanning_a_cld() { return _scanned_cld != NULL; }
coleenp@47735 94 void do_cld_barrier();
duke@1 95 };
duke@1 96
stefank@50518 97 #if INCLUDE_SERIALGC
coleenp@47735 98
duke@1 99 // Closure for scanning DefNewGeneration.
duke@1 100 //
duke@1 101 // This closure will perform barrier store calls for ALL
duke@1 102 // pointers in scanned oops.
coleenp@47735 103 class ScanClosure: public OopsInClassLoaderDataOrGenClosure {
coleenp@360 104 protected:
duke@1 105 DefNewGeneration* _g;
coleenp@360 106 HeapWord* _boundary;
coleenp@360 107 bool _gc_barrier;
coleenp@360 108 template <class T> inline void do_oop_work(T* p);
coleenp@360 109 public:
duke@1 110 ScanClosure(DefNewGeneration* g, bool gc_barrier);
coleenp@360 111 virtual void do_oop(oop* p);
coleenp@360 112 virtual void do_oop(narrowOop* p);
coleenp@360 113 inline void do_oop_nv(oop* p);
coleenp@360 114 inline void do_oop_nv(narrowOop* p);
duke@1 115 };
duke@1 116
duke@1 117 // Closure for scanning DefNewGeneration.
duke@1 118 //
duke@1 119 // This closure only performs barrier store calls on
duke@1 120 // pointers into the DefNewGeneration. This is less
duke@1 121 // precise, but faster, than a ScanClosure
coleenp@47735 122 class FastScanClosure: public OopsInClassLoaderDataOrGenClosure {
coleenp@360 123 protected:
duke@1 124 DefNewGeneration* _g;
coleenp@360 125 HeapWord* _boundary;
coleenp@360 126 bool _gc_barrier;
coleenp@360 127 template <class T> inline void do_oop_work(T* p);
coleenp@360 128 public:
duke@1 129 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
coleenp@360 130 virtual void do_oop(oop* p);
coleenp@360 131 virtual void do_oop(narrowOop* p);
coleenp@360 132 inline void do_oop_nv(oop* p);
coleenp@360 133 inline void do_oop_nv(narrowOop* p);
duke@1 134 };
duke@1 135
stefank@50518 136 #endif // INCLUDE_SERIALGC
stefank@50518 137
coleenp@47735 138 class CLDScanClosure: public CLDClosure {
coleenp@47735 139 OopsInClassLoaderDataOrGenClosure* _scavenge_closure;
coleenp@13728 140 // true if the the modified oops state should be saved.
coleenp@47735 141 bool _accumulate_modified_oops;
coleenp@13728 142 public:
coleenp@47735 143 CLDScanClosure(OopsInClassLoaderDataOrGenClosure* scavenge_closure,
coleenp@47735 144 bool accumulate_modified_oops) :
coleenp@47735 145 _scavenge_closure(scavenge_closure), _accumulate_modified_oops(accumulate_modified_oops) {}
coleenp@47735 146 void do_cld(ClassLoaderData* cld);
coleenp@13728 147 };
coleenp@13728 148
coleenp@13728 149 class FilteringClosure: public ExtendedOopClosure {
coleenp@360 150 private:
coleenp@360 151 HeapWord* _boundary;
coleenp@13728 152 ExtendedOopClosure* _cl;
coleenp@360 153 protected:
goetz@35862 154 template <class T> inline void do_oop_work(T* p);
coleenp@360 155 public:
coleenp@13728 156 FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) :
pliden@50322 157 ExtendedOopClosure(cl->ref_discoverer()), _boundary(boundary),
duke@1 158 _cl(cl) {}
coleenp@360 159 virtual void do_oop(oop* p);
coleenp@360 160 virtual void do_oop(narrowOop* p);
goetz@35862 161 inline void do_oop_nv(oop* p);
goetz@35862 162 inline void do_oop_nv(narrowOop* p);
coleenp@13728 163 virtual bool do_metadata() { return do_metadata_nv(); }
coleenp@13728 164 inline bool do_metadata_nv() { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
duke@1 165 };
duke@1 166
stefank@50518 167 #if INCLUDE_SERIALGC
stefank@50518 168
duke@1 169 // Closure for scanning DefNewGeneration's weak references.
duke@1 170 // NOTE: very much like ScanClosure but not derived from
duke@1 171 // OopsInGenClosure -- weak references are processed all
duke@1 172 // at once, with no notion of which generation they were in.
duke@1 173 class ScanWeakRefClosure: public OopClosure {
coleenp@360 174 protected:
coleenp@360 175 DefNewGeneration* _g;
coleenp@360 176 HeapWord* _boundary;
coleenp@360 177 template <class T> inline void do_oop_work(T* p);
coleenp@360 178 public:
duke@1 179 ScanWeakRefClosure(DefNewGeneration* g);
coleenp@360 180 virtual void do_oop(oop* p);
coleenp@360 181 virtual void do_oop(narrowOop* p);
coleenp@360 182 inline void do_oop_nv(oop* p);
coleenp@360 183 inline void do_oop_nv(narrowOop* p);
duke@1 184 };
duke@1 185
stefank@50518 186 #endif // INCLUDE_SERIALGC
stefank@50518 187
pliden@30764 188 #endif // SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP