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

changeset 4037
da91efe96a93
parent 3957
a2f7274eb6ef
child 4098
8966c2d65d96
     1.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -68,15 +68,11 @@
     1.4    GenMarkSweep::_ref_processor = rp;
     1.5    rp->setup_policy(clear_all_softrefs);
     1.6  
     1.7 -  // When collecting the permanent generation methodOops may be moving,
     1.8 +  // When collecting the permanent generation Method*s may be moving,
     1.9    // so we either have to flush all bcp data or convert it into bci.
    1.10    CodeCache::gc_prologue();
    1.11    Threads::gc_prologue();
    1.12  
    1.13 -  // Increment the invocation count for the permanent generation, since it is
    1.14 -  // implicitly collected whenever we do a full mark sweep collection.
    1.15 -  sh->perm_gen()->stat_record()->invocations++;
    1.16 -
    1.17    bool marked_for_unloading = false;
    1.18  
    1.19    allocate_stacks();
    1.20 @@ -100,10 +96,6 @@
    1.21    BiasedLocking::restore_marks();
    1.22    GenMarkSweep::deallocate_stacks();
    1.23  
    1.24 -  // We must invalidate the perm-gen rs, so that it gets rebuilt.
    1.25 -  GenRemSet* rs = sh->rem_set();
    1.26 -  rs->invalidate(sh->perm_gen()->used_region(), true /*whole_heap*/);
    1.27 -
    1.28    // "free at last gc" is calculated from these.
    1.29    // CHF: cheating for now!!!
    1.30    //  Universe::set_heap_capacity_at_last_gc(Universe::heap()->capacity());
    1.31 @@ -132,12 +124,15 @@
    1.32  
    1.33    SharedHeap* sh = SharedHeap::heap();
    1.34  
    1.35 -  sh->process_strong_roots(true,  // activeate StrongRootsScope
    1.36 -                           true,  // Collecting permanent generation.
    1.37 +  // Need cleared claim bits for the strong roots processing
    1.38 +  ClassLoaderDataGraph::clear_claimed_marks();
    1.39 +
    1.40 +  sh->process_strong_roots(true,  // activate StrongRootsScope
    1.41 +                           false, // not scavenging.
    1.42                             SharedHeap::SO_SystemClasses,
    1.43                             &GenMarkSweep::follow_root_closure,
    1.44                             &GenMarkSweep::follow_code_root_closure,
    1.45 -                           &GenMarkSweep::follow_root_closure);
    1.46 +                           &GenMarkSweep::follow_klass_closure);
    1.47  
    1.48    // Process reference objects found during marking
    1.49    ReferenceProcessor* rp = GenMarkSweep::ref_processor();
    1.50 @@ -162,14 +157,10 @@
    1.51    GenMarkSweep::follow_stack();
    1.52  
    1.53    // Update subklass/sibling/implementor links of live klasses
    1.54 -  GenMarkSweep::follow_weak_klass_links();
    1.55 +  Klass::clean_weak_klass_links(&GenMarkSweep::is_alive);
    1.56    assert(GenMarkSweep::_marking_stack.is_empty(),
    1.57           "stack should be empty by now");
    1.58  
    1.59 -  // Visit memoized MDO's and clear any unmarked weak refs
    1.60 -  GenMarkSweep::follow_mdo_weak_refs();
    1.61 -  assert(GenMarkSweep::_marking_stack.is_empty(), "just drained");
    1.62 -
    1.63    // Visit interned string tables and delete unmarked oops
    1.64    StringTable::unlink(&GenMarkSweep::is_alive);
    1.65    // Clean up unreferenced symbols in symbol table.
    1.66 @@ -265,19 +256,11 @@
    1.67  void G1MarkSweep::mark_sweep_phase2() {
    1.68    // Now all live objects are marked, compute the new object addresses.
    1.69  
    1.70 -  // It is imperative that we traverse perm_gen LAST. If dead space is
    1.71 -  // allowed a range of dead object may get overwritten by a dead int
    1.72 -  // array. If perm_gen is not traversed last a klassOop may get
    1.73 -  // overwritten. This is fine since it is dead, but if the class has dead
    1.74 -  // instances we have to skip them, and in order to find their size we
    1.75 -  // need the klassOop!
    1.76 -  //
    1.77    // It is not required that we traverse spaces in the same order in
    1.78    // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
    1.79    // tracking expects us to do so. See comment under phase4.
    1.80  
    1.81    G1CollectedHeap* g1h = G1CollectedHeap::heap();
    1.82 -  Generation* pg = g1h->perm_gen();
    1.83  
    1.84    TraceTime tm("phase 2", G1Log::fine() && Verbose, true, gclog_or_tty);
    1.85    GenMarkSweep::trace("2");
    1.86 @@ -292,9 +275,6 @@
    1.87    G1PrepareCompactClosure blk(sp);
    1.88    g1h->heap_region_iterate(&blk);
    1.89    blk.update_sets();
    1.90 -
    1.91 -  CompactPoint perm_cp(pg, NULL, NULL);
    1.92 -  pg->prepare_for_compaction(&perm_cp);
    1.93  }
    1.94  
    1.95  class G1AdjustPointersClosure: public HeapRegionClosure {
    1.96 @@ -319,7 +299,6 @@
    1.97  
    1.98  void G1MarkSweep::mark_sweep_phase3() {
    1.99    G1CollectedHeap* g1h = G1CollectedHeap::heap();
   1.100 -  Generation* pg = g1h->perm_gen();
   1.101  
   1.102    // Adjust the pointers to reflect the new locations
   1.103    TraceTime tm("phase 3", G1Log::fine() && Verbose, true, gclog_or_tty);
   1.104 @@ -327,12 +306,15 @@
   1.105  
   1.106    SharedHeap* sh = SharedHeap::heap();
   1.107  
   1.108 +  // Need cleared claim bits for the strong roots processing
   1.109 +  ClassLoaderDataGraph::clear_claimed_marks();
   1.110 +
   1.111    sh->process_strong_roots(true,  // activate StrongRootsScope
   1.112 -                           true,  // Collecting permanent generation.
   1.113 +                           false, // not scavenging.
   1.114                             SharedHeap::SO_AllClasses,
   1.115                             &GenMarkSweep::adjust_root_pointer_closure,
   1.116                             NULL,  // do not touch code cache here
   1.117 -                           &GenMarkSweep::adjust_pointer_closure);
   1.118 +                           &GenMarkSweep::adjust_klass_closure);
   1.119  
   1.120    assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
   1.121    g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);
   1.122 @@ -346,7 +328,6 @@
   1.123  
   1.124    G1AdjustPointersClosure blk;
   1.125    g1h->heap_region_iterate(&blk);
   1.126 -  pg->adjust_pointers();
   1.127  }
   1.128  
   1.129  class G1SpaceCompactClosure: public HeapRegionClosure {
   1.130 @@ -374,23 +355,15 @@
   1.131  void G1MarkSweep::mark_sweep_phase4() {
   1.132    // All pointers are now adjusted, move objects accordingly
   1.133  
   1.134 -  // It is imperative that we traverse perm_gen first in phase4. All
   1.135 -  // classes must be allocated earlier than their instances, and traversing
   1.136 -  // perm_gen first makes sure that all klassOops have moved to their new
   1.137 -  // location before any instance does a dispatch through it's klass!
   1.138 -
   1.139    // The ValidateMarkSweep live oops tracking expects us to traverse spaces
   1.140    // in the same order in phase2, phase3 and phase4. We don't quite do that
   1.141 -  // here (perm_gen first rather than last), so we tell the validate code
   1.142 +  // here (code and comment not fixed for perm removal), so we tell the validate code
   1.143    // to use a higher index (saved from phase2) when verifying perm_gen.
   1.144    G1CollectedHeap* g1h = G1CollectedHeap::heap();
   1.145 -  Generation* pg = g1h->perm_gen();
   1.146  
   1.147    TraceTime tm("phase 4", G1Log::fine() && Verbose, true, gclog_or_tty);
   1.148    GenMarkSweep::trace("4");
   1.149  
   1.150 -  pg->compact();
   1.151 -
   1.152    G1SpaceCompactClosure blk;
   1.153    g1h->heap_region_iterate(&blk);
   1.154  

mercurial