116
117 void G1MarkSweep::allocate_stacks() {
118 GenMarkSweep::_preserved_count_max = 0;
119 GenMarkSweep::_preserved_marks = NULL;
120 GenMarkSweep::_preserved_count = 0;
121 }
122
123 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
124 bool clear_all_softrefs) {
125 // Recursively traverse all live objects and mark them
126 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
127 GenMarkSweep::trace(" 1");
128
129 G1CollectedHeap* g1h = G1CollectedHeap::heap();
130
131 // Need cleared claim bits for the roots processing
132 ClassLoaderDataGraph::clear_claimed_marks();
133
134 MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations);
135 {
136 G1RootProcessor root_processor(g1h, true /* trace_metadata */);
137 root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure,
138 &GenMarkSweep::follow_cld_closure,
139 &follow_code_closure);
140 }
141
142 // Process reference objects found during marking
143 ReferenceProcessor* rp = GenMarkSweep::ref_processor();
144 assert(rp == g1h->ref_processor_stw(), "Sanity");
145
146 rp->setup_policy(clear_all_softrefs);
147 const ReferenceProcessorStats& stats =
148 rp->process_discovered_references(&GenMarkSweep::is_alive,
149 &GenMarkSweep::keep_alive,
150 &GenMarkSweep::follow_stack_closure,
151 NULL,
152 gc_timer(),
153 gc_tracer()->gc_id());
154 gc_tracer()->report_gc_reference_stats(stats);
155
156
228 };
229
230 class G1AlwaysTrueClosure: public BoolObjectClosure {
231 public:
232 bool do_object_b(oop p) { return true; }
233 };
234 static G1AlwaysTrueClosure always_true;
235
236 void G1MarkSweep::mark_sweep_phase3() {
237 G1CollectedHeap* g1h = G1CollectedHeap::heap();
238
239 // Adjust the pointers to reflect the new locations
240 GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
241 GenMarkSweep::trace("3");
242
243 // Need cleared claim bits for the roots processing
244 ClassLoaderDataGraph::clear_claimed_marks();
245
246 CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
247 {
248 G1RootProcessor root_processor(g1h, false /* trace_metadata */);
249 root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
250 &GenMarkSweep::adjust_cld_closure,
251 &adjust_code_closure);
252 }
253
254 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
255 g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
256
257 // Now adjust pointers in remaining weak roots. (All of which should
258 // have been cleared if they pointed to non-surviving objects.)
259 JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure);
260
261 if (G1StringDedup::is_enabled()) {
262 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
263 }
264
265 GenMarkSweep::adjust_marks();
266
267 G1AdjustPointersClosure blk;
268 g1h->heap_region_iterate(&blk);
|
116
117 void G1MarkSweep::allocate_stacks() {
118 GenMarkSweep::_preserved_count_max = 0;
119 GenMarkSweep::_preserved_marks = NULL;
120 GenMarkSweep::_preserved_count = 0;
121 }
122
123 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
124 bool clear_all_softrefs) {
125 // Recursively traverse all live objects and mark them
126 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
127 GenMarkSweep::trace(" 1");
128
129 G1CollectedHeap* g1h = G1CollectedHeap::heap();
130
131 // Need cleared claim bits for the roots processing
132 ClassLoaderDataGraph::clear_claimed_marks();
133
134 MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations);
135 {
136 G1RootProcessor root_processor(g1h);
137 root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure,
138 &GenMarkSweep::follow_cld_closure,
139 &follow_code_closure);
140 }
141
142 // Process reference objects found during marking
143 ReferenceProcessor* rp = GenMarkSweep::ref_processor();
144 assert(rp == g1h->ref_processor_stw(), "Sanity");
145
146 rp->setup_policy(clear_all_softrefs);
147 const ReferenceProcessorStats& stats =
148 rp->process_discovered_references(&GenMarkSweep::is_alive,
149 &GenMarkSweep::keep_alive,
150 &GenMarkSweep::follow_stack_closure,
151 NULL,
152 gc_timer(),
153 gc_tracer()->gc_id());
154 gc_tracer()->report_gc_reference_stats(stats);
155
156
228 };
229
230 class G1AlwaysTrueClosure: public BoolObjectClosure {
231 public:
232 bool do_object_b(oop p) { return true; }
233 };
234 static G1AlwaysTrueClosure always_true;
235
236 void G1MarkSweep::mark_sweep_phase3() {
237 G1CollectedHeap* g1h = G1CollectedHeap::heap();
238
239 // Adjust the pointers to reflect the new locations
240 GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
241 GenMarkSweep::trace("3");
242
243 // Need cleared claim bits for the roots processing
244 ClassLoaderDataGraph::clear_claimed_marks();
245
246 CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
247 {
248 G1RootProcessor root_processor(g1h);
249 root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
250 &GenMarkSweep::adjust_cld_closure,
251 &adjust_code_closure);
252 }
253
254 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
255 g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
256
257 // Now adjust pointers in remaining weak roots. (All of which should
258 // have been cleared if they pointed to non-surviving objects.)
259 JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure);
260
261 if (G1StringDedup::is_enabled()) {
262 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
263 }
264
265 GenMarkSweep::adjust_marks();
266
267 G1AdjustPointersClosure blk;
268 g1h->heap_region_iterate(&blk);
|