63 } |
63 } |
64 |
64 |
65 // Return the region with the given index. It assumes the index is valid. |
65 // Return the region with the given index. It assumes the index is valid. |
66 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); } |
66 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); } |
67 |
67 |
|
68 inline HeapRegion* G1CollectedHeap::next_region_in_humongous(HeapRegion* hr) const { |
|
69 return _hrm.next_region_in_humongous(hr); |
|
70 } |
|
71 |
68 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const { |
72 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const { |
69 assert(is_in_reserved(addr), |
73 assert(is_in_reserved(addr), |
70 "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")", |
74 "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")", |
71 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())); |
75 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())); |
72 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); |
76 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); |
75 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const { |
79 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const { |
76 return _hrm.reserved().start() + index * HeapRegion::GrainWords; |
80 return _hrm.reserved().start() + index * HeapRegion::GrainWords; |
77 } |
81 } |
78 |
82 |
79 template <class T> |
83 template <class T> |
80 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const { |
84 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const { |
81 assert(addr != NULL, "invariant"); |
85 assert(addr != NULL, "invariant"); |
82 assert(is_in_g1_reserved((const void*) addr), |
86 assert(is_in_g1_reserved((const void*) addr), |
83 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")", |
87 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")", |
84 p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end())); |
88 p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end())); |
85 return _hrm.addr_to_region((HeapWord*) addr); |
89 return _hrm.addr_to_region((HeapWord*) addr); |
86 } |
|
87 |
|
88 template <class T> |
|
89 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const { |
|
90 HeapRegion* hr = heap_region_containing_raw(addr); |
|
91 if (hr->is_continues_humongous()) { |
|
92 return hr->humongous_start_region(); |
|
93 } |
|
94 return hr; |
|
95 } |
90 } |
96 |
91 |
97 inline void G1CollectedHeap::reset_gc_time_stamp() { |
92 inline void G1CollectedHeap::reset_gc_time_stamp() { |
98 _gc_time_stamp = 0; |
93 _gc_time_stamp = 0; |
99 OrderAccess::fence(); |
94 OrderAccess::fence(); |
122 inline void |
117 inline void |
123 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) { |
118 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) { |
124 assert_heap_not_locked(); |
119 assert_heap_not_locked(); |
125 |
120 |
126 // Assign the containing region to containing_hr so that we don't |
121 // Assign the containing region to containing_hr so that we don't |
127 // have to keep calling heap_region_containing_raw() in the |
122 // have to keep calling heap_region_containing() in the |
128 // asserts below. |
123 // asserts below. |
129 DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);) |
124 DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing(start);) |
130 assert(word_size > 0, "pre-condition"); |
125 assert(word_size > 0, "pre-condition"); |
131 assert(containing_hr->is_in(start), "it should contain start"); |
126 assert(containing_hr->is_in(start), "it should contain start"); |
132 assert(containing_hr->is_young(), "it should be young"); |
127 assert(containing_hr->is_young(), "it should be young"); |
133 assert(!containing_hr->is_humongous(), "it should not be humongous"); |
128 assert(!containing_hr->is_humongous(), "it should not be humongous"); |
134 |
129 |