59 // never be in a humongous region
60 // * Allowing humongous PLABs needlessly churns the region free lists
61 return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
62 }
63
64 // Inline functions for G1CollectedHeap
65
66 // Return the region with the given index. It assumes the index is valid.
67 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm->at(index); }
68
69 // Return the region with the given index, or NULL if unmapped. It assumes the index is valid.
70 inline HeapRegion* G1CollectedHeap::region_at_or_null(uint index) const { return _hrm->at_or_null(index); }
71
72 inline HeapRegion* G1CollectedHeap::next_region_in_humongous(HeapRegion* hr) const {
73 return _hrm->next_region_in_humongous(hr);
74 }
75
76 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
77 assert(is_in_reserved(addr),
78 "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
79 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
80 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
81 }
82
83 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
84 return _hrm->reserved().start() + index * HeapRegion::GrainWords;
85 }
86
87 template <class T>
88 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
89 assert(addr != NULL, "invariant");
90 assert(is_in_reserved((const void*) addr),
91 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
92 p2i((void*)addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
93 return _hrm->addr_to_region((HeapWord*)(void*) addr);
94 }
95
96 template <class T>
97 inline HeapRegion* G1CollectedHeap::heap_region_containing_or_null(const T addr) const {
98 assert(addr != NULL, "invariant");
99 assert(is_in_reserved((const void*) addr),
100 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
101 p2i((void*)addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
102 uint const region_idx = addr_to_region(addr);
103 return region_at_or_null(region_idx);
104 }
105
106 inline void G1CollectedHeap::old_set_add(HeapRegion* hr) {
107 _old_set.add(hr);
108 }
109
110 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
111 _old_set.remove(hr);
112 }
113
114 inline void G1CollectedHeap::archive_set_add(HeapRegion* hr) {
115 _archive_set.add(hr);
116 }
117
118 // It dirties the cards that cover the block so that the post
119 // write barrier never queues anything when updating objects on this
120 // block. It is assumed (and in fact we assert) that the block
121 // belongs to a young region.
|
59 // never be in a humongous region
60 // * Allowing humongous PLABs needlessly churns the region free lists
61 return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
62 }
63
64 // Inline functions for G1CollectedHeap
65
66 // Return the region with the given index. It assumes the index is valid.
67 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm->at(index); }
68
69 // Return the region with the given index, or NULL if unmapped. It assumes the index is valid.
70 inline HeapRegion* G1CollectedHeap::region_at_or_null(uint index) const { return _hrm->at_or_null(index); }
71
72 inline HeapRegion* G1CollectedHeap::next_region_in_humongous(HeapRegion* hr) const {
73 return _hrm->next_region_in_humongous(hr);
74 }
75
76 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
77 assert(is_in_reserved(addr),
78 "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
79 p2i(addr), p2i(reserved().start()), p2i(reserved().end()));
80 return (uint)(pointer_delta(addr, reserved().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
81 }
82
83 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
84 return _hrm->reserved().start() + index * HeapRegion::GrainWords;
85 }
86
87 template <class T>
88 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
89 assert(addr != NULL, "invariant");
90 assert(is_in_reserved((const void*) addr),
91 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
92 p2i((void*)addr), p2i(reserved().start()), p2i(reserved().end()));
93 return _hrm->addr_to_region((HeapWord*)(void*) addr);
94 }
95
96 template <class T>
97 inline HeapRegion* G1CollectedHeap::heap_region_containing_or_null(const T addr) const {
98 assert(addr != NULL, "invariant");
99 assert(is_in_reserved((const void*) addr),
100 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
101 p2i((void*)addr), p2i(reserved().start()), p2i(reserved().end()));
102 uint const region_idx = addr_to_region(addr);
103 return region_at_or_null(region_idx);
104 }
105
106 inline void G1CollectedHeap::old_set_add(HeapRegion* hr) {
107 _old_set.add(hr);
108 }
109
110 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
111 _old_set.remove(hr);
112 }
113
114 inline void G1CollectedHeap::archive_set_add(HeapRegion* hr) {
115 _archive_set.add(hr);
116 }
117
118 // It dirties the cards that cover the block so that the post
119 // write barrier never queues anything when updating objects on this
120 // block. It is assumed (and in fact we assert) that the block
121 // belongs to a young region.
|