hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
changeset 13728 882756847a04
parent 13336 e582172ff6ff
child 13878 6e6a462a6cff
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Fri Aug 31 16:39:35 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Sat Sep 01 13:25:18 2012 -0400
@@ -68,15 +68,11 @@
   GenMarkSweep::_ref_processor = rp;
   rp->setup_policy(clear_all_softrefs);
 
-  // When collecting the permanent generation methodOops may be moving,
+  // When collecting the permanent generation Method*s may be moving,
   // so we either have to flush all bcp data or convert it into bci.
   CodeCache::gc_prologue();
   Threads::gc_prologue();
 
-  // Increment the invocation count for the permanent generation, since it is
-  // implicitly collected whenever we do a full mark sweep collection.
-  sh->perm_gen()->stat_record()->invocations++;
-
   bool marked_for_unloading = false;
 
   allocate_stacks();
@@ -100,10 +96,6 @@
   BiasedLocking::restore_marks();
   GenMarkSweep::deallocate_stacks();
 
-  // We must invalidate the perm-gen rs, so that it gets rebuilt.
-  GenRemSet* rs = sh->rem_set();
-  rs->invalidate(sh->perm_gen()->used_region(), true /*whole_heap*/);
-
   // "free at last gc" is calculated from these.
   // CHF: cheating for now!!!
   //  Universe::set_heap_capacity_at_last_gc(Universe::heap()->capacity());
@@ -132,12 +124,15 @@
 
   SharedHeap* sh = SharedHeap::heap();
 
-  sh->process_strong_roots(true,  // activeate StrongRootsScope
-                           true,  // Collecting permanent generation.
+  // Need cleared claim bits for the strong roots processing
+  ClassLoaderDataGraph::clear_claimed_marks();
+
+  sh->process_strong_roots(true,  // activate StrongRootsScope
+                           false, // not scavenging.
                            SharedHeap::SO_SystemClasses,
                            &GenMarkSweep::follow_root_closure,
                            &GenMarkSweep::follow_code_root_closure,
-                           &GenMarkSweep::follow_root_closure);
+                           &GenMarkSweep::follow_klass_closure);
 
   // Process reference objects found during marking
   ReferenceProcessor* rp = GenMarkSweep::ref_processor();
@@ -162,14 +157,10 @@
   GenMarkSweep::follow_stack();
 
   // Update subklass/sibling/implementor links of live klasses
-  GenMarkSweep::follow_weak_klass_links();
+  Klass::clean_weak_klass_links(&GenMarkSweep::is_alive);
   assert(GenMarkSweep::_marking_stack.is_empty(),
          "stack should be empty by now");
 
-  // Visit memoized MDO's and clear any unmarked weak refs
-  GenMarkSweep::follow_mdo_weak_refs();
-  assert(GenMarkSweep::_marking_stack.is_empty(), "just drained");
-
   // Visit interned string tables and delete unmarked oops
   StringTable::unlink(&GenMarkSweep::is_alive);
   // Clean up unreferenced symbols in symbol table.
@@ -265,19 +256,11 @@
 void G1MarkSweep::mark_sweep_phase2() {
   // Now all live objects are marked, compute the new object addresses.
 
-  // It is imperative that we traverse perm_gen LAST. If dead space is
-  // allowed a range of dead object may get overwritten by a dead int
-  // array. If perm_gen is not traversed last a klassOop may get
-  // overwritten. This is fine since it is dead, but if the class has dead
-  // instances we have to skip them, and in order to find their size we
-  // need the klassOop!
-  //
   // It is not required that we traverse spaces in the same order in
   // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
   // tracking expects us to do so. See comment under phase4.
 
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  Generation* pg = g1h->perm_gen();
 
   TraceTime tm("phase 2", G1Log::fine() && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("2");
@@ -292,9 +275,6 @@
   G1PrepareCompactClosure blk(sp);
   g1h->heap_region_iterate(&blk);
   blk.update_sets();
-
-  CompactPoint perm_cp(pg, NULL, NULL);
-  pg->prepare_for_compaction(&perm_cp);
 }
 
 class G1AdjustPointersClosure: public HeapRegionClosure {
@@ -319,7 +299,6 @@
 
 void G1MarkSweep::mark_sweep_phase3() {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  Generation* pg = g1h->perm_gen();
 
   // Adjust the pointers to reflect the new locations
   TraceTime tm("phase 3", G1Log::fine() && Verbose, true, gclog_or_tty);
@@ -327,12 +306,15 @@
 
   SharedHeap* sh = SharedHeap::heap();
 
+  // Need cleared claim bits for the strong roots processing
+  ClassLoaderDataGraph::clear_claimed_marks();
+
   sh->process_strong_roots(true,  // activate StrongRootsScope
-                           true,  // Collecting permanent generation.
+                           false, // not scavenging.
                            SharedHeap::SO_AllClasses,
                            &GenMarkSweep::adjust_root_pointer_closure,
                            NULL,  // do not touch code cache here
-                           &GenMarkSweep::adjust_pointer_closure);
+                           &GenMarkSweep::adjust_klass_closure);
 
   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);
@@ -346,7 +328,6 @@
 
   G1AdjustPointersClosure blk;
   g1h->heap_region_iterate(&blk);
-  pg->adjust_pointers();
 }
 
 class G1SpaceCompactClosure: public HeapRegionClosure {
@@ -374,23 +355,15 @@
 void G1MarkSweep::mark_sweep_phase4() {
   // All pointers are now adjusted, move objects accordingly
 
-  // It is imperative that we traverse perm_gen first in phase4. All
-  // classes must be allocated earlier than their instances, and traversing
-  // perm_gen first makes sure that all klassOops have moved to their new
-  // location before any instance does a dispatch through it's klass!
-
   // The ValidateMarkSweep live oops tracking expects us to traverse spaces
   // in the same order in phase2, phase3 and phase4. We don't quite do that
-  // here (perm_gen first rather than last), so we tell the validate code
+  // here (code and comment not fixed for perm removal), so we tell the validate code
   // to use a higher index (saved from phase2) when verifying perm_gen.
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  Generation* pg = g1h->perm_gen();
 
   TraceTime tm("phase 4", G1Log::fine() && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("4");
 
-  pg->compact();
-
   G1SpaceCompactClosure blk;
   g1h->heap_region_iterate(&blk);