src/share/vm/gc_implementation/g1/g1MarkSweep.cpp

Print this page

        

@@ -31,12 +31,13 @@
                                       bool clear_all_softrefs) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
 
   // hook up weak ref data so it can be used during Mark-Sweep
   assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
-  GenMarkSweep::_ref_processor = rp;
   assert(rp != NULL, "should be non-NULL");
+  GenMarkSweep::_ref_processor = rp;
+  rp->snap_policy(clear_all_softrefs);
 
   // When collecting the permanent generation methodOops may be moving,
   // so we either have to flush all bcp data or convert it into bci.
   CodeCache::gc_prologue();
   Threads::gc_prologue();

@@ -119,24 +120,13 @@
                            SharedHeap::SO_SystemClasses,
                            &GenMarkSweep::follow_root_closure,
                            &GenMarkSweep::follow_root_closure);
 
   // Process reference objects found during marking
-  ReferencePolicy *soft_ref_policy;
-  if (clear_all_softrefs) {
-    soft_ref_policy = new AlwaysClearPolicy();
-  } else {
-#ifdef COMPILER2
-    soft_ref_policy = new LRUMaxHeapPolicy();
-#else
-    soft_ref_policy = new LRUCurrentHeapPolicy();
-#endif
-  }
-  assert(soft_ref_policy != NULL,"No soft reference policy");
-  GenMarkSweep::ref_processor()->process_discovered_references(
-                                   soft_ref_policy,
-                                   &GenMarkSweep::is_alive,
+  ReferenceProcessor* rp = GenMarkSweep::ref_processor();
+  rp->snap_policy(clear_all_softrefs);
+  rp->process_discovered_references(&GenMarkSweep::is_alive,
                                    &GenMarkSweep::keep_alive,
                                    &GenMarkSweep::follow_stack_closure,
                                    NULL);
 
   // Follow system dictionary roots and unload classes