annotate src/share/vm/memory/genOopClosures.hpp @ 452:00b023ae2d78

6722113: CMS: Incorrect overflow handling during precleaning of Reference lists Summary: When we encounter marking stack overflow during precleaning of Reference lists, we were using the overflow list mechanism, which can cause problems on account of mutating the mark word of the header because of conflicts with mutator accesses and updates of that field. Instead we should use the usual mechanism for overflow handling in concurrent phases, namely dirtying of the card on which the overflowed object lies. Since precleaning effectively does a form of discovered list processing, albeit with discovery enabled, we needed to adjust some code to be correct in the face of interleaved processing and discovery. Reviewed-by: apetrusenko, jcoomes
author ysr
date Thu, 20 Nov 2008 12:27:41 -0800
parents 1ee8caae33af
children df6caf649ff7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
0
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
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
31 template<class E> class GenericTaskQueue;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
32 typedef GenericTaskQueue<oop> OopTaskQueue;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
33 template<class E> class GenericTaskQueueSet;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
34 typedef GenericTaskQueueSet<oop> OopTaskQueueSet;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Closure for iterating roots from a particular generation
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Note: all classes deriving from this MUST call this do_barrier
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // method at the end of their own do_oop method!
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Note: no do_oop defined, this is an abstract class.
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class OopsInGenClosure : public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private:
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
43 Generation* _orig_gen; // generation originally set in ctor
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
44 Generation* _gen; // generation being scanned
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Some subtypes need access.
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
48 HeapWord* _gen_boundary; // start of generation
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
49 CardTableRS* _rs; // remembered set
0
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // For assertions
a61af66fc99e Initial load
duke
parents:
diff changeset
52 Generation* generation() { return _gen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 CardTableRS* rs() { return _rs; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Derived classes that modify oops so that they might be old-to-young
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // pointers must call the method below.
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
57 template <class T> void do_barrier(T* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
59 // Version for use by closures that may be called in parallel code.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
60 void par_do_barrier(oop* p);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
61
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
63 OopsInGenClosure() : OopClosure(NULL),
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 OopsInGenClosure(Generation* gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void set_generation(Generation* gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void reset_generation() { _gen = _orig_gen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Problem with static closures: must have _gen_boundary set at some point,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // but cannot do this until after the heap is initialized.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 void set_orig_generation(Generation* gen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _orig_gen = gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 set_generation(gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 HeapWord* gen_boundary() { return _gen_boundary; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 };
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Closure for scanning DefNewGeneration.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 //
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // This closure will perform barrier store calls for ALL
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // pointers in scanned oops.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 class ScanClosure: public OopsInGenClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
86 protected:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 DefNewGeneration* _g;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
88 HeapWord* _boundary;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
89 bool _gc_barrier;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
90 template <class T> inline void do_oop_work(T* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
91 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
92 ScanClosure(DefNewGeneration* g, bool gc_barrier);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
93 virtual void do_oop(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
94 virtual void do_oop(narrowOop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
95 inline void do_oop_nv(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
96 inline void do_oop_nv(narrowOop* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97 bool do_header() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 return Prefetch::do_write;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 };
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Closure for scanning DefNewGeneration.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 //
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // This closure only performs barrier store calls on
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // pointers into the DefNewGeneration. This is less
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // precise, but faster, than a ScanClosure
a61af66fc99e Initial load
duke
parents:
diff changeset
108 class FastScanClosure: public OopsInGenClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
109 protected:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110 DefNewGeneration* _g;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
111 HeapWord* _boundary;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
112 bool _gc_barrier;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
113 template <class T> inline void do_oop_work(T* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
114 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
116 virtual void do_oop(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
117 virtual void do_oop(narrowOop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
118 inline void do_oop_nv(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
119 inline void do_oop_nv(narrowOop* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
120 bool do_header() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return Prefetch::do_write;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 };
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 class FilteringClosure: public OopClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
127 private:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
128 HeapWord* _boundary;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129 OopClosure* _cl;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
130 protected:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
131 template <class T> inline void do_oop_work(T* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
132 T heap_oop = oopDesc::load_heap_oop(p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
133 if (!oopDesc::is_null(heap_oop)) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
134 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
135 if ((HeapWord*)obj < _boundary) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
136 _cl->do_oop(p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
137 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
138 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
139 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
140 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141 FilteringClosure(HeapWord* boundary, OopClosure* cl) :
a61af66fc99e Initial load
duke
parents:
diff changeset
142 OopClosure(cl->_ref_processor), _boundary(boundary),
a61af66fc99e Initial load
duke
parents:
diff changeset
143 _cl(cl) {}
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
144 virtual void do_oop(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
145 virtual void do_oop(narrowOop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
146 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
147 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 bool do_header() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 };
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Closure for scanning DefNewGeneration's weak references.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // NOTE: very much like ScanClosure but not derived from
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // OopsInGenClosure -- weak references are processed all
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // at once, with no notion of which generation they were in.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 class ScanWeakRefClosure: public OopClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
156 protected:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
157 DefNewGeneration* _g;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
158 HeapWord* _boundary;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
159 template <class T> inline void do_oop_work(T* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
160 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
161 ScanWeakRefClosure(DefNewGeneration* g);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
162 virtual void do_oop(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
163 virtual void do_oop(narrowOop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
164 inline void do_oop_nv(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
165 inline void do_oop_nv(narrowOop* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
166 };
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 class VerifyOopClosure: public OopClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
169 protected:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
170 template <class T> inline void do_oop_work(T* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
171 oop obj = oopDesc::load_decode_heap_oop(p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
172 guarantee(obj->is_oop_or_null(), "invalid oop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
174 public:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
175 virtual void do_oop(oop* p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
176 virtual void do_oop(narrowOop* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
177 static VerifyOopClosure verify_oop;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 };