comparison src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @ 23286:dd9cc155639c

Merge with jdk8u66-b17
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Thu, 07 Jan 2016 17:28:46 +0100
parents c28cb37b2e1d 38d6febe66af
children
comparison
equal deleted inserted replaced
22786:ac649db7fec4 23286:dd9cc155639c
29 #include "classfile/vmSymbols.hpp" 29 #include "classfile/vmSymbols.hpp"
30 #include "code/codeCache.hpp" 30 #include "code/codeCache.hpp"
31 #include "code/icBuffer.hpp" 31 #include "code/icBuffer.hpp"
32 #include "gc_implementation/g1/g1Log.hpp" 32 #include "gc_implementation/g1/g1Log.hpp"
33 #include "gc_implementation/g1/g1MarkSweep.hpp" 33 #include "gc_implementation/g1/g1MarkSweep.hpp"
34 #include "gc_implementation/g1/g1RootProcessor.hpp"
34 #include "gc_implementation/g1/g1StringDedup.hpp" 35 #include "gc_implementation/g1/g1StringDedup.hpp"
35 #include "gc_implementation/shared/gcHeapSummary.hpp" 36 #include "gc_implementation/shared/gcHeapSummary.hpp"
36 #include "gc_implementation/shared/gcTimer.hpp" 37 #include "gc_implementation/shared/gcTimer.hpp"
37 #include "gc_implementation/shared/gcTrace.hpp" 38 #include "gc_implementation/shared/gcTrace.hpp"
38 #include "gc_implementation/shared/gcTraceTime.hpp" 39 #include "gc_implementation/shared/gcTraceTime.hpp"
126 bool clear_all_softrefs) { 127 bool clear_all_softrefs) {
127 // Recursively traverse all live objects and mark them 128 // Recursively traverse all live objects and mark them
128 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 129 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
129 GenMarkSweep::trace(" 1"); 130 GenMarkSweep::trace(" 1");
130 131
131 SharedHeap* sh = SharedHeap::heap(); 132 G1CollectedHeap* g1h = G1CollectedHeap::heap();
132 133
133 // Need cleared claim bits for the roots processing 134 // Need cleared claim bits for the roots processing
134 ClassLoaderDataGraph::clear_claimed_marks(); 135 ClassLoaderDataGraph::clear_claimed_marks();
135 136
136 MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations); 137 MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations);
137 sh->process_strong_roots(true, // activate StrongRootsScope 138 {
138 SharedHeap::SO_None, 139 G1RootProcessor root_processor(g1h);
139 &GenMarkSweep::follow_root_closure, 140 root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure,
140 &GenMarkSweep::follow_cld_closure, 141 &GenMarkSweep::follow_cld_closure,
141 &follow_code_closure); 142 &follow_code_closure);
143 }
142 144
143 // Process reference objects found during marking 145 // Process reference objects found during marking
144 ReferenceProcessor* rp = GenMarkSweep::ref_processor(); 146 ReferenceProcessor* rp = GenMarkSweep::ref_processor();
145 assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity"); 147 assert(rp == g1h->ref_processor_stw(), "Sanity");
146 148
147 rp->setup_policy(clear_all_softrefs); 149 rp->setup_policy(clear_all_softrefs);
148 const ReferenceProcessorStats& stats = 150 const ReferenceProcessorStats& stats =
149 rp->process_discovered_references(&GenMarkSweep::is_alive, 151 rp->process_discovered_references(&GenMarkSweep::is_alive,
150 &GenMarkSweep::keep_alive, 152 &GenMarkSweep::keep_alive,
228 } 230 }
229 return false; 231 return false;
230 } 232 }
231 }; 233 };
232 234
235 class G1AlwaysTrueClosure: public BoolObjectClosure {
236 public:
237 bool do_object_b(oop p) { return true; }
238 };
239 static G1AlwaysTrueClosure always_true;
240
233 void G1MarkSweep::mark_sweep_phase3() { 241 void G1MarkSweep::mark_sweep_phase3() {
234 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 242 G1CollectedHeap* g1h = G1CollectedHeap::heap();
235 243
236 // Adjust the pointers to reflect the new locations 244 // Adjust the pointers to reflect the new locations
237 GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 245 GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
238 GenMarkSweep::trace("3"); 246 GenMarkSweep::trace("3");
239 247
240 SharedHeap* sh = SharedHeap::heap();
241
242 // Need cleared claim bits for the roots processing 248 // Need cleared claim bits for the roots processing
243 ClassLoaderDataGraph::clear_claimed_marks(); 249 ClassLoaderDataGraph::clear_claimed_marks();
244 250
245 CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations); 251 CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
246 sh->process_all_roots(true, // activate StrongRootsScope 252 {
247 SharedHeap::SO_AllCodeCache, 253 G1RootProcessor root_processor(g1h);
248 &GenMarkSweep::adjust_pointer_closure, 254 root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
249 &GenMarkSweep::adjust_cld_closure, 255 &GenMarkSweep::adjust_cld_closure,
250 &adjust_code_closure); 256 &adjust_code_closure);
257 }
251 258
252 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity"); 259 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
253 g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure); 260 g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
254 261
255 // Now adjust pointers in remaining weak roots. (All of which should 262 // Now adjust pointers in remaining weak roots. (All of which should
256 // have been cleared if they pointed to non-surviving objects.) 263 // have been cleared if they pointed to non-surviving objects.)
257 sh->process_weak_roots(&GenMarkSweep::adjust_pointer_closure); 264 JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure);
258 265
259 if (G1StringDedup::is_enabled()) { 266 if (G1StringDedup::is_enabled()) {
260 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure); 267 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
261 } 268 }
262 269