src/share/vm/memory/genOopClosures.hpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 548
ba764ed4b6f2
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 2001-2007 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
duke@435 31 // Closure for iterating roots from a particular generation
duke@435 32 // Note: all classes deriving from this MUST call this do_barrier
duke@435 33 // method at the end of their own do_oop method!
duke@435 34 // Note: no do_oop defined, this is an abstract class.
duke@435 35
duke@435 36 class OopsInGenClosure : public OopClosure {
duke@435 37 private:
duke@435 38 Generation* _orig_gen; // generation originally set in ctor
duke@435 39 Generation* _gen; // generation being scanned
duke@435 40
duke@435 41 protected:
duke@435 42 // Some subtypes need access.
duke@435 43 HeapWord* _gen_boundary; // start of generation
duke@435 44 CardTableRS* _rs; // remembered set
duke@435 45
duke@435 46 // For assertions
duke@435 47 Generation* generation() { return _gen; }
duke@435 48 CardTableRS* rs() { return _rs; }
duke@435 49
duke@435 50 // Derived classes that modify oops so that they might be old-to-young
duke@435 51 // pointers must call the method below.
duke@435 52 void do_barrier(oop* p);
duke@435 53
duke@435 54 public:
duke@435 55 OopsInGenClosure() : OopClosure(NULL),
duke@435 56 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
duke@435 57
duke@435 58 OopsInGenClosure(Generation* gen);
duke@435 59 void set_generation(Generation* gen);
duke@435 60
duke@435 61 void reset_generation() { _gen = _orig_gen; }
duke@435 62
duke@435 63 // Problem with static closures: must have _gen_boundary set at some point,
duke@435 64 // but cannot do this until after the heap is initialized.
duke@435 65 void set_orig_generation(Generation* gen) {
duke@435 66 _orig_gen = gen;
duke@435 67 set_generation(gen);
duke@435 68 }
duke@435 69
duke@435 70 HeapWord* gen_boundary() { return _gen_boundary; }
duke@435 71 };
duke@435 72
duke@435 73 // Closure for scanning DefNewGeneration.
duke@435 74 //
duke@435 75 // This closure will perform barrier store calls for ALL
duke@435 76 // pointers in scanned oops.
duke@435 77 class ScanClosure: public OopsInGenClosure {
duke@435 78 protected:
duke@435 79 DefNewGeneration* _g;
duke@435 80 HeapWord* _boundary;
duke@435 81 bool _gc_barrier;
duke@435 82 public:
duke@435 83 ScanClosure(DefNewGeneration* g, bool gc_barrier);
duke@435 84 void do_oop(oop* p);
duke@435 85 void do_oop_nv(oop* p);
duke@435 86 bool do_header() { return false; }
duke@435 87 Prefetch::style prefetch_style() {
duke@435 88 return Prefetch::do_write;
duke@435 89 }
duke@435 90 };
duke@435 91
duke@435 92 // Closure for scanning DefNewGeneration.
duke@435 93 //
duke@435 94 // This closure only performs barrier store calls on
duke@435 95 // pointers into the DefNewGeneration. This is less
duke@435 96 // precise, but faster, than a ScanClosure
duke@435 97 class FastScanClosure: public OopsInGenClosure {
duke@435 98 protected:
duke@435 99 DefNewGeneration* _g;
duke@435 100 HeapWord* _boundary;
duke@435 101 bool _gc_barrier;
duke@435 102 public:
duke@435 103 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
duke@435 104 void do_oop(oop* p);
duke@435 105 void do_oop_nv(oop* p);
duke@435 106 bool do_header() { return false; }
duke@435 107 Prefetch::style prefetch_style() {
duke@435 108 return Prefetch::do_write;
duke@435 109 }
duke@435 110 };
duke@435 111
duke@435 112 class FilteringClosure: public OopClosure {
duke@435 113 HeapWord* _boundary;
duke@435 114 OopClosure* _cl;
duke@435 115 public:
duke@435 116 FilteringClosure(HeapWord* boundary, OopClosure* cl) :
duke@435 117 OopClosure(cl->_ref_processor), _boundary(boundary),
duke@435 118 _cl(cl) {}
duke@435 119 void do_oop(oop* p);
duke@435 120 void do_oop_nv(oop* p) {
duke@435 121 oop obj = *p;
duke@435 122 if ((HeapWord*)obj < _boundary && obj != NULL) {
duke@435 123 _cl->do_oop(p);
duke@435 124 }
duke@435 125 }
duke@435 126 bool do_header() { return false; }
duke@435 127 };
duke@435 128
duke@435 129 // Closure for scanning DefNewGeneration's weak references.
duke@435 130 // NOTE: very much like ScanClosure but not derived from
duke@435 131 // OopsInGenClosure -- weak references are processed all
duke@435 132 // at once, with no notion of which generation they were in.
duke@435 133 class ScanWeakRefClosure: public OopClosure {
duke@435 134 protected:
duke@435 135 DefNewGeneration* _g;
duke@435 136 HeapWord* _boundary;
duke@435 137 public:
duke@435 138 ScanWeakRefClosure(DefNewGeneration* g);
duke@435 139 void do_oop(oop* p);
duke@435 140 void do_oop_nv(oop* p);
duke@435 141 };
duke@435 142
duke@435 143 class VerifyOopClosure: public OopClosure {
duke@435 144 public:
duke@435 145 void do_oop(oop* p) {
duke@435 146 guarantee((*p)->is_oop_or_null(), "invalid oop");
duke@435 147 }
duke@435 148 static VerifyOopClosure verify_oop;
duke@435 149 };

mercurial