Mercurial > hg > truffle
annotate src/share/vm/gc_interface/collectedHeap.hpp @ 4899:a79cb7c55012
7132690: InstanceKlass:_reference_type should be u1 type
Summary: Change InstanceKlass::_reference_type to u1 type.
Reviewed-by: dholmes, coleenp, acorn
Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>
author | jiangli |
---|---|
date | Wed, 25 Jan 2012 17:40:51 -0500 |
parents | 441e946dc1af |
children | aa3d708d67c4 |
rev | line source |
---|---|
0 | 1 /* |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
3772
diff
changeset
|
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1387
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1387
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1387
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP |
26 #define SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP | |
27 | |
28 #include "gc_interface/gcCause.hpp" | |
29 #include "memory/allocation.hpp" | |
30 #include "memory/barrierSet.hpp" | |
31 #include "runtime/handles.hpp" | |
32 #include "runtime/perfData.hpp" | |
33 #include "runtime/safepoint.hpp" | |
34 | |
0 | 35 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This |
36 // is an abstract class: there may be many different kinds of heaps. This | |
37 // class defines the functions that a heap must implement, and contains | |
38 // infrastructure common to all heaps. | |
39 | |
40 class BarrierSet; | |
41 class ThreadClosure; | |
42 class AdaptiveSizePolicy; | |
43 class Thread; | |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1166
diff
changeset
|
44 class CollectorPolicy; |
0 | 45 |
46 // | |
47 // CollectedHeap | |
48 // SharedHeap | |
49 // GenCollectedHeap | |
50 // G1CollectedHeap | |
51 // ParallelScavengeHeap | |
52 // | |
53 class CollectedHeap : public CHeapObj { | |
54 friend class VMStructs; | |
55 friend class IsGCActiveMark; // Block structured external access to _is_gc_active | |
542
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
517
diff
changeset
|
56 friend class constantPoolCacheKlass; // allocate() method inserts is_conc_safe |
0 | 57 |
58 #ifdef ASSERT | |
59 static int _fire_out_of_memory_count; | |
60 #endif | |
61 | |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
62 // Used for filler objects (static, but initialized in ctor). |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
63 static size_t _filler_array_max_size; |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
64 |
1166 | 65 // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used |
66 bool _defer_initial_card_mark; | |
67 | |
0 | 68 protected: |
69 MemRegion _reserved; | |
70 BarrierSet* _barrier_set; | |
71 bool _is_gc_active; | |
4728
441e946dc1af
7121618: Change type of number of GC workers to unsigned int.
jmasa
parents:
4708
diff
changeset
|
72 uint _n_par_threads; |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
73 |
0 | 74 unsigned int _total_collections; // ... started |
75 unsigned int _total_full_collections; // ... started | |
76 NOT_PRODUCT(volatile size_t _promotion_failure_alot_count;) | |
77 NOT_PRODUCT(volatile size_t _promotion_failure_alot_gc_number;) | |
78 | |
79 // Reason for current garbage collection. Should be set to | |
80 // a value reflecting no collection between collections. | |
81 GCCause::Cause _gc_cause; | |
82 GCCause::Cause _gc_lastcause; | |
83 PerfStringVariable* _perf_gc_cause; | |
84 PerfStringVariable* _perf_gc_lastcause; | |
85 | |
86 // Constructor | |
87 CollectedHeap(); | |
88 | |
1166 | 89 // Do common initializations that must follow instance construction, |
90 // for example, those needing virtual calls. | |
91 // This code could perhaps be moved into initialize() but would | |
92 // be slightly more awkward because we want the latter to be a | |
93 // pure virtual. | |
94 void pre_initialize(); | |
95 | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
3772
diff
changeset
|
96 // Create a new tlab. All TLAB allocations must go through this. |
0 | 97 virtual HeapWord* allocate_new_tlab(size_t size); |
98 | |
99 // Accumulate statistics on all tlabs. | |
100 virtual void accumulate_statistics_all_tlabs(); | |
101 | |
102 // Reinitialize tlabs before resuming mutators. | |
103 virtual void resize_all_tlabs(); | |
104 | |
105 protected: | |
106 // Allocate from the current thread's TLAB, with broken-out slow path. | |
107 inline static HeapWord* allocate_from_tlab(Thread* thread, size_t size); | |
108 static HeapWord* allocate_from_tlab_slow(Thread* thread, size_t size); | |
109 | |
110 // Allocate an uninitialized block of the given size, or returns NULL if | |
111 // this is impossible. | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
3772
diff
changeset
|
112 inline static HeapWord* common_mem_allocate_noinit(size_t size, TRAPS); |
0 | 113 |
114 // Like allocate_init, but the block returned by a successful allocation | |
115 // is guaranteed initialized to zeros. | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
3772
diff
changeset
|
116 inline static HeapWord* common_mem_allocate_init(size_t size, TRAPS); |
0 | 117 |
118 // Same as common_mem version, except memory is allocated in the permanent area | |
119 // If there is no permanent area, revert to common_mem_allocate_noinit | |
120 inline static HeapWord* common_permanent_mem_allocate_noinit(size_t size, TRAPS); | |
121 | |
122 // Same as common_mem version, except memory is allocated in the permanent area | |
123 // If there is no permanent area, revert to common_mem_allocate_init | |
124 inline static HeapWord* common_permanent_mem_allocate_init(size_t size, TRAPS); | |
125 | |
126 // Helper functions for (VM) allocation. | |
127 inline static void post_allocation_setup_common(KlassHandle klass, | |
128 HeapWord* obj, size_t size); | |
129 inline static void post_allocation_setup_no_klass_install(KlassHandle klass, | |
130 HeapWord* objPtr, | |
131 size_t size); | |
132 | |
133 inline static void post_allocation_setup_obj(KlassHandle klass, | |
134 HeapWord* obj, size_t size); | |
135 | |
136 inline static void post_allocation_setup_array(KlassHandle klass, | |
137 HeapWord* obj, size_t size, | |
138 int length); | |
139 | |
140 // Clears an allocated object. | |
141 inline static void init_obj(HeapWord* obj, size_t size); | |
142 | |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
143 // Filler object utilities. |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
144 static inline size_t filler_array_hdr_size(); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
145 static inline size_t filler_array_min_size(); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
146 static inline size_t filler_array_max_size(); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
147 |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
148 DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);) |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
149 DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words, bool zap = true);) |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
150 |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
151 // Fill with a single array; caller must ensure filler_array_min_size() <= |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
152 // words <= filler_array_max_size(). |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
153 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true); |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
154 |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
155 // Fill with a single object (either an int array or a java.lang.Object). |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
156 static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true); |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
157 |
0 | 158 // Verification functions |
159 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size) | |
160 PRODUCT_RETURN; | |
161 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) | |
162 PRODUCT_RETURN; | |
542
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
517
diff
changeset
|
163 debug_only(static void check_for_valid_allocation_state();) |
0 | 164 |
165 public: | |
166 enum Name { | |
167 Abstract, | |
168 SharedHeap, | |
169 GenCollectedHeap, | |
170 ParallelScavengeHeap, | |
171 G1CollectedHeap | |
172 }; | |
173 | |
174 virtual CollectedHeap::Name kind() const { return CollectedHeap::Abstract; } | |
175 | |
176 /** | |
177 * Returns JNI error code JNI_ENOMEM if memory could not be allocated, | |
178 * and JNI_OK on success. | |
179 */ | |
180 virtual jint initialize() = 0; | |
181 | |
182 // In many heaps, there will be a need to perform some initialization activities | |
183 // after the Universe is fully formed, but before general heap allocation is allowed. | |
184 // This is the correct place to place such initialization methods. | |
185 virtual void post_initialize() = 0; | |
186 | |
187 MemRegion reserved_region() const { return _reserved; } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
188 address base() const { return (address)reserved_region().start(); } |
0 | 189 |
190 // Future cleanup here. The following functions should specify bytes or | |
191 // heapwords as part of their signature. | |
192 virtual size_t capacity() const = 0; | |
193 virtual size_t used() const = 0; | |
194 | |
195 // Return "true" if the part of the heap that allocates Java | |
196 // objects has reached the maximal committed limit that it can | |
197 // reach, without a garbage collection. | |
198 virtual bool is_maximal_no_gc() const = 0; | |
199 | |
200 virtual size_t permanent_capacity() const = 0; | |
201 virtual size_t permanent_used() const = 0; | |
202 | |
203 // Support for java.lang.Runtime.maxMemory(): return the maximum amount of | |
204 // memory that the vm could make available for storing 'normal' java objects. | |
205 // This is based on the reserved address space, but should not include space | |
206 // that the vm uses internally for bookkeeping or temporary storage (e.g., | |
207 // perm gen space or, in the case of the young gen, one of the survivor | |
208 // spaces). | |
209 virtual size_t max_capacity() const = 0; | |
210 | |
211 // Returns "TRUE" if "p" points into the reserved area of the heap. | |
212 bool is_in_reserved(const void* p) const { | |
213 return _reserved.contains(p); | |
214 } | |
215 | |
216 bool is_in_reserved_or_null(const void* p) const { | |
217 return p == NULL || is_in_reserved(p); | |
218 } | |
219 | |
4708 | 220 // Returns "TRUE" iff "p" points into the committed areas of the heap. |
221 // Since this method can be expensive in general, we restrict its | |
0 | 222 // use to assertion checking only. |
223 virtual bool is_in(const void* p) const = 0; | |
224 | |
225 bool is_in_or_null(const void* p) const { | |
226 return p == NULL || is_in(p); | |
227 } | |
228 | |
229 // Let's define some terms: a "closed" subset of a heap is one that | |
230 // | |
231 // 1) contains all currently-allocated objects, and | |
232 // | |
233 // 2) is closed under reference: no object in the closed subset | |
234 // references one outside the closed subset. | |
235 // | |
236 // Membership in a heap's closed subset is useful for assertions. | |
237 // Clearly, the entire heap is a closed subset, so the default | |
238 // implementation is to use "is_in_reserved". But this may not be too | |
239 // liberal to perform useful checking. Also, the "is_in" predicate | |
240 // defines a closed subset, but may be too expensive, since "is_in" | |
241 // verifies that its argument points to an object head. The | |
242 // "closed_subset" method allows a heap to define an intermediate | |
243 // predicate, allowing more precise checking than "is_in_reserved" at | |
244 // lower cost than "is_in." | |
245 | |
246 // One important case is a heap composed of disjoint contiguous spaces, | |
247 // such as the Garbage-First collector. Such heaps have a convenient | |
248 // closed subset consisting of the allocated portions of those | |
249 // contiguous spaces. | |
250 | |
251 // Return "TRUE" iff the given pointer points into the heap's defined | |
252 // closed subset (which defaults to the entire heap). | |
253 virtual bool is_in_closed_subset(const void* p) const { | |
254 return is_in_reserved(p); | |
255 } | |
256 | |
257 bool is_in_closed_subset_or_null(const void* p) const { | |
258 return p == NULL || is_in_closed_subset(p); | |
259 } | |
260 | |
941 | 261 // XXX is_permanent() and is_in_permanent() should be better named |
262 // to distinguish one from the other. | |
263 | |
0 | 264 // Returns "TRUE" if "p" is allocated as "permanent" data. |
265 // If the heap does not use "permanent" data, returns the same | |
266 // value is_in_reserved() would return. | |
267 // NOTE: this actually returns true if "p" is in reserved space | |
268 // for the space not that it is actually allocated (i.e. in committed | |
269 // space). If you need the more conservative answer use is_permanent(). | |
270 virtual bool is_in_permanent(const void *p) const = 0; | |
271 | |
3377
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
272 |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
273 #ifdef ASSERT |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
274 // Returns true if "p" is in the part of the |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
275 // heap being collected. |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
276 virtual bool is_in_partial_collection(const void *p) = 0; |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
277 #endif |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
278 |
941 | 279 bool is_in_permanent_or_null(const void *p) const { |
280 return p == NULL || is_in_permanent(p); | |
281 } | |
282 | |
0 | 283 // Returns "TRUE" if "p" is in the committed area of "permanent" data. |
284 // If the heap does not use "permanent" data, returns the same | |
285 // value is_in() would return. | |
286 virtual bool is_permanent(const void *p) const = 0; | |
287 | |
941 | 288 bool is_permanent_or_null(const void *p) const { |
289 return p == NULL || is_permanent(p); | |
0 | 290 } |
291 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
845
diff
changeset
|
292 // An object is scavengable if its location may move during a scavenge. |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
845
diff
changeset
|
293 // (A scavenge is a GC which is not a full GC.) |
3377
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
1972
diff
changeset
|
294 virtual bool is_scavengable(const void *p) = 0; |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
845
diff
changeset
|
295 |
0 | 296 // Returns "TRUE" if "p" is a method oop in the |
297 // current heap, with high probability. This predicate | |
298 // is not stable, in general. | |
299 bool is_valid_method(oop p) const; | |
300 | |
301 void set_gc_cause(GCCause::Cause v) { | |
302 if (UsePerfData) { | |
303 _gc_lastcause = _gc_cause; | |
304 _perf_gc_lastcause->set_value(GCCause::to_string(_gc_lastcause)); | |
305 _perf_gc_cause->set_value(GCCause::to_string(v)); | |
306 } | |
307 _gc_cause = v; | |
308 } | |
309 GCCause::Cause gc_cause() { return _gc_cause; } | |
310 | |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
311 // Number of threads currently working on GC tasks. |
4728
441e946dc1af
7121618: Change type of number of GC workers to unsigned int.
jmasa
parents:
4708
diff
changeset
|
312 uint n_par_threads() { return _n_par_threads; } |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
313 |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
314 // May be overridden to set additional parallelism. |
4728
441e946dc1af
7121618: Change type of number of GC workers to unsigned int.
jmasa
parents:
4708
diff
changeset
|
315 virtual void set_par_threads(uint t) { _n_par_threads = t; }; |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
316 |
0 | 317 // Preload classes into the shared portion of the heap, and then dump |
318 // that data to a file so that it can be loaded directly by another | |
319 // VM (then terminate). | |
320 virtual void preload_and_dump(TRAPS) { ShouldNotReachHere(); } | |
321 | |
4009 | 322 // Allocate and initialize instances of Class |
323 static oop Class_obj_allocate(KlassHandle klass, int size, KlassHandle real_klass, TRAPS); | |
324 | |
0 | 325 // General obj/array allocation facilities. |
326 inline static oop obj_allocate(KlassHandle klass, int size, TRAPS); | |
327 inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS); | |
3961
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3774
diff
changeset
|
328 inline static oop array_allocate_nozero(KlassHandle klass, int size, int length, TRAPS); |
0 | 329 |
330 // Special obj/array allocation facilities. | |
331 // Some heaps may want to manage "permanent" data uniquely. These default | |
332 // to the general routines if the heap does not support such handling. | |
333 inline static oop permanent_obj_allocate(KlassHandle klass, int size, TRAPS); | |
334 // permanent_obj_allocate_no_klass_install() does not do the installation of | |
335 // the klass pointer in the newly created object (as permanent_obj_allocate() | |
336 // above does). This allows for a delay in the installation of the klass | |
337 // pointer that is needed during the create of klassKlass's. The | |
338 // method post_allocation_install_obj_klass() is used to install the | |
339 // klass pointer. | |
340 inline static oop permanent_obj_allocate_no_klass_install(KlassHandle klass, | |
341 int size, | |
342 TRAPS); | |
343 inline static void post_allocation_install_obj_klass(KlassHandle klass, | |
344 oop obj, | |
345 int size); | |
346 inline static oop permanent_array_allocate(KlassHandle klass, int size, int length, TRAPS); | |
347 | |
348 // Raw memory allocation facilities | |
349 // The obj and array allocate methods are covers for these methods. | |
350 // The permanent allocation method should default to mem_allocate if | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
3772
diff
changeset
|
351 // permanent memory isn't supported. mem_allocate() should never be |
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
3772
diff
changeset
|
352 // called to allocate TLABs, only individual objects. |
0 | 353 virtual HeapWord* mem_allocate(size_t size, |
354 bool* gc_overhead_limit_was_exceeded) = 0; | |
355 virtual HeapWord* permanent_mem_allocate(size_t size) = 0; | |
356 | |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
357 // Utilities for turning raw memory into filler objects. |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
358 // |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
359 // min_fill_size() is the smallest region that can be filled. |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
360 // fill_with_objects() can fill arbitrary-sized regions of the heap using |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
361 // multiple objects. fill_with_object() is for regions known to be smaller |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
362 // than the largest array of integers; it uses a single object to fill the |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
363 // region and has slightly less overhead. |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
364 static size_t min_fill_size() { |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
365 return size_t(align_object_size(oopDesc::header_size())); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
366 } |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
367 |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
368 static void fill_with_objects(HeapWord* start, size_t words, bool zap = true); |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
369 |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
370 static void fill_with_object(HeapWord* start, size_t words, bool zap = true); |
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
371 static void fill_with_object(MemRegion region, bool zap = true) { |
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
372 fill_with_object(region.start(), region.word_size(), zap); |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
373 } |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
374 static void fill_with_object(HeapWord* start, HeapWord* end, bool zap = true) { |
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
1027
diff
changeset
|
375 fill_with_object(start, pointer_delta(end, start), zap); |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
376 } |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
377 |
0 | 378 // Some heaps may offer a contiguous region for shared non-blocking |
379 // allocation, via inlined code (by exporting the address of the top and | |
380 // end fields defining the extent of the contiguous allocation region.) | |
381 | |
382 // This function returns "true" iff the heap supports this kind of | |
383 // allocation. (Default is "no".) | |
384 virtual bool supports_inline_contig_alloc() const { | |
385 return false; | |
386 } | |
387 // These functions return the addresses of the fields that define the | |
388 // boundaries of the contiguous allocation area. (These fields should be | |
389 // physically near to one another.) | |
390 virtual HeapWord** top_addr() const { | |
391 guarantee(false, "inline contiguous allocation not supported"); | |
392 return NULL; | |
393 } | |
394 virtual HeapWord** end_addr() const { | |
395 guarantee(false, "inline contiguous allocation not supported"); | |
396 return NULL; | |
397 } | |
398 | |
399 // Some heaps may be in an unparseable state at certain times between | |
400 // collections. This may be necessary for efficient implementation of | |
401 // certain allocation-related activities. Calling this function before | |
402 // attempting to parse a heap ensures that the heap is in a parsable | |
403 // state (provided other concurrent activity does not introduce | |
404 // unparsability). It is normally expected, therefore, that this | |
405 // method is invoked with the world stopped. | |
406 // NOTE: if you override this method, make sure you call | |
407 // super::ensure_parsability so that the non-generational | |
408 // part of the work gets done. See implementation of | |
409 // CollectedHeap::ensure_parsability and, for instance, | |
410 // that of GenCollectedHeap::ensure_parsability(). | |
411 // The argument "retire_tlabs" controls whether existing TLABs | |
412 // are merely filled or also retired, thus preventing further | |
413 // allocation from them and necessitating allocation of new TLABs. | |
414 virtual void ensure_parsability(bool retire_tlabs); | |
415 | |
416 // Return an estimate of the maximum allocation that could be performed | |
417 // without triggering any collection or expansion activity. In a | |
418 // generational collector, for example, this is probably the largest | |
419 // allocation that could be supported (without expansion) in the youngest | |
420 // generation. It is "unsafe" because no locks are taken; the result | |
421 // should be treated as an approximation, not a guarantee, for use in | |
422 // heuristic resizing decisions. | |
423 virtual size_t unsafe_max_alloc() = 0; | |
424 | |
425 // Section on thread-local allocation buffers (TLABs) | |
426 // If the heap supports thread-local allocation buffers, it should override | |
427 // the following methods: | |
428 // Returns "true" iff the heap supports thread-local allocation buffers. | |
429 // The default is "no". | |
430 virtual bool supports_tlab_allocation() const { | |
431 return false; | |
432 } | |
433 // The amount of space available for thread-local allocation buffers. | |
434 virtual size_t tlab_capacity(Thread *thr) const { | |
435 guarantee(false, "thread-local allocation buffers not supported"); | |
436 return 0; | |
437 } | |
438 // An estimate of the maximum allocation that could be performed | |
439 // for thread-local allocation buffers without triggering any | |
440 // collection or expansion activity. | |
441 virtual size_t unsafe_max_tlab_alloc(Thread *thr) const { | |
442 guarantee(false, "thread-local allocation buffers not supported"); | |
443 return 0; | |
444 } | |
1027
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
445 |
0 | 446 // Can a compiler initialize a new object without store barriers? |
447 // This permission only extends from the creation of a new object | |
1027
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
448 // via a TLAB up to the first subsequent safepoint. If such permission |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
449 // is granted for this heap type, the compiler promises to call |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
450 // defer_store_barrier() below on any slow path allocation of |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
451 // a new object for which such initializing store barriers will |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
452 // have been elided. |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
453 virtual bool can_elide_tlab_store_barriers() const = 0; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
454 |
0 | 455 // If a compiler is eliding store barriers for TLAB-allocated objects, |
456 // there is probably a corresponding slow path which can produce | |
457 // an object allocated anywhere. The compiler's runtime support | |
458 // promises to call this function on such a slow-path-allocated | |
459 // object before performing initializations that have elided | |
1027
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
460 // store barriers. Returns new_obj, or maybe a safer copy thereof. |
1166 | 461 virtual oop new_store_pre_barrier(JavaThread* thread, oop new_obj); |
1027
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
462 |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
463 // Answers whether an initializing store to a new object currently |
1166 | 464 // allocated at the given address doesn't need a store |
1027
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
465 // barrier. Returns "true" if it doesn't need an initializing |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
466 // store barrier; answers "false" if it does. |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
467 virtual bool can_elide_initializing_store_barrier(oop new_obj) = 0; |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
468 |
1166 | 469 // If a compiler is eliding store barriers for TLAB-allocated objects, |
470 // we will be informed of a slow-path allocation by a call | |
471 // to new_store_pre_barrier() above. Such a call precedes the | |
472 // initialization of the object itself, and no post-store-barriers will | |
473 // be issued. Some heap types require that the barrier strictly follows | |
474 // the initializing stores. (This is currently implemented by deferring the | |
475 // barrier until the next slow-path allocation or gc-related safepoint.) | |
476 // This interface answers whether a particular heap type needs the card | |
477 // mark to be thus strictly sequenced after the stores. | |
478 virtual bool card_mark_must_follow_store() const = 0; | |
479 | |
1027
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
480 // If the CollectedHeap was asked to defer a store barrier above, |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
481 // this informs it to flush such a deferred store barrier to the |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
482 // remembered set. |
39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
993
diff
changeset
|
483 virtual void flush_deferred_store_barrier(JavaThread* thread); |
0 | 484 |
485 // Can a compiler elide a store barrier when it writes | |
486 // a permanent oop into the heap? Applies when the compiler | |
487 // is storing x to the heap, where x->is_perm() is true. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
488 virtual bool can_elide_permanent_oop_store_barriers() const = 0; |
0 | 489 |
490 // Does this heap support heap inspection (+PrintClassHistogram?) | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
491 virtual bool supports_heap_inspection() const = 0; |
0 | 492 |
493 // Perform a collection of the heap; intended for use in implementing | |
494 // "System.gc". This probably implies as full a collection as the | |
495 // "CollectedHeap" supports. | |
496 virtual void collect(GCCause::Cause cause) = 0; | |
497 | |
498 // This interface assumes that it's being called by the | |
499 // vm thread. It collects the heap assuming that the | |
500 // heap lock is already held and that we are executing in | |
501 // the context of the vm thread. | |
502 virtual void collect_as_vm_thread(GCCause::Cause cause) = 0; | |
503 | |
504 // Returns the barrier set for this heap | |
505 BarrierSet* barrier_set() { return _barrier_set; } | |
506 | |
507 // Returns "true" iff there is a stop-world GC in progress. (I assume | |
508 // that it should answer "false" for the concurrent part of a concurrent | |
509 // collector -- dld). | |
510 bool is_gc_active() const { return _is_gc_active; } | |
511 | |
512 // Total number of GC collections (started) | |
513 unsigned int total_collections() const { return _total_collections; } | |
514 unsigned int total_full_collections() const { return _total_full_collections;} | |
515 | |
516 // Increment total number of GC collections (started) | |
517 // Should be protected but used by PSMarkSweep - cleanup for 1.4.2 | |
518 void increment_total_collections(bool full = false) { | |
519 _total_collections++; | |
520 if (full) { | |
521 increment_total_full_collections(); | |
522 } | |
523 } | |
524 | |
525 void increment_total_full_collections() { _total_full_collections++; } | |
526 | |
527 // Return the AdaptiveSizePolicy for the heap. | |
528 virtual AdaptiveSizePolicy* size_policy() = 0; | |
529 | |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1166
diff
changeset
|
530 // Return the CollectorPolicy for the heap |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1166
diff
changeset
|
531 virtual CollectorPolicy* collector_policy() const = 0; |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1166
diff
changeset
|
532 |
0 | 533 // Iterate over all the ref-containing fields of all objects, calling |
534 // "cl.do_oop" on each. This includes objects in permanent memory. | |
535 virtual void oop_iterate(OopClosure* cl) = 0; | |
536 | |
537 // Iterate over all objects, calling "cl.do_object" on each. | |
538 // This includes objects in permanent memory. | |
539 virtual void object_iterate(ObjectClosure* cl) = 0; | |
540 | |
517
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
541 // Similar to object_iterate() except iterates only |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
542 // over live objects. |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
543 virtual void safe_object_iterate(ObjectClosure* cl) = 0; |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
544 |
0 | 545 // Behaves the same as oop_iterate, except only traverses |
546 // interior pointers contained in permanent memory. If there | |
547 // is no permanent memory, does nothing. | |
548 virtual void permanent_oop_iterate(OopClosure* cl) = 0; | |
549 | |
550 // Behaves the same as object_iterate, except only traverses | |
551 // object contained in permanent memory. If there is no | |
552 // permanent memory, does nothing. | |
553 virtual void permanent_object_iterate(ObjectClosure* cl) = 0; | |
554 | |
555 // NOTE! There is no requirement that a collector implement these | |
556 // functions. | |
557 // | |
558 // A CollectedHeap is divided into a dense sequence of "blocks"; that is, | |
559 // each address in the (reserved) heap is a member of exactly | |
560 // one block. The defining characteristic of a block is that it is | |
561 // possible to find its size, and thus to progress forward to the next | |
562 // block. (Blocks may be of different sizes.) Thus, blocks may | |
563 // represent Java objects, or they might be free blocks in a | |
564 // free-list-based heap (or subheap), as long as the two kinds are | |
565 // distinguishable and the size of each is determinable. | |
566 | |
567 // Returns the address of the start of the "block" that contains the | |
568 // address "addr". We say "blocks" instead of "object" since some heaps | |
569 // may not pack objects densely; a chunk may either be an object or a | |
570 // non-object. | |
571 virtual HeapWord* block_start(const void* addr) const = 0; | |
572 | |
573 // Requires "addr" to be the start of a chunk, and returns its size. | |
574 // "addr + size" is required to be the start of a new chunk, or the end | |
575 // of the active area of the heap. | |
576 virtual size_t block_size(const HeapWord* addr) const = 0; | |
577 | |
578 // Requires "addr" to be the start of a block, and returns "TRUE" iff | |
579 // the block is an object. | |
580 virtual bool block_is_obj(const HeapWord* addr) const = 0; | |
581 | |
582 // Returns the longest time (in ms) that has elapsed since the last | |
583 // time that any part of the heap was examined by a garbage collection. | |
584 virtual jlong millis_since_last_gc() = 0; | |
585 | |
586 // Perform any cleanup actions necessary before allowing a verification. | |
587 virtual void prepare_for_verify() = 0; | |
588 | |
615
c6c601a0f2d6
6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents:
542
diff
changeset
|
589 // Generate any dumps preceding or following a full gc |
c6c601a0f2d6
6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents:
542
diff
changeset
|
590 void pre_full_gc_dump(); |
c6c601a0f2d6
6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents:
542
diff
changeset
|
591 void post_full_gc_dump(); |
c6c601a0f2d6
6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents:
542
diff
changeset
|
592 |
4073
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
593 // Print heap information on the given outputStream. |
0 | 594 virtual void print_on(outputStream* st) const = 0; |
4073
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
595 // The default behavior is to call print_on() on tty. |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
596 virtual void print() const { |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
597 print_on(tty); |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
598 } |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
599 // Print more detailed heap information on the given |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
600 // outputStream. The default behaviour is to call print_on(). It is |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
601 // up to each subclass to override it and add any additional output |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
602 // it needs. |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
603 virtual void print_extended_on(outputStream* st) const { |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
604 print_on(st); |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
605 } |
0 | 606 |
607 // Print all GC threads (other than the VM thread) | |
608 // used by this heap. | |
609 virtual void print_gc_threads_on(outputStream* st) const = 0; | |
4073
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
610 // The default behavior is to call print_gc_threads_on() on tty. |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
611 void print_gc_threads() { |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
612 print_gc_threads_on(tty); |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
4009
diff
changeset
|
613 } |
0 | 614 // Iterator for all GC threads (other than VM thread) |
615 virtual void gc_threads_do(ThreadClosure* tc) const = 0; | |
616 | |
617 // Print any relevant tracing info that flags imply. | |
618 // Default implementation does nothing. | |
619 virtual void print_tracing_info() const = 0; | |
620 | |
621 // Heap verification | |
3772
6747fd0512e0
7004681: G1: Extend marking verification to Full GCs
johnc
parents:
3377
diff
changeset
|
622 virtual void verify(bool allow_dirty, bool silent, VerifyOption option) = 0; |
0 | 623 |
624 // Non product verification and debugging. | |
625 #ifndef PRODUCT | |
626 // Support for PromotionFailureALot. Return true if it's time to cause a | |
627 // promotion failure. The no-argument version uses | |
628 // this->_promotion_failure_alot_count as the counter. | |
629 inline bool promotion_should_fail(volatile size_t* count); | |
630 inline bool promotion_should_fail(); | |
631 | |
632 // Reset the PromotionFailureALot counters. Should be called at the end of a | |
633 // GC in which promotion failure ocurred. | |
634 inline void reset_promotion_should_fail(volatile size_t* count); | |
635 inline void reset_promotion_should_fail(); | |
636 #endif // #ifndef PRODUCT | |
637 | |
638 #ifdef ASSERT | |
639 static int fired_fake_oom() { | |
640 return (CIFireOOMAt > 1 && _fire_out_of_memory_count >= CIFireOOMAt); | |
641 } | |
642 #endif | |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
643 |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
644 public: |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
645 // This is a convenience method that is used in cases where |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
646 // the actual number of GC worker threads is not pertinent but |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
647 // only whether there more than 0. Use of this method helps |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
648 // reduce the occurrence of ParallelGCThreads to uses where the |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
649 // actual number may be germane. |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
650 static bool use_parallel_gc_threads() { return ParallelGCThreads > 0; } |
4708 | 651 |
652 /////////////// Unit tests /////////////// | |
653 | |
654 NOT_PRODUCT(static void test_is_in();) | |
0 | 655 }; |
656 | |
657 // Class to set and reset the GC cause for a CollectedHeap. | |
658 | |
659 class GCCauseSetter : StackObj { | |
660 CollectedHeap* _heap; | |
661 GCCause::Cause _previous_cause; | |
662 public: | |
663 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) { | |
664 assert(SafepointSynchronize::is_at_safepoint(), | |
665 "This method manipulates heap state without locking"); | |
666 _heap = heap; | |
667 _previous_cause = _heap->gc_cause(); | |
668 _heap->set_gc_cause(cause); | |
669 } | |
670 | |
671 ~GCCauseSetter() { | |
672 assert(SafepointSynchronize::is_at_safepoint(), | |
673 "This method manipulates heap state without locking"); | |
674 _heap->set_gc_cause(_previous_cause); | |
675 } | |
676 }; | |
1972 | 677 |
678 #endif // SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP |