55 #include "utilities/copy.hpp" |
55 #include "utilities/copy.hpp" |
56 #include "utilities/events.hpp" |
56 #include "utilities/events.hpp" |
57 |
57 |
58 class HeapRegion; |
58 class HeapRegion; |
59 |
59 |
|
60 bool G1MarkSweep::_archive_check_enabled = false; |
|
61 G1ArchiveRegionMap G1MarkSweep::_archive_region_map; |
|
62 |
60 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, |
63 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, |
61 bool clear_all_softrefs) { |
64 bool clear_all_softrefs) { |
62 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); |
65 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); |
63 |
66 |
64 #ifdef ASSERT |
67 #ifdef ASSERT |
210 // We must adjust the pointers on the single H object. |
213 // We must adjust the pointers on the single H object. |
211 oop obj = oop(r->bottom()); |
214 oop obj = oop(r->bottom()); |
212 // point all the oops to the new location |
215 // point all the oops to the new location |
213 MarkSweep::adjust_pointers(obj); |
216 MarkSweep::adjust_pointers(obj); |
214 } |
217 } |
215 } else { |
218 } else if (!r->is_pinned()) { |
216 // This really ought to be "as_CompactibleSpace"... |
219 // This really ought to be "as_CompactibleSpace"... |
217 r->adjust_pointers(); |
220 r->adjust_pointers(); |
218 } |
221 } |
219 return false; |
222 return false; |
220 } |
223 } |
294 GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); |
297 GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); |
295 |
298 |
296 G1SpaceCompactClosure blk; |
299 G1SpaceCompactClosure blk; |
297 g1h->heap_region_iterate(&blk); |
300 g1h->heap_region_iterate(&blk); |
298 |
301 |
|
302 } |
|
303 |
|
304 void G1MarkSweep::enable_archive_object_check() { |
|
305 assert(!_archive_check_enabled, "archive range check already enabled"); |
|
306 _archive_check_enabled = true; |
|
307 size_t length = Universe::heap()->max_capacity(); |
|
308 _archive_region_map.initialize((HeapWord*)Universe::heap()->base(), |
|
309 (HeapWord*)Universe::heap()->base() + length, |
|
310 HeapRegion::GrainBytes); |
|
311 } |
|
312 |
|
313 void G1MarkSweep::mark_range_archive(MemRegion range) { |
|
314 assert(_archive_check_enabled, "archive range check not enabled"); |
|
315 _archive_region_map.set_by_address(range, true); |
|
316 } |
|
317 |
|
318 bool G1MarkSweep::in_archive_range(oop object) { |
|
319 // This is the out-of-line part of is_archive_object test, done separately |
|
320 // to avoid additional performance impact when the check is not enabled. |
|
321 return _archive_region_map.get_by_address((HeapWord*)object); |
299 } |
322 } |
300 |
323 |
301 void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) { |
324 void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) { |
302 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
325 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
303 g1h->heap_region_iterate(blk); |
326 g1h->heap_region_iterate(blk); |