25 #ifndef SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP |
25 #ifndef SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP |
26 #define SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP |
26 #define SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP |
27 |
27 |
28 #include "gc/g1/g1BlockOffsetTable.inline.hpp" |
28 #include "gc/g1/g1BlockOffsetTable.inline.hpp" |
29 #include "gc/g1/g1CollectedHeap.inline.hpp" |
29 #include "gc/g1/g1CollectedHeap.inline.hpp" |
|
30 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp" |
30 #include "gc/g1/heapRegion.hpp" |
31 #include "gc/g1/heapRegion.hpp" |
31 #include "gc/shared/space.hpp" |
32 #include "gc/shared/space.hpp" |
32 #include "oops/oop.inline.hpp" |
33 #include "oops/oop.inline.hpp" |
33 #include "runtime/atomic.hpp" |
34 #include "runtime/atomic.hpp" |
|
35 #include "runtime/prefetch.inline.hpp" |
34 #include "utilities/align.hpp" |
36 #include "utilities/align.hpp" |
35 |
37 |
36 inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size, |
38 inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size, |
37 size_t desired_word_size, |
39 size_t desired_word_size, |
38 size_t* actual_size) { |
40 size_t* actual_size) { |
176 if (block_is_obj(addr)) { |
178 if (block_is_obj(addr)) { |
177 return oop(addr)->size(); |
179 return oop(addr)->size(); |
178 } |
180 } |
179 |
181 |
180 return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prev_mark_bitmap()); |
182 return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prev_mark_bitmap()); |
|
183 } |
|
184 |
|
185 inline void HeapRegion::complete_compaction() { |
|
186 // Reset space and bot after compaction is complete if needed. |
|
187 reset_after_compaction(); |
|
188 if (used_region().is_empty()) { |
|
189 reset_bot(); |
|
190 } |
|
191 |
|
192 // After a compaction the mark bitmap is invalid, so we must |
|
193 // treat all objects as being inside the unmarked area. |
|
194 zero_marked_bytes(); |
|
195 init_top_at_mark_start(); |
|
196 |
|
197 // Clear unused heap memory in debug builds. |
|
198 if (ZapUnusedHeapArea) { |
|
199 mangle_unused_area(); |
|
200 } |
|
201 } |
|
202 |
|
203 template<typename ApplyToMarkedClosure> |
|
204 inline void HeapRegion::apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarkedClosure* closure) { |
|
205 HeapWord* limit = scan_limit(); |
|
206 HeapWord* next_addr = bottom(); |
|
207 |
|
208 while (next_addr < limit) { |
|
209 Prefetch::write(next_addr, PrefetchScanIntervalInBytes); |
|
210 // This explicit is_marked check is a way to avoid |
|
211 // some extra work done by get_next_marked_addr for |
|
212 // the case where next_addr is marked. |
|
213 if (bitmap->is_marked(next_addr)) { |
|
214 oop current = oop(next_addr); |
|
215 next_addr += closure->apply(current); |
|
216 } else { |
|
217 next_addr = bitmap->get_next_marked_addr(next_addr, limit); |
|
218 } |
|
219 } |
|
220 |
|
221 assert(next_addr == limit, "Should stop the scan at the limit."); |
181 } |
222 } |
182 |
223 |
183 inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t min_word_size, |
224 inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t min_word_size, |
184 size_t desired_word_size, |
225 size_t desired_word_size, |
185 size_t* actual_word_size) { |
226 size_t* actual_word_size) { |