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

changeset 6413
595c0f60d50d
parent 6408
bc22cbb8b45a
child 6423
2775f322649a
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Mar 24 09:14:14 2014 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Mar 18 19:07:22 2014 +0100
     1.3 @@ -39,6 +39,7 @@
     1.4  #include "gc_implementation/g1/g1MarkSweep.hpp"
     1.5  #include "gc_implementation/g1/g1OopClosures.inline.hpp"
     1.6  #include "gc_implementation/g1/g1RemSet.inline.hpp"
     1.7 +#include "gc_implementation/g1/g1StringDedup.hpp"
     1.8  #include "gc_implementation/g1/g1YCTypes.hpp"
     1.9  #include "gc_implementation/g1/heapRegion.inline.hpp"
    1.10  #include "gc_implementation/g1/heapRegionRemSet.hpp"
    1.11 @@ -2173,6 +2174,8 @@
    1.12    // values in the heap have been properly initialized.
    1.13    _g1mm = new G1MonitoringSupport(this);
    1.14  
    1.15 +  G1StringDedup::initialize();
    1.16 +
    1.17    return JNI_OK;
    1.18  }
    1.19  
    1.20 @@ -3475,6 +3478,11 @@
    1.21      if (!silent) gclog_or_tty->print("RemSet ");
    1.22      rem_set()->verify();
    1.23  
    1.24 +    if (G1StringDedup::is_enabled()) {
    1.25 +      if (!silent) gclog_or_tty->print("StrDedup ");
    1.26 +      G1StringDedup::verify();
    1.27 +    }
    1.28 +
    1.29      if (failures) {
    1.30        gclog_or_tty->print_cr("Heap:");
    1.31        // It helps to have the per-region information in the output to
    1.32 @@ -3492,8 +3500,13 @@
    1.33      }
    1.34      guarantee(!failures, "there should not have been any failures");
    1.35    } else {
    1.36 -    if (!silent)
    1.37 -      gclog_or_tty->print("(SKIPPING roots, heapRegionSets, heapRegions, remset) ");
    1.38 +    if (!silent) {
    1.39 +      gclog_or_tty->print("(SKIPPING Roots, HeapRegionSets, HeapRegions, RemSet");
    1.40 +      if (G1StringDedup::is_enabled()) {
    1.41 +        gclog_or_tty->print(", StrDedup");
    1.42 +      }
    1.43 +      gclog_or_tty->print(") ");
    1.44 +    }
    1.45    }
    1.46  }
    1.47  
    1.48 @@ -3586,6 +3599,9 @@
    1.49    st->cr();
    1.50    _cm->print_worker_threads_on(st);
    1.51    _cg1r->print_worker_threads_on(st);
    1.52 +  if (G1StringDedup::is_enabled()) {
    1.53 +    G1StringDedup::print_worker_threads_on(st);
    1.54 +  }
    1.55  }
    1.56  
    1.57  void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const {
    1.58 @@ -3594,6 +3610,9 @@
    1.59    }
    1.60    tc->do_thread(_cmThread);
    1.61    _cg1r->threads_do(tc);
    1.62 +  if (G1StringDedup::is_enabled()) {
    1.63 +    G1StringDedup::threads_do(tc);
    1.64 +  }
    1.65  }
    1.66  
    1.67  void G1CollectedHeap::print_tracing_info() const {
    1.68 @@ -4774,6 +4793,13 @@
    1.69        obj->set_mark(m);
    1.70      }
    1.71  
    1.72 +    if (G1StringDedup::is_enabled()) {
    1.73 +      G1StringDedup::enqueue_from_evacuation(from_region->is_young(),
    1.74 +                                             to_region->is_young(),
    1.75 +                                             queue_num(),
    1.76 +                                             obj);
    1.77 +    }
    1.78 +
    1.79      size_t* surv_young_words = surviving_young_words();
    1.80      surv_young_words[young_index] += word_sz;
    1.81  
    1.82 @@ -5249,6 +5275,10 @@
    1.83                             g1_unlink_task.strings_processed(), g1_unlink_task.strings_removed(),
    1.84                             g1_unlink_task.symbols_processed(), g1_unlink_task.symbols_removed());
    1.85    }
    1.86 +
    1.87 +  if (G1StringDedup::is_enabled()) {
    1.88 +    G1StringDedup::unlink(is_alive);
    1.89 +  }
    1.90  }
    1.91  
    1.92  class RedirtyLoggedCardTableEntryFastClosure : public CardTableEntryClosure {
    1.93 @@ -5872,6 +5902,9 @@
    1.94      G1STWIsAliveClosure is_alive(this);
    1.95      G1KeepAliveClosure keep_alive(this);
    1.96      JNIHandles::weak_oops_do(&is_alive, &keep_alive);
    1.97 +    if (G1StringDedup::is_enabled()) {
    1.98 +      G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive);
    1.99 +    }
   1.100    }
   1.101  
   1.102    release_gc_alloc_regions(n_workers, evacuation_info);
   1.103 @@ -6352,9 +6385,10 @@
   1.104      TearDownRegionSetsClosure cl(&_old_set);
   1.105      heap_region_iterate(&cl);
   1.106  
   1.107 -    // Need to do this after the heap iteration to be able to
   1.108 -    // recognize the young regions and ignore them during the iteration.
   1.109 -    _young_list->empty_list();
   1.110 +    // Note that emptying the _young_list is postponed and instead done as
   1.111 +    // the first step when rebuilding the regions sets again. The reason for
   1.112 +    // this is that during a full GC string deduplication needs to know if
   1.113 +    // a collected region was young or old when the full GC was initiated.
   1.114    }
   1.115    _free_list.remove_all();
   1.116  }
   1.117 @@ -6408,6 +6442,10 @@
   1.118  void G1CollectedHeap::rebuild_region_sets(bool free_list_only) {
   1.119    assert_at_safepoint(true /* should_be_vm_thread */);
   1.120  
   1.121 +  if (!free_list_only) {
   1.122 +    _young_list->empty_list();
   1.123 +  }
   1.124 +
   1.125    RebuildRegionSetsClosure cl(free_list_only, &_old_set, &_free_list);
   1.126    heap_region_iterate(&cl);
   1.127  

mercurial