comparison src/share/vm/gc_implementation/g1/heapRegion.hpp @ 20481:c02ec279b062

8057768: Make heap region region type in G1 HeapRegion explicit Reviewed-by: brutisso, tschatzl
author brutisso
date Tue, 16 Sep 2014 14:27:40 +0200
parents d35872270666
children 7baf47cb97cb
comparison
equal deleted inserted replaced
20478:00448aa81791 20481:c02ec279b062
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP
27 27
28 #include "gc_implementation/g1/g1AllocationContext.hpp" 28 #include "gc_implementation/g1/g1AllocationContext.hpp"
29 #include "gc_implementation/g1/g1BlockOffsetTable.hpp" 29 #include "gc_implementation/g1/g1BlockOffsetTable.hpp"
30 #include "gc_implementation/g1/g1_specialized_oop_closures.hpp" 30 #include "gc_implementation/g1/g1_specialized_oop_closures.hpp"
31 #include "gc_implementation/g1/heapRegionType.hpp"
31 #include "gc_implementation/g1/survRateGroup.hpp" 32 #include "gc_implementation/g1/survRateGroup.hpp"
32 #include "gc_implementation/shared/ageTable.hpp" 33 #include "gc_implementation/shared/ageTable.hpp"
33 #include "gc_implementation/shared/spaceDecorator.hpp" 34 #include "gc_implementation/shared/spaceDecorator.hpp"
34 #include "memory/space.inline.hpp" 35 #include "memory/space.inline.hpp"
35 #include "memory/watermark.hpp" 36 #include "memory/watermark.hpp"
36 #include "utilities/macros.hpp" 37 #include "utilities/macros.hpp"
37 38
38 #if INCLUDE_ALL_GCS
39
40 // A HeapRegion is the smallest piece of a G1CollectedHeap that 39 // A HeapRegion is the smallest piece of a G1CollectedHeap that
41 // can be collected independently. 40 // can be collected independently.
42 41
43 // NOTE: Although a HeapRegion is a Space, its 42 // NOTE: Although a HeapRegion is a Space, its
44 // Space::initDirtyCardClosure method must not be called. 43 // Space::initDirtyCardClosure method must not be called.
54 class nmethod; 53 class nmethod;
55 54
56 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]" 55 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
57 #define HR_FORMAT_PARAMS(_hr_) \ 56 #define HR_FORMAT_PARAMS(_hr_) \
58 (_hr_)->hrm_index(), \ 57 (_hr_)->hrm_index(), \
59 (_hr_)->is_survivor() ? "S" : (_hr_)->is_young() ? "E" : \ 58 (_hr_)->get_short_type_str(), \
60 (_hr_)->startsHumongous() ? "HS" : \
61 (_hr_)->continuesHumongous() ? "HC" : \
62 !(_hr_)->is_empty() ? "O" : "F", \
63 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end()) 59 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
64 60
65 // sentinel value for hrm_index 61 // sentinel value for hrm_index
66 #define G1_NO_HRM_INDEX ((uint) -1) 62 #define G1_NO_HRM_INDEX ((uint) -1)
67 63
218 214
219 class HeapRegion: public G1OffsetTableContigSpace { 215 class HeapRegion: public G1OffsetTableContigSpace {
220 friend class VMStructs; 216 friend class VMStructs;
221 private: 217 private:
222 218
223 enum HumongousType {
224 NotHumongous = 0,
225 StartsHumongous,
226 ContinuesHumongous
227 };
228
229 // The remembered set for this region. 219 // The remembered set for this region.
230 // (Might want to make this "inline" later, to avoid some alloc failure 220 // (Might want to make this "inline" later, to avoid some alloc failure
231 // issues.) 221 // issues.)
232 HeapRegionRemSet* _rem_set; 222 HeapRegionRemSet* _rem_set;
233 223
237 // The index of this region in the heap region sequence. 227 // The index of this region in the heap region sequence.
238 uint _hrm_index; 228 uint _hrm_index;
239 229
240 AllocationContext_t _allocation_context; 230 AllocationContext_t _allocation_context;
241 231
242 HumongousType _humongous_type; 232 HeapRegionType _type;
233
243 // For a humongous region, region in which it starts. 234 // For a humongous region, region in which it starts.
244 HeapRegion* _humongous_start_region; 235 HeapRegion* _humongous_start_region;
245 // For the start region of a humongous sequence, it's original end(). 236 // For the start region of a humongous sequence, it's original end().
246 HeapWord* _orig_end; 237 HeapWord* _orig_end;
247 238
279 size_t _next_marked_bytes; // Bytes known to be live via in-progress marking. 270 size_t _next_marked_bytes; // Bytes known to be live via in-progress marking.
280 271
281 // The calculated GC efficiency of the region. 272 // The calculated GC efficiency of the region.
282 double _gc_efficiency; 273 double _gc_efficiency;
283 274
284 enum YoungType {
285 NotYoung, // a region is not young
286 Young, // a region is young
287 Survivor // a region is young and it contains survivors
288 };
289
290 volatile YoungType _young_type;
291 int _young_index_in_cset; 275 int _young_index_in_cset;
292 SurvRateGroup* _surv_rate_group; 276 SurvRateGroup* _surv_rate_group;
293 int _age_index; 277 int _age_index;
294 278
295 // The start of the unmarked area. The unmarked area extends from this 279 // The start of the unmarked area. The unmarked area extends from this
308 _next_marked_bytes == 0, 292 _next_marked_bytes == 0,
309 "Must be called after zero_marked_bytes."); 293 "Must be called after zero_marked_bytes.");
310 HeapWord* bot = bottom(); 294 HeapWord* bot = bottom();
311 _prev_top_at_mark_start = bot; 295 _prev_top_at_mark_start = bot;
312 _next_top_at_mark_start = bot; 296 _next_top_at_mark_start = bot;
313 }
314
315 void set_young_type(YoungType new_type) {
316 //assert(_young_type != new_type, "setting the same type" );
317 // TODO: add more assertions here
318 _young_type = new_type;
319 } 297 }
320 298
321 // Cached attributes used in the collection set policy information 299 // Cached attributes used in the collection set policy information
322 300
323 // The RSet length that was added to the total value 301 // The RSet length that was added to the total value
435 413
436 void zero_marked_bytes() { 414 void zero_marked_bytes() {
437 _prev_marked_bytes = _next_marked_bytes = 0; 415 _prev_marked_bytes = _next_marked_bytes = 0;
438 } 416 }
439 417
440 bool isHumongous() const { return _humongous_type != NotHumongous; } 418 const char* get_type_str() const { return _type.get_str(); }
441 bool startsHumongous() const { return _humongous_type == StartsHumongous; } 419 const char* get_short_type_str() const { return _type.get_short_str(); }
442 bool continuesHumongous() const { return _humongous_type == ContinuesHumongous; } 420
421 bool is_free() const { return _type.is_free(); }
422
423 bool is_young() const { return _type.is_young(); }
424 bool is_eden() const { return _type.is_eden(); }
425 bool is_survivor() const { return _type.is_survivor(); }
426
427 bool isHumongous() const { return _type.is_humongous(); }
428 bool startsHumongous() const { return _type.is_starts_humongous(); }
429 bool continuesHumongous() const { return _type.is_continues_humongous(); }
430
431 bool is_old() const { return _type.is_old(); }
432
443 // For a humongous region, region in which it starts. 433 // For a humongous region, region in which it starts.
444 HeapRegion* humongous_start_region() const { 434 HeapRegion* humongous_start_region() const {
445 return _humongous_start_region; 435 return _humongous_start_region;
446 } 436 }
447 437
501 // region. first_hr is the "start humongous" region of the series 491 // region. first_hr is the "start humongous" region of the series
502 // which this region will be part of. 492 // which this region will be part of.
503 void set_continuesHumongous(HeapRegion* first_hr); 493 void set_continuesHumongous(HeapRegion* first_hr);
504 494
505 // Unsets the humongous-related fields on the region. 495 // Unsets the humongous-related fields on the region.
506 void set_notHumongous(); 496 void clear_humongous();
507 497
508 // If the region has a remembered set, return a pointer to it. 498 // If the region has a remembered set, return a pointer to it.
509 HeapRegionRemSet* rem_set() const { 499 HeapRegionRemSet* rem_set() const {
510 return _rem_set; 500 return _rem_set;
511 } 501 }
636 } 626 }
637 627
638 void calc_gc_efficiency(void); 628 void calc_gc_efficiency(void);
639 double gc_efficiency() { return _gc_efficiency;} 629 double gc_efficiency() { return _gc_efficiency;}
640 630
641 bool is_young() const { return _young_type != NotYoung; }
642 bool is_survivor() const { return _young_type == Survivor; }
643
644 int young_index_in_cset() const { return _young_index_in_cset; } 631 int young_index_in_cset() const { return _young_index_in_cset; }
645 void set_young_index_in_cset(int index) { 632 void set_young_index_in_cset(int index) {
646 assert( (index == -1) || is_young(), "pre-condition" ); 633 assert( (index == -1) || is_young(), "pre-condition" );
647 _young_index_in_cset = index; 634 _young_index_in_cset = index;
648 } 635 }
690 } else { 677 } else {
691 assert( _age_index == -1, "pre-condition" ); 678 assert( _age_index == -1, "pre-condition" );
692 } 679 }
693 } 680 }
694 681
695 void set_young() { set_young_type(Young); } 682 void set_free() { _type.set_free(); }
696 683
697 void set_survivor() { set_young_type(Survivor); } 684 void set_eden() { _type.set_eden(); }
698 685 void set_eden_pre_gc() { _type.set_eden_pre_gc(); }
699 void set_not_young() { set_young_type(NotYoung); } 686 void set_survivor() { _type.set_survivor(); }
687
688 void set_old() { _type.set_old(); }
700 689
701 // Determine if an object has been allocated since the last 690 // Determine if an object has been allocated since the last
702 // mark performed by the collector. This returns true iff the object 691 // mark performed by the collector. This returns true iff the object
703 // is within the unmarked area of the region. 692 // is within the unmarked area of the region.
704 bool obj_allocated_since_prev_marking(oop obj) const { 693 bool obj_allocated_since_prev_marking(oop obj) const {
839 // True after iteration if the closure was applied to all heap regions 828 // True after iteration if the closure was applied to all heap regions
840 // and returned "false" in all cases. 829 // and returned "false" in all cases.
841 bool complete() { return _complete; } 830 bool complete() { return _complete; }
842 }; 831 };
843 832
844 #endif // INCLUDE_ALL_GCS
845
846 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP 833 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP