8227927: Move ParallelCleaningTask back to G1
authorzgu
Wed, 24 Jul 2019 08:34:06 -0400
changeset 57510 4db4d0d14390
parent 57509 c64a2df9dc7d
child 57511 00ae3b739184
8227927: Move ParallelCleaningTask back to G1 Reviewed-by: tschatzl, kbarrett
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
src/hotspot/share/gc/g1/g1ParallelCleaning.cpp
src/hotspot/share/gc/g1/g1ParallelCleaning.hpp
src/hotspot/share/gc/shared/parallelCleaning.cpp
src/hotspot/share/gc/shared/parallelCleaning.hpp
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed Jul 24 13:08:36 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed Jul 24 08:34:06 2019 -0400
@@ -48,6 +48,7 @@
 #include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1MemoryPool.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
+#include "gc/g1/g1ParallelCleaning.hpp"
 #include "gc/g1/g1ParScanThreadState.inline.hpp"
 #include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1RedirtyCardsQueue.hpp"
@@ -74,7 +75,6 @@
 #include "gc/shared/generationSpec.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
 #include "gc/shared/oopStorageParState.hpp"
-#include "gc/shared/parallelCleaning.hpp"
 #include "gc/shared/preservedMarks.inline.hpp"
 #include "gc/shared/suspendibleThreadSet.hpp"
 #include "gc/shared/referenceProcessor.inline.hpp"
