changeset 50875:3d4b26a487d7

ZGC: Support for signaling the ServiceThread to remove cleaned StringTable entries
author pliden
date Fri, 08 Jun 2018 18:24:45 +0200
parents 3f7d18a79e8e
children e95f45dc3927
files src/hotspot/share/gc/z/zRootsIterator.cpp
diffstat 1 files changed, 57 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/z/zRootsIterator.cpp	Fri Jun 08 18:24:45 2018 +0200
+++ b/src/hotspot/share/gc/z/zRootsIterator.cpp	Fri Jun 08 18:24:45 2018 +0200
@@ -341,9 +341,34 @@
   SymbolTable::possibly_parallel_unlink(&dummy, &dummy);
 }
 
+class ZStringTableDeadCounterBoolObjectClosure : public BoolObjectClosure  {
+private:
+  BoolObjectClosure* const _cl;
+  size_t                   _ndead;
+
+public:
+  ZStringTableDeadCounterBoolObjectClosure(BoolObjectClosure* cl) :
+      _cl(cl),
+      _ndead(0) {}
+
+  ~ZStringTableDeadCounterBoolObjectClosure() {
+    StringTable::inc_dead_counter(_ndead);
+  }
+
+  virtual bool do_object_b(oop obj) {
+    if (_cl->do_object_b(obj)) {
+      return true;
+    }
+
+    _ndead++;
+    return false;
+  }
+};
+
 void ZWeakRootsIterator::do_string_table(BoolObjectClosure* is_alive, OopClosure* cl) {
   ZStatTimer timer(ZSubPhasePauseWeakRootsStringTable);
-  _string_table_iter.weak_oops_do(is_alive, cl);
+  ZStringTableDeadCounterBoolObjectClosure counter_is_alive(is_alive);
+  _string_table_iter.weak_oops_do(&counter_is_alive, cl);
 }
 
 void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl) {
@@ -377,7 +402,9 @@
     _string_table_iter(StringTable::weak_storage()),
     _vm_weak_handles(this),
     _jni_weak_handles(this),
-    _string_table(this) {}
+    _string_table(this) {
+  StringTable::reset_dead_counter();
+}
 
 void ZConcurrentWeakRootsIterator::do_vm_weak_handles(OopClosure* cl) {
   ZStatTimer timer(ZSubPhaseConcurrentWeakRootsVMWeakHandles);
@@ -389,9 +416,36 @@
   _jni_weak_handles_iter.oops_do(cl);
 }
 
+class ZStringTableDeadCounterOopClosure : public OopClosure  {
+private:
+  OopClosure* const _cl;
+  size_t            _ndead;
+
+public:
+  ZStringTableDeadCounterOopClosure(OopClosure* cl) :
+      _cl(cl),
+      _ndead(0) {}
+
+  ~ZStringTableDeadCounterOopClosure() {
+    StringTable::inc_dead_counter(_ndead);
+  }
+
+  virtual void do_oop(oop* p) {
+    _cl->do_oop(p);
+    if (*p == NULL) {
+      _ndead++;
+    }
+  }
+
+  virtual void do_oop(narrowOop* p) {
+    ShouldNotReachHere();
+  }
+};
+
 void ZConcurrentWeakRootsIterator::do_string_table(OopClosure* cl) {
   ZStatTimer timer(ZSubPhaseConcurrentWeakRootsStringTable);
-  _string_table_iter.oops_do(cl);
+  ZStringTableDeadCounterOopClosure counter_cl(cl);
+  _string_table_iter.oops_do(&counter_cl);
 }
 
 void ZConcurrentWeakRootsIterator::oops_do(OopClosure* cl) {