annotate src/share/vm/memory/sharedHeap.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 37f87013dfd8
children 7d7a7c599c17
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 2000-2006 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 // A "SharedHeap" is an implementation of a java heap for HotSpot. This
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // is an abstract class: there may be many different kinds of heaps. This
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // class defines the functions that a heap must implement, and contains
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // infrastructure common to all heaps.
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class PermGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class Generation;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class BarrierSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class GenRemSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 class Space;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class SpaceClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class OopClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class OopsInGenClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class ObjectClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class SubTasksDone;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class WorkGang;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class CollectorPolicy;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class KlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class SharedHeap : public CollectedHeap {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
47 friend class VM_GC_Operation;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
48 friend class VM_CGC_Operation;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
49
0
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // For claiming strong_roots tasks.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 SubTasksDone* _process_strong_tasks;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // There should be only a single instance of "SharedHeap" in a program.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // This is enforced with the protected constructor below, which will also
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // set the static pointer "_sh" to that instance.
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static SharedHeap* _sh;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // All heaps contain a "permanent generation." This is some ways
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // similar to a generation in a generational system, in other ways not.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // See the "PermGen" class.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 PermGen* _perm_gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // and the Gen Remembered Set, at least one good enough to scan the perm
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // gen.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 GenRemSet* _rem_set;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // A gc policy, controls global gc resource issues
a61af66fc99e Initial load
duke
parents:
diff changeset
70 CollectorPolicy *_collector_policy;
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // See the discussion below, in the specification of the reader function
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // for this variable.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 int _strong_roots_parity;
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // If we're doing parallel GC, use this gang of threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
77 WorkGang* _workers;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Number of parallel threads currently working on GC tasks.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // O indicates use sequential code; 1 means use parallel code even with
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // only one thread, for performance testing purposes.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 int _n_par_threads;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Full initialization is done in a concrete subtype's "initialize"
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // function.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 SharedHeap(CollectorPolicy* policy_);
a61af66fc99e Initial load
duke
parents:
diff changeset
87
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
88 // Returns true if the calling thread holds the heap lock,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
89 // or the calling thread is a par gc thread and the heap_lock is held
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
90 // by the vm thread doing a gc operation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
91 bool heap_lock_held_for_gc();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
92 // True if the heap_lock is held by the a non-gc thread invoking a gc
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
93 // operation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
94 bool _thread_holds_heap_lock_for_gc;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
95
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 static SharedHeap* heap() { return _sh; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 CollectorPolicy *collector_policy() const { return _collector_policy; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void set_barrier_set(BarrierSet* bs);
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Does operations required after initialization has been done.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 virtual void post_initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Initialization of ("weak") reference processing support
a61af66fc99e Initial load
duke
parents:
diff changeset
107 virtual void ref_processing_init();
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 void set_perm(PermGen* perm_gen) { _perm_gen = perm_gen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
111 // A helper function that fills a region of the heap with
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
112 // with a single object.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
113 static void fill_region_with_object(MemRegion mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Minimum garbage fill object size
a61af66fc99e Initial load
duke
parents:
diff changeset
116 static size_t min_fill_size() { return (size_t)align_object_size(oopDesc::header_size()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 static size_t min_fill_size_in_bytes() { return min_fill_size() * HeapWordSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // This function returns the "GenRemSet" object that allows us to scan
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // generations; at least the perm gen, possibly more in a fully
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // generational heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 GenRemSet* rem_set() { return _rem_set; }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // These function return the "permanent" generation, in which
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // reflective objects are allocated and stored. Two versions, the second
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // of which returns the view of the perm gen as a generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 PermGen* perm() const { return _perm_gen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 Generation* perm_gen() const { return _perm_gen->as_gen(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Iteration functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 void oop_iterate(OopClosure* cl) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Same as above, restricted to a memory region.
a61af66fc99e Initial load
duke
parents:
diff changeset
134 virtual void oop_iterate(MemRegion mr, OopClosure* cl) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Iterate over all objects allocated since the last collection, calling
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // "cl->do_object" on each. The heap must have been initialized properly
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // to support this function, or else this call will fail.
a61af66fc99e Initial load
duke
parents:
diff changeset
139 virtual void object_iterate_since_last_GC(ObjectClosure* cl) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Iterate over all spaces in use in the heap, in an undefined order.
a61af66fc99e Initial load
duke
parents:
diff changeset
142 virtual void space_iterate(SpaceClosure* cl) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // A SharedHeap will contain some number of spaces. This finds the
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // space whose reserved area contains the given address, or else returns
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // NULL.
a61af66fc99e Initial load
duke
parents:
diff changeset
147 virtual Space* space_containing(const void* addr) const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 bool no_gc_in_progress() { return !is_gc_active(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Some collectors will perform "process_strong_roots" in parallel.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Such a call will involve claiming some fine-grained tasks, such as
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // scanning of threads. To make this process simpler, we provide the
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // "strong_roots_parity()" method. Collectors that start parallel tasks
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // whose threads invoke "process_strong_roots" must
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // call "change_strong_roots_parity" in sequential code starting such a
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // task. (This also means that a parallel thread may only call
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // process_strong_roots once.)
a61af66fc99e Initial load
duke
parents:
diff changeset
159 //
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // For calls to process_strong_roots by sequential code, the parity is
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // updated automatically.
a61af66fc99e Initial load
duke
parents:
diff changeset
162 //
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // The idea is that objects representing fine-grained tasks, such as
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // threads, will contain a "parity" field. A task will is claimed in the
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // current "process_strong_roots" call only if its parity field is the
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // same as the "strong_roots_parity"; task claiming is accomplished by
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // updating the parity field to the strong_roots_parity with a CAS.
a61af66fc99e Initial load
duke
parents:
diff changeset
168 //
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // If the client meats this spec, then strong_roots_parity() will have
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // the following properties:
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // a) to return a different value than was returned before the last
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // call to change_strong_roots_parity, and
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // c) to never return a distinguished value (zero) with which such
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // task-claiming variables may be initialized, to indicate "never
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // claimed".
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void change_strong_roots_parity();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 int strong_roots_parity() { return _strong_roots_parity; }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 enum ScanningOption {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 SO_None = 0x0,
a61af66fc99e Initial load
duke
parents:
diff changeset
181 SO_AllClasses = 0x1,
a61af66fc99e Initial load
duke
parents:
diff changeset
182 SO_SystemClasses = 0x2,
a61af66fc99e Initial load
duke
parents:
diff changeset
183 SO_Symbols = 0x4,
a61af66fc99e Initial load
duke
parents:
diff changeset
184 SO_Strings = 0x8,
a61af66fc99e Initial load
duke
parents:
diff changeset
185 SO_CodeCache = 0x10
a61af66fc99e Initial load
duke
parents:
diff changeset
186 };
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 WorkGang* workers() const { return _workers; }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // Sets the number of parallel threads that will be doing tasks
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // (such as process strong roots) subsequently.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 virtual void set_par_threads(int t);
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // Number of threads currently working on GC tasks.
a61af66fc99e Initial load
duke
parents:
diff changeset
195 int n_par_threads() { return _n_par_threads; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Invoke the "do_oop" method the closure "roots" on all root locations.
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // If "collecting_perm_gen" is false, then roots that may only contain
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // references to permGen objects are not scanned. If true, the
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // "perm_gen" closure is applied to all older-to-younger refs in the
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // permanent generation. The "so" argument determines which of roots
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // the closure is applied to:
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // "SO_None" does none;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // "SO_AllClasses" applies the closure to all entries in the SystemDictionary;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // "SO_SystemClasses" to all the "system" classes and loaders;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // "SO_Symbols" applies the closure to all entries in SymbolsTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // "SO_Strings" applies the closure to all entries in StringTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // "SO_CodeCache" applies the closure to all elements of the CodeCache.
a61af66fc99e Initial load
duke
parents:
diff changeset
209 void process_strong_roots(bool collecting_perm_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
210 ScanningOption so,
a61af66fc99e Initial load
duke
parents:
diff changeset
211 OopClosure* roots,
a61af66fc99e Initial load
duke
parents:
diff changeset
212 OopsInGenClosure* perm_blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // Apply "blk" to all the weak roots of the system. These include
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // JNI weak roots, the code cache, system dictionary, symbol table,
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // string table.
a61af66fc99e Initial load
duke
parents:
diff changeset
217 void process_weak_roots(OopClosure* root_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
218 OopClosure* non_root_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // Like CollectedHeap::collect, but assume that the caller holds the Heap_lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 virtual void collect_locked(GCCause::Cause cause) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // The functions below are helper functions that a subclass of
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // "SharedHeap" can use in the implementation of its virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
227
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
228 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Do anything common to GC's.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 virtual void gc_prologue(bool full) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 virtual void gc_epilogue(bool full) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 //
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // New methods from CollectedHeap
a61af66fc99e Initial load
duke
parents:
diff changeset
236 //
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 size_t permanent_capacity() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return perm_gen()->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 size_t permanent_used() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return perm_gen()->used();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 bool is_in_permanent(const void *p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
250 return perm_gen()->is_in_reserved(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Different from is_in_permanent in that is_in_permanent
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // only checks if p is in the reserved area of the heap
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // and this checks to see if it in the commited area.
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // This is typically used by things like the forte stackwalker
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // during verification of suspicious frame values.
a61af66fc99e Initial load
duke
parents:
diff changeset
258 bool is_permanent(const void *p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 return perm_gen()->is_in(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 HeapWord* permanent_mem_allocate(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
265 return _perm_gen->mem_allocate(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 void permanent_oop_iterate(OopClosure* cl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 _perm_gen->oop_iterate(cl);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 void permanent_object_iterate(ObjectClosure* cl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 assert(perm_gen(), "NULL perm gen");
a61af66fc99e Initial load
duke
parents:
diff changeset
275 _perm_gen->object_iterate(cl);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // Some utilities.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
279 void print_size_transition(outputStream* out,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
280 size_t bytes_before,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
281 size_t bytes_after,
a61af66fc99e Initial load
duke
parents:
diff changeset
282 size_t capacity);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 };