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