< prev index next >

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

Print this page




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/stringTable.hpp"
  27 #include "gc/g1/g1StringDedup.hpp"
  28 #include "gc/g1/g1StringDedupQueue.hpp"
  29 #include "gc/g1/g1StringDedupTable.hpp"
  30 #include "gc/g1/g1StringDedupThread.hpp"
  31 #include "gc/shared/suspendibleThreadSet.hpp"
  32 #include "logging/log.hpp"

  33 #include "oops/oop.inline.hpp"
  34 #include "runtime/atomic.hpp"
  35 
  36 G1StringDedupThread* G1StringDedupThread::_thread = NULL;
  37 
  38 G1StringDedupThread::G1StringDedupThread() :
  39   ConcurrentGCThread() {
  40   set_name("G1 StrDedup");
  41   create_and_start();
  42 }
  43 
  44 G1StringDedupThread::~G1StringDedupThread() {
  45   ShouldNotReachHere();
  46 }
  47 
  48 void G1StringDedupThread::create() {
  49   assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
  50   assert(_thread == NULL, "One string deduplication thread allowed");
  51   _thread = new G1StringDedupThread();
  52 }
  53 
  54 G1StringDedupThread* G1StringDedupThread::thread() {
  55   assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
  56   assert(_thread != NULL, "String deduplication thread not created");
  57   return _thread;
  58 }
  59 
  60 class G1StringDedupSharedClosure: public OopClosure {
  61  private:
  62   G1StringDedupStat& _stat;
  63 
  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




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/stringTable.hpp"
  27 #include "gc/g1/g1StringDedup.hpp"
  28 #include "gc/g1/g1StringDedupQueue.hpp"
  29 #include "gc/g1/g1StringDedupTable.hpp"
  30 #include "gc/g1/g1StringDedupThread.hpp"
  31 #include "gc/shared/suspendibleThreadSet.hpp"
  32 #include "logging/log.hpp"
  33 #include "oops/access.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "runtime/atomic.hpp"
  36 
  37 G1StringDedupThread* G1StringDedupThread::_thread = NULL;
  38 
  39 G1StringDedupThread::G1StringDedupThread() :
  40   ConcurrentGCThread() {
  41   set_name("G1 StrDedup");
  42   create_and_start();
  43 }
  44 
  45 G1StringDedupThread::~G1StringDedupThread() {
  46   ShouldNotReachHere();
  47 }
  48 
  49 void G1StringDedupThread::create() {
  50   assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
  51   assert(_thread == NULL, "One string deduplication thread allowed");
  52   _thread = new G1StringDedupThread();
  53 }
  54 
  55 G1StringDedupThread* G1StringDedupThread::thread() {
  56   assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
  57   assert(_thread != NULL, "String deduplication thread not created");
  58   return _thread;
  59 }
  60 
  61 class G1StringDedupSharedClosure: public OopClosure {
  62  private:
  63   G1StringDedupStat& _stat;
  64 
  65  public:
  66   G1StringDedupSharedClosure(G1StringDedupStat& stat) : _stat(stat) {}
  67 
  68   virtual void do_oop(oop* p) { ShouldNotReachHere(); }
  69   virtual void do_oop(narrowOop* p) {
  70     oop java_string = RawAccess<>::oop_load(p);
  71     G1StringDedupTable::deduplicate(java_string, _stat);
  72   }
  73 };
  74 
  75 // The CDS archive does not include the string dedupication table. Only the string
  76 // table is saved in the archive. The shared strings from CDS archive need to be
  77 // added to the string dedupication table before deduplication occurs. That is
  78 // done in the begining of the G1StringDedupThread (see G1StringDedupThread::run()
  79 // below).
  80 void G1StringDedupThread::deduplicate_shared_strings(G1StringDedupStat& stat) {
  81   G1StringDedupSharedClosure sharedStringDedup(stat);
  82   StringTable::shared_oops_do(&sharedStringDedup);
  83 }
  84 
  85 void G1StringDedupThread::run_service() {
  86   G1StringDedupStat total_stat;
  87 
  88   deduplicate_shared_strings(total_stat);
  89 
  90   // Main loop


< prev index next >