< prev index next >

src/share/vm/gc/g1/g1StringDedupThread.cpp

Print this page
rev 10297 : [mq]: webrev.01
   1 /*
   2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  64  public:
  65   G1StringDedupSharedClosure(G1StringDedupStat& stat) : _stat(stat) {}
  66 
  67   virtual void do_oop(oop* p) { ShouldNotReachHere(); }
  68   virtual void do_oop(narrowOop* p) {
  69     oop java_string = oopDesc::load_decode_heap_oop(p);
  70     G1StringDedupTable::deduplicate(java_string, _stat);
  71   }
  72 };
  73 
  74 // The CDS archive does not include the string dedupication table. Only the string
  75 // table is saved in the archive. The shared strings from CDS archive need to be
  76 // added to the string dedupication table before deduplication occurs. That is
  77 // done in the begining of the G1StringDedupThread (see G1StringDedupThread::run()
  78 // below).
  79 void G1StringDedupThread::deduplicate_shared_strings(G1StringDedupStat& stat) {
  80   G1StringDedupSharedClosure sharedStringDedup(stat);
  81   StringTable::shared_oops_do(&sharedStringDedup);
  82 }
  83 
  84 void G1StringDedupThread::run() {
  85   G1StringDedupStat total_stat;
  86 
  87   initialize_in_thread();
  88   wait_for_universe_init();
  89   deduplicate_shared_strings(total_stat);
  90 
  91   // Main loop
  92   for (;;) {
  93     G1StringDedupStat stat;
  94 
  95     stat.mark_idle();
  96 
  97     // Wait for the queue to become non-empty
  98     G1StringDedupQueue::wait();
  99     if (_should_terminate) {
 100       break;
 101     }
 102 
 103     {
 104       // Include thread in safepoints
 105       SuspendibleThreadSetJoiner sts_join;
 106 
 107       stat.mark_exec();
 108 


 116         G1StringDedupTable::deduplicate(java_string, stat);
 117 
 118         // Safepoint this thread if needed
 119         if (sts_join.should_yield()) {
 120           stat.mark_block();
 121           sts_join.yield();
 122           stat.mark_unblock();
 123         }
 124       }
 125 
 126       G1StringDedupTable::trim_entry_cache();
 127 
 128       stat.mark_done();
 129 
 130       // Print statistics
 131       total_stat.add(stat);
 132       print(stat, total_stat);
 133     }
 134   }
 135 
 136   terminate();
 137 }
 138 
 139 void G1StringDedupThread::stop() {
 140   {
 141     MonitorLockerEx ml(Terminator_lock);
 142     _thread->_should_terminate = true;
 143   }
 144 
 145   G1StringDedupQueue::cancel_wait();
 146 
 147   {
 148     MonitorLockerEx ml(Terminator_lock);
 149     while (!_thread->_has_terminated) {
 150       ml.wait();
 151     }
 152   }
 153 }
 154 
 155 void G1StringDedupThread::print(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
 156   if (log_is_enabled(Info, gc, stringdedup)) {
 157     G1StringDedupStat::print_summary(last_stat, total_stat);
 158     if (log_is_enabled(Debug, gc, stringdedup)) {
 159       G1StringDedupStat::print_statistics(last_stat, false);
 160       G1StringDedupStat::print_statistics(total_stat, true);
 161       G1StringDedupTable::print_statistics();
 162       G1StringDedupQueue::print_statistics();
 163     }
 164   }
 165 }
   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  64  public:
  65   G1StringDedupSharedClosure(G1StringDedupStat& stat) : _stat(stat) {}
  66 
  67   virtual void do_oop(oop* p) { ShouldNotReachHere(); }
  68   virtual void do_oop(narrowOop* p) {
  69     oop java_string = oopDesc::load_decode_heap_oop(p);
  70     G1StringDedupTable::deduplicate(java_string, _stat);
  71   }
  72 };
  73 
  74 // The CDS archive does not include the string dedupication table. Only the string
  75 // table is saved in the archive. The shared strings from CDS archive need to be
  76 // added to the string dedupication table before deduplication occurs. That is
  77 // done in the begining of the G1StringDedupThread (see G1StringDedupThread::run()
  78 // below).
  79 void G1StringDedupThread::deduplicate_shared_strings(G1StringDedupStat& stat) {
  80   G1StringDedupSharedClosure sharedStringDedup(stat);
  81   StringTable::shared_oops_do(&sharedStringDedup);
  82 }
  83 
  84 void G1StringDedupThread::run_service() {
  85   G1StringDedupStat total_stat;
  86 


  87   deduplicate_shared_strings(total_stat);
  88 
  89   // Main loop
  90   for (;;) {
  91     G1StringDedupStat stat;
  92 
  93     stat.mark_idle();
  94 
  95     // Wait for the queue to become non-empty
  96     G1StringDedupQueue::wait();
  97     if (_should_terminate) {
  98       break;
  99     }
 100 
 101     {
 102       // Include thread in safepoints
 103       SuspendibleThreadSetJoiner sts_join;
 104 
 105       stat.mark_exec();
 106 


 114         G1StringDedupTable::deduplicate(java_string, stat);
 115 
 116         // Safepoint this thread if needed
 117         if (sts_join.should_yield()) {
 118           stat.mark_block();
 119           sts_join.yield();
 120           stat.mark_unblock();
 121         }
 122       }
 123 
 124       G1StringDedupTable::trim_entry_cache();
 125 
 126       stat.mark_done();
 127 
 128       // Print statistics
 129       total_stat.add(stat);
 130       print(stat, total_stat);
 131     }
 132   }
 133 

 134 }
 135 
 136 void G1StringDedupThread::stop_service() {





 137   G1StringDedupQueue::cancel_wait();







 138 }
 139 
 140 void G1StringDedupThread::print(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
 141   if (log_is_enabled(Info, gc, stringdedup)) {
 142     G1StringDedupStat::print_summary(last_stat, total_stat);
 143     if (log_is_enabled(Debug, gc, stringdedup)) {
 144       G1StringDedupStat::print_statistics(last_stat, false);
 145       G1StringDedupStat::print_statistics(total_stat, true);
 146       G1StringDedupTable::print_statistics();
 147       G1StringDedupQueue::print_statistics();
 148     }
 149   }
 150 }
< prev index next >