8065305: Make it possible to extend the G1CollectorPolicy
authorjwilhelm
Tue, 25 Nov 2014 13:41:08 +0100
changeset 27892 06a143c836ad
parent 27887 8e793accbf05
child 27893 527177401964
8065305: Make it possible to extend the G1CollectorPolicy Summary: Added a G1CollectorPolicyExt where it is possible to extend the class. Reviewed-by: sjohanss, tschatzl
hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy_ext.hpp
hotspot/src/share/vm/memory/universe.cpp
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/arguments.hpp
hotspot/src/share/vm/runtime/arguments_ext.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Fri May 17 17:24:20 2013 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Tue Nov 25 13:41:08 2014 +0100
@@ -1425,6 +1425,18 @@
 #endif // PRODUCT
 }
 
+bool G1CollectorPolicy::is_young_list_full() {
+  uint young_list_length = _g1->young_list()->length();
+  uint young_list_target_length = _young_list_target_length;
+  return young_list_length >= young_list_target_length;
+}
+
+bool G1CollectorPolicy::can_expand_young_list() {
+  uint young_list_length = _g1->young_list()->length();
+  uint young_list_max_length = _young_list_max_length;
+  return young_list_length < young_list_max_length;
+}
+
 uint G1CollectorPolicy::max_regions(int purpose) {
   switch (purpose) {
     case GCAllocForSurvived:
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Fri May 17 17:24:20 2013 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Tue Nov 25 13:41:08 2014 +0100
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
 
 #include "gc_implementation/g1/collectionSetChooser.hpp"
+#include "gc_implementation/g1/g1Allocator.hpp"
 #include "gc_implementation/g1/g1MMUTracker.hpp"
 #include "memory/collectorPolicy.hpp"
 
@@ -807,7 +808,7 @@
 
   // If an expansion would be appropriate, because recent GC overhead had
   // exceeded the desired limit, return an amount to expand by.
-  size_t expansion_amount();
+  virtual size_t expansion_amount();
 
   // Print tracing information.
   void print_tracing_info() const;
@@ -826,17 +827,9 @@
 
   size_t young_list_target_length() const { return _young_list_target_length; }
 
-  bool is_young_list_full() {
-    uint young_list_length = _g1->young_list()->length();
-    uint young_list_target_length = _young_list_target_length;
-    return young_list_length >= young_list_target_length;
-  }
+  bool is_young_list_full();
 
-  bool can_expand_young_list() {
-    uint young_list_length = _g1->young_list()->length();
-    uint young_list_max_length = _young_list_max_length;
-    return young_list_length < young_list_max_length;
-  }
+  bool can_expand_young_list();
 
   uint young_list_max_length() {
     return _young_list_max_length;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy_ext.hpp	Tue Nov 25 13:41:08 2014 +0100
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014, 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_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_EXT_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_EXT_HPP
+
+#include "gc_implementation/g1/g1CollectorPolicy.hpp"
+
+class G1CollectorPolicyExt : public G1CollectorPolicy { };
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_EXT_HPP
--- a/hotspot/src/share/vm/memory/universe.cpp	Fri May 17 17:24:20 2013 +0200
+++ b/hotspot/src/share/vm/memory/universe.cpp	Tue Nov 25 13:41:08 2014 +0100
@@ -76,7 +76,7 @@
 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
-#include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1CollectorPolicy_ext.hpp"
 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
 #endif // INCLUDE_ALL_GCS
 #if INCLUDE_CDS
@@ -799,7 +799,7 @@
 
   } else if (UseG1GC) {
 #if INCLUDE_ALL_GCS
-    G1CollectorPolicy* g1p = new G1CollectorPolicy();
+    G1CollectorPolicyExt* g1p = new G1CollectorPolicyExt();
     g1p->initialize_all();
     G1CollectedHeap* g1h = new G1CollectedHeap(g1p);
     Universe::_collectedHeap = g1h;
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Fri May 17 17:24:20 2013 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Tue Nov 25 13:41:08 2014 +0100
@@ -2300,7 +2300,7 @@
     FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
   }
 
-  status = status && ArgumentsExt::check_gc_consistency_user();
+  status = status && check_gc_consistency_user();
   status = status && check_stack_pages();
 
   status = status && verify_percentage(CMSIncrementalSafetyFactor,
@@ -3556,7 +3556,7 @@
     }
   }
 
-  if (!ArgumentsExt::check_vm_args_consistency()) {
+  if (!check_vm_args_consistency()) {
     return JNI_ERR;
   }
 
@@ -3954,7 +3954,7 @@
   // Set heap size based on available physical memory
   set_heap_size();
 
-  set_gc_specific_flags();
+  ArgumentsExt::set_gc_specific_flags();
 
   // Initialize Metaspace flags and alignments
   Metaspace::ergo_initialize();
--- a/hotspot/src/share/vm/runtime/arguments.hpp	Fri May 17 17:24:20 2013 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.hpp	Tue Nov 25 13:41:08 2014 +0100
@@ -346,7 +346,6 @@
   static void select_gc();
   static void set_ergonomics_flags();
   static void set_shared_spaces_flags();
-  static void set_gc_specific_flags();
   // limits the given memory size by the maximum amount of memory this process is
   // currently allowed to allocate or reserve.
   static julong limit_by_allocatable_memory(julong size);
@@ -458,6 +457,7 @@
   // Adjusts the arguments after the OS have adjusted the arguments
   static jint adjust_after_os();
 
+  static void set_gc_specific_flags();
   static inline bool gc_selected(); // whether a gc has been selected
   static void select_gc_ergonomically();
 
--- a/hotspot/src/share/vm/runtime/arguments_ext.hpp	Fri May 17 17:24:20 2013 +0200
+++ b/hotspot/src/share/vm/runtime/arguments_ext.hpp	Tue Nov 25 13:41:08 2014 +0100
@@ -31,9 +31,8 @@
 class ArgumentsExt: AllStatic {
 public:
   static inline void select_gc_ergonomically();
-  static inline bool check_gc_consistency_user();
+  static inline void set_gc_specific_flags();
   static inline bool check_gc_consistency_ergo();
-  static inline bool check_vm_args_consistency();
   // The argument processing extension. Returns true if there is
   // no additional parsing needed in Arguments::parse() for the option.
   // Otherwise returns false.
@@ -44,16 +43,12 @@
   Arguments::select_gc_ergonomically();
 }
 
-bool ArgumentsExt::check_gc_consistency_user() {
-  return Arguments::check_gc_consistency_user();
+void ArgumentsExt::set_gc_specific_flags() {
+  Arguments::set_gc_specific_flags();
 }
 
 bool ArgumentsExt::check_gc_consistency_ergo() {
   return Arguments::check_gc_consistency_ergo();
 }
 
-bool ArgumentsExt::check_vm_args_consistency() {
-  return Arguments::check_vm_args_consistency();
-}
-
 #endif // SHARE_VM_RUNTIME_ARGUMENTS_EXT_HPP