1 /*
2 * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_G1_HEAPREGION_HPP
26 #define SHARE_GC_G1_HEAPREGION_HPP
27
28 #include "gc/g1/g1BlockOffsetTable.hpp"
29 #include "gc/g1/g1HeapRegionTraceType.hpp"
30 #include "gc/g1/g1SurvRateGroup.hpp"
31 #include "gc/g1/heapRegionTracer.hpp"
32 #include "gc/g1/heapRegionType.hpp"
33 #include "gc/shared/ageTable.hpp"
34 #include "gc/shared/spaceDecorator.hpp"
35 #include "gc/shared/verifyOption.hpp"
36 #include "runtime/mutex.hpp"
37 #include "utilities/macros.hpp"
38
39 class G1CollectedHeap;
40 class G1CMBitMap;
41 class G1Predictions;
42 class HeapRegionRemSet;
43 class HeapRegion;
44 class HeapRegionSetBase;
45 class nmethod;
46
47 #define HR_FORMAT "%u:(%s)[" PTR_FORMAT "," PTR_FORMAT "," PTR_FORMAT "]"
48 #define HR_FORMAT_PARAMS(_hr_) \
49 (_hr_)->hrm_index(), \
50 (_hr_)->get_short_type_str(), \
51 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
52
53 // sentinel value for hrm_index
54 #define G1_NO_HRM_INDEX ((uint) -1)
55
56 // A HeapRegion is the smallest piece of a G1CollectedHeap that
57 // can be collected independently.
58
59 // Each heap region is self contained. top() and end() can never
60 // be set beyond the end of the region. For humongous objects,
61 // the first region is a StartsHumongous region. If the humongous
62 // object is larger than a heap region, the following regions will
63 // be of type ContinuesHumongous. In this case the top() of the
64 // StartHumongous region and all ContinuesHumongous regions except
65 // the last will point to their own end. The last ContinuesHumongous
66 // region may have top() equal the end of object if there isn't
67 // room for filler objects to pad out to the end of the region.
68 class HeapRegion : public CHeapObj<mtGC> {
69 friend class VMStructs;
70
71 HeapWord* const _bottom;
72 HeapWord* const _end;
73
74 HeapWord* volatile _top;
75 HeapWord* _compaction_top;
76
77 G1BlockOffsetTablePart _bot_part;
78 Mutex _par_alloc_lock;
79 // When we need to retire an allocation region, while other threads
80 // are also concurrently trying to allocate into it, we typically
81 // allocate a dummy object at the end of the region to ensure that
82 // no more allocations can take place in it. However, sometimes we
83 // want to know where the end of the last "real" object we allocated
84 // into the region was and this is what this keeps track.
85 HeapWord* _pre_dummy_top;
86
87 public:
88 HeapWord* bottom() const { return _bottom; }
89 HeapWord* end() const { return _end; }
90
91 void set_compaction_top(HeapWord* compaction_top) { _compaction_top = compaction_top; }
92 HeapWord* compaction_top() const { return _compaction_top; }
93
94 void set_top(HeapWord* value) { _top = value; }
95 HeapWord* top() const { return _top; }
96
97 // See the comment above in the declaration of _pre_dummy_top for an
98 // explanation of what it is.
99 void set_pre_dummy_top(HeapWord* pre_dummy_top) {
100 assert(is_in(pre_dummy_top) && pre_dummy_top <= top(), "pre-condition");
101 _pre_dummy_top = pre_dummy_top;
102 }
103 HeapWord* pre_dummy_top() { return (_pre_dummy_top == NULL) ? top() : _pre_dummy_top; }
104 void reset_pre_dummy_top() { _pre_dummy_top = NULL; }
105
106 // Returns true iff the given the heap region contains the
107 // given address as part of an allocated object. This may
108 // be a potentially, so we restrict its use to assertion checks only.
109 bool is_in(const void* p) const {
110 return is_in_reserved(p);
111 }
112 bool is_in(oop obj) const {
113 return is_in((void*)obj);
114 }
115 // Returns true iff the given reserved memory of the space contains the
116 // given address.
117 bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; }
118
119 size_t capacity() const { return byte_size(bottom(), end()); }
120 size_t used() const { return byte_size(bottom(), top()); }
121 size_t free() const { return byte_size(top(), end()); }
122
123 bool is_empty() const { return used() == 0; }
124
125 private:
126 void reset_compaction_top_after_compaction();
127
128 void reset_after_full_gc_common();
129
130 void clear(bool mangle_space);
131
132 HeapWord* block_start_const(const void* p) const;
133
134 void mangle_unused_area() PRODUCT_RETURN;
135
136 // Try to allocate at least min_word_size and up to desired_size from this region.
137 // Returns NULL if not possible, otherwise sets actual_word_size to the amount of
138 // space allocated.
139 // This version assumes that all allocation requests to this HeapRegion are properly
140 // synchronized.
141 inline HeapWord* allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
142 // Try to allocate at least min_word_size and up to desired_size from this HeapRegion.
143 // Returns NULL if not possible, otherwise sets actual_word_size to the amount of
144 // space allocated.
145 // This version synchronizes with other calls to par_allocate_impl().
146 inline HeapWord* par_allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
147
148 template<bool RESOLVE>149 void object_iterate_impl(ObjectClosure* blk);150
151 public:
152 HeapWord* block_start(const void* p);
153
154 void object_iterate(ObjectClosure* blk);
155
156 // Allocation (return NULL if full). Assumes the caller has established
157 // mutually exclusive access to the HeapRegion.
158 HeapWord* allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
159 // Allocation (return NULL if full). Enforces mutual exclusion internally.
160 HeapWord* par_allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
161
162 HeapWord* allocate(size_t word_size);
163 HeapWord* par_allocate(size_t word_size);
164
165 inline HeapWord* par_allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* word_size);
166 inline HeapWord* allocate_no_bot_updates(size_t word_size);
167 inline HeapWord* allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* actual_size);
168
169 // Full GC support methods.
170
171 HeapWord* initialize_threshold();
172 HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
173
174 // Update heap region that has been compacted to be consistent after Full GC.
175 void reset_compacted_after_full_gc();
176 // Update skip-compacting heap region to be consistent after Full GC.
177 void reset_skip_compacting_after_full_gc();
178
179 // All allocated blocks are occupied by objects in a HeapRegion
180 bool block_is_obj(const HeapWord* p) const;
181
182 // Returns whether the given object is dead based on TAMS and bitmap.
183 // An object is dead iff a) it was not allocated since the last mark (>TAMS), b) it
184 // is not marked (bitmap).
185 bool is_obj_dead(const oop obj, const G1CMBitMap* const prev_bitmap) const;
186
187 // Returns the object size for all valid block starts
188 // and the amount of unallocated words if called on top()
189 template<bool RESOLVE = false>
190 size_t block_size(const HeapWord* p) const;
191
192 // Scans through the region using the bitmap to determine what
193 // objects to call size_t ApplyToMarkedClosure::apply(oop) for.
194 template<typename ApplyToMarkedClosure>
195 inline void apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarkedClosure* closure);
196
197 void reset_bot() {
198 _bot_part.reset_bot();
199 }
200
201 void update_bot() {
202 _bot_part.update();
203 }
204
205 private:
206 // The remembered set for this region.
207 HeapRegionRemSet* _rem_set;
208
209 // Cached index of this region in the heap region sequence.
210 const uint _hrm_index;
211
212 HeapRegionType _type;
213
214 // For a humongous region, region in which it starts.
215 HeapRegion* _humongous_start_region;
216
217 static const uint InvalidCSetIndex = UINT_MAX;
218
219 // The index in the optional regions array, if this region
220 // is considered optional during a mixed collections.
221 uint _index_in_opt_cset;
222
223 // Fields used by the HeapRegionSetBase class and subclasses.
224 HeapRegion* _next;
225 HeapRegion* _prev;
226 #ifdef ASSERT
227 HeapRegionSetBase* _containing_set;
228 #endif // ASSERT
229
230 // The start of the unmarked area. The unmarked area extends from this
231 // word until the top and/or end of the region, and is the part
232 // of the region for which no marking was done, i.e. objects may
233 // have been allocated in this part since the last mark phase.
234 // "prev" is the top at the start of the last completed marking.
235 // "next" is the top at the start of the in-progress marking (if any.)
236 HeapWord* _prev_top_at_mark_start;
237 HeapWord* _next_top_at_mark_start;
238
239 // We use concurrent marking to determine the amount of live data
240 // in each heap region.
241 size_t _prev_marked_bytes; // Bytes known to be live via last completed marking.
242 size_t _next_marked_bytes; // Bytes known to be live via in-progress marking.
243
244 void init_top_at_mark_start() {
245 assert(_prev_marked_bytes == 0 &&
246 _next_marked_bytes == 0,
247 "Must be called after zero_marked_bytes.");
248 _prev_top_at_mark_start = _next_top_at_mark_start = bottom();
249 }
250
251 // Data for young region survivor prediction.
252 uint _young_index_in_cset;
253 G1SurvRateGroup* _surv_rate_group;
254 int _age_index;
255
256 // Cached attributes used in the collection set policy information
257
258 // The calculated GC efficiency of the region.
259 double _gc_efficiency;
260
261 uint _node_index;
262
263 void report_region_type_change(G1HeapRegionTraceType::Type to);
264
265 // Returns whether the given object address refers to a dead object, and either the
266 // size of the object (if live) or the size of the block (if dead) in size.
267 // May
268 // - only called with obj < top()
269 // - not called on humongous objects or archive regions
270 inline bool is_obj_dead_with_size(const oop obj, const G1CMBitMap* const prev_bitmap, size_t* size) const;
271
272 // Iterate over the references covered by the given MemRegion in a humongous
273 // object and apply the given closure to them.
274 // Humongous objects are allocated directly in the old-gen. So we need special
275 // handling for concurrent processing encountering an in-progress allocation.
276 // Returns the address after the last actually scanned or NULL if the area could
277 // not be scanned (That should only happen when invoked concurrently with the
278 // mutator).
279 template <class Closure, bool is_gc_active>
280 inline HeapWord* do_oops_on_memregion_in_humongous(MemRegion mr,
281 Closure* cl,
282 G1CollectedHeap* g1h);
283
284 // Returns the block size of the given (dead, potentially having its class unloaded) object
285 // starting at p extending to at most the prev TAMS using the given mark bitmap.
286 inline size_t block_size_using_bitmap(const HeapWord* p, const G1CMBitMap* const prev_bitmap) const;
287 public:
288 HeapRegion(uint hrm_index, G1BlockOffsetTable* bot, MemRegion mr);
289
290 // If this region is a member of a HeapRegionManager, the index in that
291 // sequence, otherwise -1.
292 uint hrm_index() const { return _hrm_index; }
293
294 // Initializing the HeapRegion not only resets the data structure, but also
295 // resets the BOT for that heap region.
296 // The default values for clear_space means that we will do the clearing if
297 // there's clearing to be done ourselves. We also always mangle the space.
298 void initialize(bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
299
300 static int LogOfHRGrainBytes;
301 static int LogCardsPerRegion;
302
303 static size_t GrainBytes;
304 static size_t GrainWords;
305 static size_t CardsPerRegion;
306
307 static size_t align_up_to_region_byte_size(size_t sz) {
308 return (sz + (size_t) GrainBytes - 1) &
309 ~((1 << (size_t) LogOfHRGrainBytes) - 1);
310 }
311
312 // Returns whether a field is in the same region as the obj it points to.
313 template <typename T>
314 static bool is_in_same_region(T* p, oop obj) {
315 assert(p != NULL, "p can't be NULL");
316 assert(obj != NULL, "obj can't be NULL");
317 return (((uintptr_t) p ^ cast_from_oop<uintptr_t>(obj)) >> LogOfHRGrainBytes) == 0;
318 }
319
320 static size_t max_region_size();
321 static size_t min_region_size_in_words();
322
323 // It sets up the heap region size (GrainBytes / GrainWords), as well as
324 // other related fields that are based on the heap region size
325 // (LogOfHRGrainBytes / CardsPerRegion). All those fields are considered
326 // constant throughout the JVM's execution, therefore they should only be set
327 // up once during initialization time.
328 static void setup_heap_region_size(size_t max_heap_size);
329
330 // The number of bytes marked live in the region in the last marking phase.
331 size_t marked_bytes() { return _prev_marked_bytes; }
332 size_t live_bytes() {
333 return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes();
334 }
335
336 // The number of bytes counted in the next marking.
337 size_t next_marked_bytes() { return _next_marked_bytes; }
338 // The number of bytes live wrt the next marking.
339 size_t next_live_bytes() {
340 return
341 (top() - next_top_at_mark_start()) * HeapWordSize + next_marked_bytes();
342 }
343
344 // A lower bound on the amount of garbage bytes in the region.
345 size_t garbage_bytes() {
346 size_t used_at_mark_start_bytes =
347 (prev_top_at_mark_start() - bottom()) * HeapWordSize;
348 return used_at_mark_start_bytes - marked_bytes();
349 }
350
351 // Return the amount of bytes we'll reclaim if we collect this
352 // region. This includes not only the known garbage bytes in the
353 // region but also any unallocated space in it, i.e., [top, end),
354 // since it will also be reclaimed if we collect the region.
355 size_t reclaimable_bytes() {
356 size_t known_live_bytes = live_bytes();
357 assert(known_live_bytes <= capacity(), "sanity");
358 return capacity() - known_live_bytes;
359 }
360
361 // An upper bound on the number of live bytes in the region.
362 size_t max_live_bytes() { return used() - garbage_bytes(); }
363
364 void add_to_marked_bytes(size_t incr_bytes) {
365 _next_marked_bytes = _next_marked_bytes + incr_bytes;
366 }
367
368 void zero_marked_bytes() {
369 _prev_marked_bytes = _next_marked_bytes = 0;
370 }
371 // Get the start of the unmarked area in this region.
372 HeapWord* prev_top_at_mark_start() const { return _prev_top_at_mark_start; }
373 HeapWord* next_top_at_mark_start() const { return _next_top_at_mark_start; }
374
375 // Note the start or end of marking. This tells the heap region
376 // that the collector is about to start or has finished (concurrently)
377 // marking the heap.
378
379 // Notify the region that concurrent marking is starting. Initialize
380 // all fields related to the next marking info.
381 inline void note_start_of_marking();
382
383 // Notify the region that concurrent marking has finished. Copy the
384 // (now finalized) next marking info fields into the prev marking
385 // info fields.
386 inline void note_end_of_marking();
387
388 const char* get_type_str() const { return _type.get_str(); }
389 const char* get_short_type_str() const { return _type.get_short_str(); }
390 G1HeapRegionTraceType::Type get_trace_type() { return _type.get_trace_type(); }
391
392 bool is_free() const { return _type.is_free(); }
393
394 bool is_young() const { return _type.is_young(); }
395 bool is_eden() const { return _type.is_eden(); }
396 bool is_survivor() const { return _type.is_survivor(); }
397
398 bool is_humongous() const { return _type.is_humongous(); }
399 bool is_starts_humongous() const { return _type.is_starts_humongous(); }
400 bool is_continues_humongous() const { return _type.is_continues_humongous(); }
401
402 bool is_old() const { return _type.is_old(); }
403
404 bool is_old_or_humongous() const { return _type.is_old_or_humongous(); }
405
406 bool is_old_or_humongous_or_archive() const { return _type.is_old_or_humongous_or_archive(); }
407
408 // A pinned region contains objects which are not moved by garbage collections.
409 // Humongous regions and archive regions are pinned.
410 bool is_pinned() const { return _type.is_pinned(); }
411
412 // An archive region is a pinned region, also tagged as old, which
413 // should not be marked during mark/sweep. This allows the address
414 // space to be shared by JVM instances.
415 bool is_archive() const { return _type.is_archive(); }
416 bool is_open_archive() const { return _type.is_open_archive(); }
417 bool is_closed_archive() const { return _type.is_closed_archive(); }
418
419 void set_free();
420
421 void set_eden();
422 void set_eden_pre_gc();
423 void set_survivor();
424
425 void move_to_old();
426 void set_old();
427
428 void set_open_archive();
429 void set_closed_archive();
430
431 // For a humongous region, region in which it starts.
432 HeapRegion* humongous_start_region() const {
433 return _humongous_start_region;
434 }
435
436 // Makes the current region be a "starts humongous" region, i.e.,
437 // the first region in a series of one or more contiguous regions
438 // that will contain a single "humongous" object.
439 //
440 // obj_top : points to the top of the humongous object.
441 // fill_size : size of the filler object at the end of the region series.
442 void set_starts_humongous(HeapWord* obj_top, size_t fill_size);
443
444 // Makes the current region be a "continues humongous'
445 // region. first_hr is the "start humongous" region of the series
446 // which this region will be part of.
447 void set_continues_humongous(HeapRegion* first_hr);
448
449 // Unsets the humongous-related fields on the region.
450 void clear_humongous();
451
452 // If the region has a remembered set, return a pointer to it.
453 HeapRegionRemSet* rem_set() const {
454 return _rem_set;
455 }
456
457 inline bool in_collection_set() const;
458
459 // Methods used by the HeapRegionSetBase class and subclasses.
460
461 // Getter and setter for the next and prev fields used to link regions into
462 // linked lists.
463 void set_next(HeapRegion* next) { _next = next; }
464 HeapRegion* next() { return _next; }
465
466 void set_prev(HeapRegion* prev) { _prev = prev; }
467 HeapRegion* prev() { return _prev; }
468
469 void unlink_from_list();
470
471 // Every region added to a set is tagged with a reference to that
472 // set. This is used for doing consistency checking to make sure that
473 // the contents of a set are as they should be and it's only
474 // available in non-product builds.
475 #ifdef ASSERT
476 void set_containing_set(HeapRegionSetBase* containing_set) {
477 assert((containing_set != NULL && _containing_set == NULL) ||
478 containing_set == NULL,
479 "containing_set: " PTR_FORMAT " "
480 "_containing_set: " PTR_FORMAT,
481 p2i(containing_set), p2i(_containing_set));
482
483 _containing_set = containing_set;
484 }
485
486 HeapRegionSetBase* containing_set() { return _containing_set; }
487 #else // ASSERT
488 void set_containing_set(HeapRegionSetBase* containing_set) { }
489
490 // containing_set() is only used in asserts so there's no reason
491 // to provide a dummy version of it.
492 #endif // ASSERT
493
494
495 // Reset the HeapRegion to default values and clear its remembered set.
496 // If clear_space is true, clear the HeapRegion's memory.
497 // Callers must ensure this is not called by multiple threads at the same time.
498 void hr_clear(bool clear_space);
499 // Clear the card table corresponding to this region.
500 void clear_cardtable();
501
502 // Notify the region that we are about to start processing
503 // self-forwarded objects during evac failure handling.
504 void note_self_forwarding_removal_start(bool during_concurrent_start,
505 bool during_conc_mark);
506
507 // Notify the region that we have finished processing self-forwarded
508 // objects during evac failure handling.
509 void note_self_forwarding_removal_end(size_t marked_bytes);
510
511 uint index_in_opt_cset() const {
512 assert(has_index_in_opt_cset(), "Opt cset index not set.");
513 return _index_in_opt_cset;
514 }
515 bool has_index_in_opt_cset() const { return _index_in_opt_cset != InvalidCSetIndex; }
516 void set_index_in_opt_cset(uint index) { _index_in_opt_cset = index; }
517 void clear_index_in_opt_cset() { _index_in_opt_cset = InvalidCSetIndex; }
518
519 void calc_gc_efficiency(void);
520 double gc_efficiency() const { return _gc_efficiency;}
521
522 uint young_index_in_cset() const { return _young_index_in_cset; }
523 void clear_young_index_in_cset() { _young_index_in_cset = 0; }
524 void set_young_index_in_cset(uint index) {
525 assert(index != UINT_MAX, "just checking");
526 assert(index != 0, "just checking");
527 assert(is_young(), "pre-condition");
528 _young_index_in_cset = index;
529 }
530
531 int age_in_surv_rate_group() const;
532 bool has_valid_age_in_surv_rate() const;
533
534 bool has_surv_rate_group() const;
535
536 double surv_rate_prediction(G1Predictions const& predictor) const;
537
538 void install_surv_rate_group(G1SurvRateGroup* surv_rate_group);
539 void uninstall_surv_rate_group();
540
541 void record_surv_words_in_group(size_t words_survived);
542
543 // Determine if an object has been allocated since the last
544 // mark performed by the collector. This returns true iff the object
545 // is within the unmarked area of the region.
546 bool obj_allocated_since_prev_marking(oop obj) const {
547 return cast_from_oop<HeapWord*>(obj) >= prev_top_at_mark_start();
548 }
549 bool obj_allocated_since_next_marking(oop obj) const {
550 return cast_from_oop<HeapWord*>(obj) >= next_top_at_mark_start();
551 }
552
553 // Update the region state after a failed evacuation.
554 void handle_evacuation_failure();
555
556 // Iterate over the objects overlapping the given memory region, applying cl
557 // to all references in the region. This is a helper for
558 // G1RemSet::refine_card*, and is tightly coupled with them.
559 // mr must not be empty. Must be trimmed to the allocated/parseable space in this region.
560 // This region must be old or humongous.
561 // Returns the next unscanned address if the designated objects were successfully
562 // processed, NULL if an unparseable part of the heap was encountered (That should
563 // only happen when invoked concurrently with the mutator).
564 template <bool is_gc_active, class Closure>
565 inline HeapWord* oops_on_memregion_seq_iterate_careful(MemRegion mr, Closure* cl);
566
567 // Routines for managing a list of code roots (attached to the
568 // this region's RSet) that point into this heap region.
569 void add_strong_code_root(nmethod* nm);
570 void add_strong_code_root_locked(nmethod* nm);
571 void remove_strong_code_root(nmethod* nm);
572
573 // Applies blk->do_code_blob() to each of the entries in
574 // the strong code roots list for this region
575 void strong_code_roots_do(CodeBlobClosure* blk) const;
576
577 uint node_index() const { return _node_index; }
578 void set_node_index(uint node_index) { _node_index = node_index; }
579
580 // Verify that the entries on the strong code root list for this
581 // region are live and include at least one pointer into this region.
582 void verify_strong_code_roots(VerifyOption vo, bool* failures) const;
583
584 void print() const;
585 void print_on(outputStream* st) const;
586
587 // vo == UsePrevMarking -> use "prev" marking information,
588 // vo == UseNextMarking -> use "next" marking information
589 // vo == UseFullMarking -> use "next" marking bitmap but no TAMS
590 //
591 // NOTE: Only the "prev" marking information is guaranteed to be
592 // consistent most of the time, so most calls to this should use
593 // vo == UsePrevMarking.
594 // Currently, there is only one case where this is called with
595 // vo == UseNextMarking, which is to verify the "next" marking
596 // information at the end of remark.
597 // Currently there is only one place where this is called with
598 // vo == UseFullMarking, which is to verify the marking during a
599 // full GC.
600 void verify(VerifyOption vo, bool *failures) const;
601
602 // Verify using the "prev" marking information
603 void verify() const;
604
605 void verify_rem_set(VerifyOption vo, bool *failures) const;
606 void verify_rem_set() const;
607 };
608
609 // HeapRegionClosure is used for iterating over regions.
610 // Terminates the iteration when the "do_heap_region" method returns "true".
611 class HeapRegionClosure : public StackObj {
612 friend class HeapRegionManager;
613 friend class G1CollectionSet;
614 friend class G1CollectionSetCandidates;
615
616 bool _is_complete;
617 void set_incomplete() { _is_complete = false; }
618
619 public:
620 HeapRegionClosure(): _is_complete(true) {}
621
622 // Typically called on each region until it returns true.
623 virtual bool do_heap_region(HeapRegion* r) = 0;
624
625 // True after iteration if the closure was applied to all heap regions
626 // and returned "false" in all cases.
627 bool is_complete() { return _is_complete; }
628 };
629
630 #endif // SHARE_GC_G1_HEAPREGION_HPP
--- EOF ---