31 #include "code/icBuffer.hpp"
32 #include "gc/g1/g1MarkSweep.hpp"
33 #include "gc/g1/g1RootProcessor.hpp"
34 #include "gc/g1/g1StringDedup.hpp"
35 #include "gc/serial/markSweep.inline.hpp"
36 #include "gc/shared/gcHeapSummary.hpp"
37 #include "gc/shared/gcLocker.hpp"
38 #include "gc/shared/gcTimer.hpp"
39 #include "gc/shared/gcTrace.hpp"
40 #include "gc/shared/gcTraceTime.inline.hpp"
41 #include "gc/shared/genCollectedHeap.hpp"
42 #include "gc/shared/modRefBarrierSet.hpp"
43 #include "gc/shared/referencePolicy.hpp"
44 #include "gc/shared/space.hpp"
45 #include "oops/instanceRefKlass.hpp"
46 #include "oops/oop.inline.hpp"
47 #include "prims/jvmtiExport.hpp"
48 #include "runtime/atomic.hpp"
49 #include "runtime/biasedLocking.hpp"
50 #include "runtime/fprofiler.hpp"
51 #include "runtime/synchronizer.hpp"
52 #include "runtime/thread.hpp"
53 #include "runtime/vmThread.hpp"
54 #include "utilities/copy.hpp"
55 #include "utilities/events.hpp"
56
57 class HeapRegion;
58
59 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
60 bool clear_all_softrefs) {
61 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
62
63 #ifdef ASSERT
64 if (G1CollectedHeap::heap()->collector_policy()->should_clear_all_soft_refs()) {
65 assert(clear_all_softrefs, "Policy should have been checked earler");
66 }
67 #endif
68 // hook up weak ref data so it can be used during Mark-Sweep
69 assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
70 assert(rp != NULL, "should be non-NULL");
233 // Adjust the pointers to reflect the new locations
234 GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
235
236 // Need cleared claim bits for the roots processing
237 ClassLoaderDataGraph::clear_claimed_marks();
238
239 CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
240 {
241 G1RootProcessor root_processor(g1h, 1);
242 root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
243 &GenMarkSweep::adjust_cld_closure,
244 &adjust_code_closure);
245 }
246
247 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
248 g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
249
250 // Now adjust pointers in remaining weak roots. (All of which should
251 // have been cleared if they pointed to non-surviving objects.)
252 JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
253
254 if (G1StringDedup::is_enabled()) {
255 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
256 }
257
258 GenMarkSweep::adjust_marks();
259
260 G1AdjustPointersClosure blk;
261 g1h->heap_region_iterate(&blk);
262 }
263
264 class G1SpaceCompactClosure: public HeapRegionClosure {
265 public:
266 G1SpaceCompactClosure() {}
267
268 bool doHeapRegion(HeapRegion* hr) {
269 if (hr->is_humongous()) {
270 if (hr->is_starts_humongous()) {
271 oop obj = oop(hr->bottom());
272 if (obj->is_gc_marked()) {
|
31 #include "code/icBuffer.hpp"
32 #include "gc/g1/g1MarkSweep.hpp"
33 #include "gc/g1/g1RootProcessor.hpp"
34 #include "gc/g1/g1StringDedup.hpp"
35 #include "gc/serial/markSweep.inline.hpp"
36 #include "gc/shared/gcHeapSummary.hpp"
37 #include "gc/shared/gcLocker.hpp"
38 #include "gc/shared/gcTimer.hpp"
39 #include "gc/shared/gcTrace.hpp"
40 #include "gc/shared/gcTraceTime.inline.hpp"
41 #include "gc/shared/genCollectedHeap.hpp"
42 #include "gc/shared/modRefBarrierSet.hpp"
43 #include "gc/shared/referencePolicy.hpp"
44 #include "gc/shared/space.hpp"
45 #include "oops/instanceRefKlass.hpp"
46 #include "oops/oop.inline.hpp"
47 #include "prims/jvmtiExport.hpp"
48 #include "runtime/atomic.hpp"
49 #include "runtime/biasedLocking.hpp"
50 #include "runtime/fprofiler.hpp"
51 #include "runtime/heapMonitoring.hpp"
52 #include "runtime/synchronizer.hpp"
53 #include "runtime/thread.hpp"
54 #include "runtime/vmThread.hpp"
55 #include "utilities/copy.hpp"
56 #include "utilities/events.hpp"
57
58 class HeapRegion;
59
60 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
61 bool clear_all_softrefs) {
62 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
63
64 #ifdef ASSERT
65 if (G1CollectedHeap::heap()->collector_policy()->should_clear_all_soft_refs()) {
66 assert(clear_all_softrefs, "Policy should have been checked earler");
67 }
68 #endif
69 // hook up weak ref data so it can be used during Mark-Sweep
70 assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
71 assert(rp != NULL, "should be non-NULL");
234 // Adjust the pointers to reflect the new locations
235 GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
236
237 // Need cleared claim bits for the roots processing
238 ClassLoaderDataGraph::clear_claimed_marks();
239
240 CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
241 {
242 G1RootProcessor root_processor(g1h, 1);
243 root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
244 &GenMarkSweep::adjust_cld_closure,
245 &adjust_code_closure);
246 }
247
248 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
249 g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
250
251 // Now adjust pointers in remaining weak roots. (All of which should
252 // have been cleared if they pointed to non-surviving objects.)
253 JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
254 HeapMonitoring::do_weak_oops(&GenMarkSweep::adjust_pointer_closure);
255
256 if (G1StringDedup::is_enabled()) {
257 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
258 }
259
260 GenMarkSweep::adjust_marks();
261
262 G1AdjustPointersClosure blk;
263 g1h->heap_region_iterate(&blk);
264 }
265
266 class G1SpaceCompactClosure: public HeapRegionClosure {
267 public:
268 G1SpaceCompactClosure() {}
269
270 bool doHeapRegion(HeapRegion* hr) {
271 if (hr->is_humongous()) {
272 if (hr->is_starts_humongous()) {
273 oop obj = oop(hr->bottom());
274 if (obj->is_gc_marked()) {
|