src/hotspot/share/runtime/serviceThread.cpp
changeset 55569 8e3a0ebf3497
parent 54786 ebf733a324d4
child 55740 b3ff56f955c8
--- a/src/hotspot/share/runtime/serviceThread.cpp	Tue Jul 02 14:02:32 2019 -0700
+++ b/src/hotspot/share/runtime/serviceThread.cpp	Tue Jul 02 18:24:47 2019 -0400
@@ -83,27 +83,9 @@
   }
 }
 
-static bool needs_oopstorage_cleanup(OopStorage* const* storages,
-                                     bool* needs_cleanup,
-                                     size_t size) {
-  bool any_needs_cleanup = false;
+static void cleanup_oopstorages(OopStorage* const* storages, size_t size) {
   for (size_t i = 0; i < size; ++i) {
-    assert(!needs_cleanup[i], "precondition");
-    if (storages[i]->needs_delete_empty_blocks()) {
-      needs_cleanup[i] = true;
-      any_needs_cleanup = true;
-    }
-  }
-  return any_needs_cleanup;
-}
-
-static void cleanup_oopstorages(OopStorage* const* storages,
-                                const bool* needs_cleanup,
-                                size_t size) {
-  for (size_t i = 0; i < size; ++i) {
-    if (needs_cleanup[i]) {
-      storages[i]->delete_empty_blocks();
-    }
+    storages[i]->delete_empty_blocks();
   }
 }
 
@@ -126,7 +108,6 @@
     bool resolved_method_table_work = false;
     bool protection_domain_table_work = false;
     bool oopstorage_work = false;
-    bool oopstorages_cleanup[oopstorage_count] = {}; // Zero (false) initialize.
     JvmtiDeferredEvent jvmti_event;
     {
       // Need state transition ThreadBlockInVM so that this thread
@@ -152,10 +133,7 @@
               (symboltable_work = SymbolTable::has_work()) |
               (resolved_method_table_work = ResolvedMethodTable::has_work()) |
               (protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()) |
-              (oopstorage_work = needs_oopstorage_cleanup(oopstorages,
-                                                          oopstorages_cleanup,
-                                                          oopstorage_count)))
-
+              (oopstorage_work = OopStorage::has_cleanup_work_and_reset()))
              == 0) {
         // Wait until notified that there is some work to do.
         ml.wait();
@@ -199,7 +177,7 @@
     }
 
     if (oopstorage_work) {
-      cleanup_oopstorages(oopstorages, oopstorages_cleanup, oopstorage_count);
+      cleanup_oopstorages(oopstorages, oopstorage_count);
     }
   }
 }