annotate src/share/vm/memory/genOopClosures.hpp @ 0:a61af66fc99e jdk7-b24

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