@@ -3165,7 +3165,7 @@
 void G1CollectedHeap::complete_cleaning(BoolObjectClosure* is_alive,
                                         bool class_unloading_occurred) {
   uint num_workers = workers()->active_workers();
-  ParallelCleaningTask unlink_task(is_alive, num_workers, class_unloading_occurred, false);
+  G1ParallelCleaningTask unlink_task(is_alive, num_workers, class_unloading_occurred, false);
   workers()->run_task(&unlink_task);
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp	Wed Jul 24 08:34:06 2019 -0400
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+
+#include "gc/g1/g1ParallelCleaning.hpp"
+#if INCLUDE_JVMCI
+#include "jvmci/jvmci.hpp"
+#endif
+
+#if INCLUDE_JVMCI
+JVMCICleaningTask::JVMCICleaningTask() :
+  _cleaning_claimed(0) {
+}
+
+bool JVMCICleaningTask::claim_cleaning_task() {
+  if (_cleaning_claimed) {
+    return false;
+  }
+
+  return Atomic::cmpxchg(1, &_cleaning_claimed, 0) == 0;
+}
+
+void JVMCICleaningTask::work(bool unloading_occurred) {
+  // One worker will clean JVMCI metadata handles.
+  if (unloading_occurred && EnableJVMCI && claim_cleaning_task()) {
+    JVMCI::do_unloading(unloading_occurred);
+  }
+}
+#endif // INCLUDE_JVMCI
+
+G1ParallelCleaningTask::G1ParallelCleaningTask(BoolObjectClosure* is_alive,
+                                               uint num_workers,
+                                               bool unloading_occurred,
+                                               bool resize_dedup_table) :
+  AbstractGangTask("G1 Parallel Cleaning"),
+  _unloading_occurred(unloading_occurred),
+  _string_dedup_task(is_alive, NULL, resize_dedup_table),
+  _code_cache_task(num_workers, is_alive, unloading_occurred),
+  JVMCI_ONLY(_jvmci_cleaning_task() COMMA)
+  _klass_cleaning_task() {
+}
+
+// The parallel work done by all worker threads.
+void G1ParallelCleaningTask::work(uint worker_id) {
+  // Clean JVMCI metadata handles.
+  // Execute this task first because it is serial task.
+  JVMCI_ONLY(_jvmci_cleaning_task.work(_unloading_occurred);)
+
+  // Do first pass of code cache cleaning.
+  _code_cache_task.work(worker_id);
+
+  // Clean the string dedup data structures.
+  _string_dedup_task.work(worker_id);
+
+  // Clean all klasses that were not unloaded.
+  // The weak metadata in klass doesn't need to be
+  // processed if there was no unloading.
+  if (_unloading_occurred) {
+    _klass_cleaning_task.work();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp	Wed Jul 24 08:34:06 2019 -0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_GC_G1_G1PARALLELCLEANING_HPP
+#define SHARE_GC_G1_G1PARALLELCLEANING_HPP
+
+#include "gc/shared/parallelCleaning.hpp"
+
+#if INCLUDE_JVMCI
+class JVMCICleaningTask : public StackObj {
+  volatile int       _cleaning_claimed;
+
+public:
+  JVMCICleaningTask();
+  // Clean JVMCI metadata handles.
+  void work(bool unloading_occurred);
+
+private:
+  bool claim_cleaning_task();
+};
+#endif
+
+// Do cleanup of some weakly held data in the same parallel task.
+// Assumes a non-moving context.
+class G1ParallelCleaningTask : public AbstractGangTask {
+private:
+  bool                    _unloading_occurred;
+  StringDedupCleaningTask _string_dedup_task;
+  CodeCacheUnloadingTask  _code_cache_task;
+#if INCLUDE_JVMCI
+  JVMCICleaningTask       _jvmci_cleaning_task;
+#endif
+  KlassCleaningTask       _klass_cleaning_task;
+
+public:
+  // The constructor is run in the VMThread.
+  G1ParallelCleaningTask(BoolObjectClosure* is_alive,
+                         uint num_workers,
+                         bool unloading_occurred,
+                         bool resize_dedup_table);
+
+  void work(uint worker_id);
+};
+
+#endif // SHARE_GC_G1_G1PARALLELCLEANING_HPP
--- a/src/hotspot/share/gc/shared/parallelCleaning.cpp	Wed Jul 24 13:08:36 2019 +0100
+++ b/src/hotspot/share/gc/shared/parallelCleaning.cpp	Wed Jul 24 08:34:06 2019 -0400
@@ -30,9 +30,6 @@
 #include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "logging/log.hpp"
-#if INCLUDE_JVMCI
-#include "jvmci/jvmci.hpp"
-#endif
 
 StringDedupCleaningTask::StringDedupCleaningTask(BoolObjectClosure* is_alive,
                                                  OopClosure* keep_alive,
@@ -160,56 +157,3 @@
     clean_klass(klass);
   }
 }
-
-#if INCLUDE_JVMCI
-JVMCICleaningTask::JVMCICleaningTask() :
-  _cleaning_claimed(0) {
-}
-
-bool JVMCICleaningTask::claim_cleaning_task() {
-  if (_cleaning_claimed) {
-    return false;
-  }
-
-  return Atomic::cmpxchg(1, &_cleaning_claimed, 0) == 0;
-}
-
-void JVMCICleaningTask::work(bool unloading_occurred) {
-  // One worker will clean JVMCI metadata handles.
-  if (unloading_occurred && EnableJVMCI && claim_cleaning_task()) {
-    JVMCI::do_unloading(unloading_occurred);
-  }
-}
-#endif // INCLUDE_JVMCI
-
-ParallelCleaningTask::ParallelCleaningTask(BoolObjectClosure* is_alive,
-                                           uint num_workers,
-                                           bool unloading_occurred,
-                                           bool resize_dedup_table) :
-  AbstractGangTask("Parallel Cleaning"),
-  _unloading_occurred(unloading_occurred),
-  _string_dedup_task(is_alive, NULL, resize_dedup_table),
-  _code_cache_task(num_workers, is_alive, unloading_occurred),
-  JVMCI_ONLY(_jvmci_cleaning_task() COMMA)
-  _klass_cleaning_task() {
-}
-
-// The parallel work done by all worker threads.
-void ParallelCleaningTask::work(uint worker_id) {
-  // Clean JVMCI metadata handles.
-  // Execute this task first because it is serial task.
-  JVMCI_ONLY(_jvmci_cleaning_task.work(_unloading_occurred);)
-
-  // Do first pass of code cache cleaning.
-  _code_cache_task.work(worker_id);
-
-  // Clean the string dedup data structures.
-  _string_dedup_task.work(worker_id);
-
-  // Clean all klasses that were not unloaded.
-  // The weak metadata in klass doesn't need to be
-  // processed if there was no unloading.
-  if (_unloading_occurred) {
-    _klass_cleaning_task.work();
-  }
-}
--- a/src/hotspot/share/gc/shared/parallelCleaning.hpp	Wed Jul 24 13:08:36 2019 +0100
+++ b/src/hotspot/share/gc/shared/parallelCleaning.hpp	Wed Jul 24 08:34:06 2019 -0400
@@ -31,8 +31,6 @@
 #include "gc/shared/stringdedup/stringDedup.hpp"
 #include "gc/shared/workgroup.hpp"
 
-class ParallelCleaningTask;
-
 class StringDedupCleaningTask : public AbstractGangTask {
   StringDedupUnlinkOrOopsDoClosure _dedup_closure;
 
@@ -87,40 +85,4 @@
   void work();
 };
 
-#if INCLUDE_JVMCI
-class JVMCICleaningTask : public StackObj {
-  volatile int       _cleaning_claimed;
-
-public:
-  JVMCICleaningTask();
-  // Clean JVMCI metadata handles.
-  void work(bool unloading_occurred);
-
-private:
-  bool claim_cleaning_task();
-};
-#endif
-
-// Do cleanup of some weakly held data in the same parallel task.
-// Assumes a non-moving context.
-class ParallelCleaningTask : public AbstractGangTask {
-private:
-  bool                    _unloading_occurred;
-  StringDedupCleaningTask _string_dedup_task;
-  CodeCacheUnloadingTask  _code_cache_task;
-#if INCLUDE_JVMCI
-  JVMCICleaningTask       _jvmci_cleaning_task;
-#endif
-  KlassCleaningTask       _klass_cleaning_task;
-
-public:
-  // The constructor is run in the VMThread.
-  ParallelCleaningTask(BoolObjectClosure* is_alive,
-                       uint num_workers,
-                       bool unloading_occurred,
-                       bool resize_dedup_table);
-
-  void work(uint worker_id);
-};
-
 #endif // SHARE_GC_SHARED_PARALLELCLEANING_HPP