src/share/vm/memory/genOopClosures.hpp

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 548
ba764ed4b6f2
child 791
1ee8caae33af
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

duke@435 1 /*
xdono@631 2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 class Generation;
duke@435 26 class HeapWord;
duke@435 27 class CardTableRS;
duke@435 28 class CardTableModRefBS;
duke@435 29 class DefNewGeneration;
duke@435 30
coleenp@548 31 template<class E> class GenericTaskQueue;
coleenp@548 32 typedef GenericTaskQueue<oop> OopTaskQueue;
coleenp@548 33 template<class E> class GenericTaskQueueSet;
coleenp@548 34 typedef GenericTaskQueueSet<oop> OopTaskQueueSet;
coleenp@548 35
duke@435 36 // Closure for iterating roots from a particular generation
duke@435 37 // Note: all classes deriving from this MUST call this do_barrier
duke@435 38 // method at the end of their own do_oop method!
duke@435 39 // Note: no do_oop defined, this is an abstract class.
duke@435 40
duke@435 41 class OopsInGenClosure : public OopClosure {
duke@435 42 private:
coleenp@548 43 Generation* _orig_gen; // generation originally set in ctor
coleenp@548 44 Generation* _gen; // generation being scanned
duke@435 45
duke@435 46 protected:
duke@435 47 // Some subtypes need access.
coleenp@548 48 HeapWord* _gen_boundary; // start of generation
coleenp@548 49 CardTableRS* _rs; // remembered set
duke@435 50
duke@435 51 // For assertions
duke@435 52 Generation* generation() { return _gen; }
duke@435 53 CardTableRS* rs() { return _rs; }
duke@435 54
duke@435 55 // Derived classes that modify oops so that they might be old-to-young
duke@435 56 // pointers must call the method below.
coleenp@548 57 template <class T> void do_barrier(T* p);
duke@435 58
duke@435 59 public:
duke@435 60 OopsInGenClosure() : OopClosure(NULL),
duke@435 61 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
duke@435 62
duke@435 63 OopsInGenClosure(Generation* gen);
duke@435 64 void set_generation(Generation* gen);
duke@435 65
duke@435 66 void reset_generation() { _gen = _orig_gen; }
duke@435 67
duke@435 68 // Problem with static closures: must have _gen_boundary set at some point,
duke@435 69 // but cannot do this until after the heap is initialized.
duke@435 70 void set_orig_generation(Generation* gen) {
duke@435 71 _orig_gen = gen;
duke@435 72 set_generation(gen);
duke@435 73 }
duke@435 74
duke@435 75 HeapWord* gen_boundary() { return _gen_boundary; }
duke@435 76 };
duke@435 77
duke@435 78 // Closure for scanning DefNewGeneration.
duke@435 79 //
duke@435 80 // This closure will perform barrier store calls for ALL
duke@435 81 // pointers in scanned oops.
duke@435 82 class ScanClosure: public OopsInGenClosure {
coleenp@548 83 protected:
duke@435 84 DefNewGeneration* _g;
coleenp@548 85 HeapWord* _boundary;
coleenp@548 86 bool _gc_barrier;
coleenp@548 87 template <class T> inline void do_oop_work(T* p);
coleenp@548 88 public:
duke@435 89 ScanClosure(DefNewGeneration* g, bool gc_barrier);
coleenp@548 90 virtual void do_oop(oop* p);
coleenp@548 91 virtual void do_oop(narrowOop* p);
coleenp@548 92 inline void do_oop_nv(oop* p);
coleenp@548 93 inline void do_oop_nv(narrowOop* p);
duke@435 94 bool do_header() { return false; }
duke@435 95 Prefetch::style prefetch_style() {
duke@435 96 return Prefetch::do_write;
duke@435 97 }
duke@435 98 };
duke@435 99
duke@435 100 // Closure for scanning DefNewGeneration.
duke@435 101 //
duke@435 102 // This closure only performs barrier store calls on
duke@435 103 // pointers into the DefNewGeneration. This is less
duke@435 104 // precise, but faster, than a ScanClosure
duke@435 105 class FastScanClosure: public OopsInGenClosure {
coleenp@548 106 protected:
duke@435 107 DefNewGeneration* _g;
coleenp@548 108 HeapWord* _boundary;
coleenp@548 109 bool _gc_barrier;
coleenp@548 110 template <class T> inline void do_oop_work(T* p);
coleenp@548 111 public:
duke@435 112 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
coleenp@548 113 virtual void do_oop(oop* p);
coleenp@548 114 virtual void do_oop(narrowOop* p);
coleenp@548 115 inline void do_oop_nv(oop* p);
coleenp@548 116 inline void do_oop_nv(narrowOop* p);
duke@435 117 bool do_header() { return false; }
duke@435 118 Prefetch::style prefetch_style() {
duke@435 119 return Prefetch::do_write;
duke@435 120 }
duke@435 121 };
duke@435 122
duke@435 123 class FilteringClosure: public OopClosure {
coleenp@548 124 private:
coleenp@548 125 HeapWord* _boundary;
duke@435 126 OopClosure* _cl;
coleenp@548 127 protected:
coleenp@548 128 template <class T> inline void do_oop_work(T* p) {
coleenp@548 129 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 130 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 131 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 132 if ((HeapWord*)obj < _boundary) {
coleenp@548 133 _cl->do_oop(p);
coleenp@548 134 }
coleenp@548 135 }
coleenp@548 136 }
coleenp@548 137 public:
duke@435 138 FilteringClosure(HeapWord* boundary, OopClosure* cl) :
duke@435 139 OopClosure(cl->_ref_processor), _boundary(boundary),
duke@435 140 _cl(cl) {}
coleenp@548 141 virtual void do_oop(oop* p);
coleenp@548 142 virtual void do_oop(narrowOop* p);
coleenp@548 143 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); }
coleenp@548 144 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
duke@435 145 bool do_header() { return false; }
duke@435 146 };
duke@435 147
duke@435 148 // Closure for scanning DefNewGeneration's weak references.
duke@435 149 // NOTE: very much like ScanClosure but not derived from
duke@435 150 // OopsInGenClosure -- weak references are processed all
duke@435 151 // at once, with no notion of which generation they were in.
duke@435 152 class ScanWeakRefClosure: public OopClosure {
coleenp@548 153 protected:
coleenp@548 154 DefNewGeneration* _g;
coleenp@548 155 HeapWord* _boundary;
coleenp@548 156 template <class T> inline void do_oop_work(T* p);
coleenp@548 157 public:
duke@435 158 ScanWeakRefClosure(DefNewGeneration* g);
coleenp@548 159 virtual void do_oop(oop* p);
coleenp@548 160 virtual void do_oop(narrowOop* p);
coleenp@548 161 inline void do_oop_nv(oop* p);
coleenp@548 162 inline void do_oop_nv(narrowOop* p);
duke@435 163 };
duke@435 164
duke@435 165 class VerifyOopClosure: public OopClosure {
coleenp@548 166 protected:
coleenp@548 167 template <class T> inline void do_oop_work(T* p) {
coleenp@548 168 oop obj = oopDesc::load_decode_heap_oop(p);
coleenp@548 169 guarantee(obj->is_oop_or_null(), "invalid oop");
duke@435 170 }
coleenp@548 171 public:
coleenp@548 172 virtual void do_oop(oop* p);
coleenp@548 173 virtual void do_oop(narrowOop* p);
duke@435 174 static VerifyOopClosure verify_oop;
duke@435 175 };

mercurial