Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/g1/g1OopClosures.hpp @ 941:8b46c4d82093
4957990: Perm heap bloat in JVM
Summary: Treat ProfileData in MDO's as a source of weak, not strong, roots. Fixes the bug for stop-world collection -- the case of concurrent collection will be fixed separately.
Reviewed-by: jcoomes, jmasa, kvn, never
author | ysr |
---|---|
date | Wed, 02 Sep 2009 00:04:29 -0700 |
parents | df6caf649ff7 |
children | 0414c1049f15 |
rev | line source |
---|---|
342 | 1 /* |
579 | 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. |
342 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 class HeapRegion; | |
26 class G1CollectedHeap; | |
27 class G1RemSet; | |
28 class HRInto_G1RemSet; | |
29 class G1RemSet; | |
30 class ConcurrentMark; | |
31 class DirtyCardToOopClosure; | |
32 class CMBitMap; | |
33 class CMMarkStack; | |
34 class G1ParScanThreadState; | |
35 | |
36 // A class that scans oops in a given heap region (much as OopsInGenClosure | |
37 // scans oops in a generation.) | |
38 class OopsInHeapRegionClosure: public OopsInGenClosure { | |
39 protected: | |
40 HeapRegion* _from; | |
41 public: | |
42 virtual void set_region(HeapRegion* from) { _from = from; } | |
43 }; | |
44 | |
45 class G1ParClosureSuper : public OopsInHeapRegionClosure { | |
46 protected: | |
47 G1CollectedHeap* _g1; | |
48 G1RemSet* _g1_rem; | |
49 ConcurrentMark* _cm; | |
50 G1ParScanThreadState* _par_scan_state; | |
51 public: | |
52 G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); | |
53 bool apply_to_weak_ref_discovered_field() { return true; } | |
54 }; | |
55 | |
56 class G1ParScanClosure : public G1ParClosureSuper { | |
57 public: | |
58 G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : | |
59 G1ParClosureSuper(g1, par_scan_state) { } | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
60 template <class T> void do_oop_nv(T* p); |
342 | 61 virtual void do_oop(oop* p) { do_oop_nv(p); } |
62 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | |
63 }; | |
64 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
65 #define G1_PARTIAL_ARRAY_MASK 0x2 |
342 | 66 |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
67 template <class T> inline bool has_partial_array_mask(T* ref) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
68 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; |
526 | 69 } |
70 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
71 template <class T> inline T* set_partial_array_mask(T obj) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
72 assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
73 return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK); |
526 | 74 } |
75 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
76 template <class T> inline oop clear_partial_array_mask(T* ref) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
77 return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); |
526 | 78 } |
79 | |
342 | 80 class G1ParScanPartialArrayClosure : public G1ParClosureSuper { |
81 G1ParScanClosure _scanner; | |
82 public: | |
83 G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : | |
84 G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { } | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
85 template <class T> void do_oop_nv(T* p); |
342 | 86 virtual void do_oop(oop* p) { do_oop_nv(p); } |
87 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | |
88 }; | |
89 | |
90 | |
91 class G1ParCopyHelper : public G1ParClosureSuper { | |
92 G1ParScanClosure *_scanner; | |
93 protected: | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
94 template <class T> void mark_forwardee(T* p); |
342 | 95 oop copy_to_survivor_space(oop obj); |
96 public: | |
97 G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, | |
98 G1ParScanClosure *scanner) : | |
99 G1ParClosureSuper(g1, par_scan_state), _scanner(scanner) { } | |
100 }; | |
101 | |
526 | 102 template<bool do_gen_barrier, G1Barrier barrier, |
103 bool do_mark_forwardee, bool skip_cset_test> | |
342 | 104 class G1ParCopyClosure : public G1ParCopyHelper { |
105 G1ParScanClosure _scanner; | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
106 template <class T> void do_oop_work(T* p); |
342 | 107 public: |
108 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : | |
109 _scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { } | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
110 template <class T> void do_oop_nv(T* p) { |
342 | 111 do_oop_work(p); |
112 if (do_mark_forwardee) | |
113 mark_forwardee(p); | |
114 } | |
115 virtual void do_oop(oop* p) { do_oop_nv(p); } | |
116 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | |
117 }; | |
118 | |
526 | 119 typedef G1ParCopyClosure<false, G1BarrierNone, false, false> G1ParScanExtRootClosure; |
120 typedef G1ParCopyClosure<true, G1BarrierNone, false, false> G1ParScanPermClosure; | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
121 typedef G1ParCopyClosure<false, G1BarrierRS, false, false> G1ParScanHeapRSClosure; |
526 | 122 typedef G1ParCopyClosure<false, G1BarrierNone, true, false> G1ParScanAndMarkExtRootClosure; |
123 typedef G1ParCopyClosure<true, G1BarrierNone, true, false> G1ParScanAndMarkPermClosure; | |
124 typedef G1ParCopyClosure<false, G1BarrierRS, true, false> G1ParScanAndMarkHeapRSClosure; | |
125 // This is the only case when we set skip_cset_test. Basically, this | |
126 // closure is (should?) only be called directly while we're draining | |
127 // the overflow and task queues. In that case we know that the | |
128 // reference in question points into the collection set, otherwise we | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
129 // would not have pushed it on the queue. The following is defined in |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
130 // g1_specialized_oop_closures.hpp. |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
131 // typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure; |
526 | 132 // We need a separate closure to handle references during evacuation |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
133 // failure processing, as we cannot asume that the reference already |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
134 // points into the collection set (like G1ParScanHeapEvacClosure does). |
526 | 135 typedef G1ParCopyClosure<false, G1BarrierEvac, false, false> G1ParScanHeapEvacFailureClosure; |
342 | 136 |
137 class FilterIntoCSClosure: public OopClosure { | |
138 G1CollectedHeap* _g1; | |
139 OopClosure* _oc; | |
140 DirtyCardToOopClosure* _dcto_cl; | |
141 public: | |
142 FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl, | |
143 G1CollectedHeap* g1, OopClosure* oc) : | |
144 _dcto_cl(dcto_cl), _g1(g1), _oc(oc) | |
145 {} | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
146 template <class T> void do_oop_nv(T* p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
147 virtual void do_oop(oop* p) { do_oop_nv(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
148 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
342 | 149 bool apply_to_weak_ref_discovered_field() { return true; } |
150 bool do_header() { return false; } | |
151 }; | |
152 | |
153 class FilterInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure { | |
154 G1CollectedHeap* _g1; | |
155 OopsInHeapRegionClosure* _oc; | |
156 public: | |
157 FilterInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1, | |
158 OopsInHeapRegionClosure* oc) : | |
159 _g1(g1), _oc(oc) | |
160 {} | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
161 template <class T> void do_oop_nv(T* p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
162 virtual void do_oop(oop* p) { do_oop_nv(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
163 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
342 | 164 bool apply_to_weak_ref_discovered_field() { return true; } |
165 bool do_header() { return false; } | |
166 void set_region(HeapRegion* from) { | |
167 _oc->set_region(from); | |
168 } | |
169 }; | |
170 | |
171 class FilterAndMarkInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure { | |
172 G1CollectedHeap* _g1; | |
173 ConcurrentMark* _cm; | |
174 OopsInHeapRegionClosure* _oc; | |
175 public: | |
176 FilterAndMarkInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1, | |
177 OopsInHeapRegionClosure* oc, | |
178 ConcurrentMark* cm) | |
179 : _g1(g1), _oc(oc), _cm(cm) { } | |
180 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
181 template <class T> void do_oop_nv(T* p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
182 virtual void do_oop(oop* p) { do_oop_nv(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
183 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
342 | 184 bool apply_to_weak_ref_discovered_field() { return true; } |
185 bool do_header() { return false; } | |
186 void set_region(HeapRegion* from) { | |
187 _oc->set_region(from); | |
188 } | |
189 }; | |
190 | |
191 class FilterOutOfRegionClosure: public OopClosure { | |
192 HeapWord* _r_bottom; | |
193 HeapWord* _r_end; | |
194 OopClosure* _oc; | |
195 int _out_of_region; | |
196 public: | |
197 FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc); | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
198 template <class T> void do_oop_nv(T* p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
199 virtual void do_oop(oop* p) { do_oop_nv(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
579
diff
changeset
|
200 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
342 | 201 bool apply_to_weak_ref_discovered_field() { return true; } |
202 bool do_header() { return false; } | |
203 int out_of_region() { return _out_of_region; } | |
204 }; |