< prev index next >

src/hotspot/share/gc/shared/gcConfig.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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 "gc/serial/serialArguments.hpp"
  27 #include "gc/shared/gcConfig.hpp"
  28 #include "runtime/java.hpp"
  29 #include "runtime/os.hpp"
  30 #include "utilities/macros.hpp"
  31 #if INCLUDE_ALL_GCS
  32 #include "gc/parallel/parallelArguments.hpp"
  33 #include "gc/cms/cmsArguments.hpp"


  34 #include "gc/g1/g1Arguments.hpp"
  35 #endif // INCLUDE_ALL_GCS






  36 
  37 struct SupportedGC {
  38   bool&               _flag;
  39   CollectedHeap::Name _name;
  40   GCArguments&        _arguments;
  41 
  42   SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments) :
  43       _flag(flag), _name(name), _arguments(arguments) {}
  44 };
  45 
  46 static SerialArguments   serialArguments;
  47 #if INCLUDE_ALL_GCS
  48 static ParallelArguments parallelArguments;
  49 static CMSArguments      cmsArguments;
  50 static G1Arguments       g1Arguments;
  51 #endif // INCLUDE_ALL_GCS
  52 
  53 // Table of supported GCs, for translating between command
  54 // line flag, CollectedHeap::Name and GCArguments instance.
  55 static const SupportedGC SupportedGCs[] = {
  56   SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments),
  57 #if INCLUDE_ALL_GCS
  58   SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments),
  59   SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments),
  60   SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments),
  61   SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments),
  62 #endif // INCLUDE_ALL_GCS
  63 };
  64 
  65 GCArguments* GCConfig::_arguments = NULL;
  66 bool GCConfig::_gc_selected_ergonomically = false;
  67 
  68 void GCConfig::select_gc_ergonomically() {
  69 #if INCLUDE_ALL_GCS
  70   if (os::is_server_class_machine()) {

  71     FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);





  72   } else {

  73     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);

  74   }
  75 #else
  76   UNSUPPORTED_OPTION(UseG1GC);
  77   UNSUPPORTED_OPTION(UseParallelGC);
  78   UNSUPPORTED_OPTION(UseParallelOldGC);
  79   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
  80   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  81 #endif // INCLUDE_ALL_GCS
  82 }
  83 
  84 bool GCConfig::is_no_gc_selected() {
  85   for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
  86     if (SupportedGCs[i]._flag) {
  87       return false;
  88     }
  89   }
  90 
  91   return true;
  92 }
  93 
  94 bool GCConfig::is_exactly_one_gc_selected() {
  95   CollectedHeap::Name selected = CollectedHeap::None;
  96 
  97   for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
  98     if (SupportedGCs[i]._flag) {
  99       if (SupportedGCs[i]._name == selected || selected == CollectedHeap::None) {
 100         // Selected
 101         selected = SupportedGCs[i]._name;




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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 "gc/shared/gcConfig.hpp"
  27 #include "runtime/java.hpp"
  28 #include "runtime/os.hpp"
  29 #include "utilities/macros.hpp"
  30 #if INCLUDE_CMSGC

  31 #include "gc/cms/cmsArguments.hpp"
  32 #endif
  33 #if INCLUDE_G1GC
  34 #include "gc/g1/g1Arguments.hpp"
  35 #endif
  36 #if INCLUDE_PARALLELGC
  37 #include "gc/parallel/parallelArguments.hpp"
  38 #endif
  39 #if INCLUDE_SERIALGC
  40 #include "gc/serial/serialArguments.hpp"
  41 #endif
  42 
  43 struct SupportedGC {
  44   bool&               _flag;
  45   CollectedHeap::Name _name;
  46   GCArguments&        _arguments;
  47 
  48   SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments) :
  49       _flag(flag), _name(name), _arguments(arguments) {}
  50 };
  51 
  52      CMSGC_ONLY(static CMSArguments      cmsArguments;)
  53       G1GC_ONLY(static G1Arguments       g1Arguments;)
  54 PARALLELGC_ONLY(static ParallelArguments parallelArguments;)
  55   SERIALGC_ONLY(static SerialArguments   serialArguments;)


  56 
  57 // Table of supported GCs, for translating between command
  58 // line flag, CollectedHeap::Name and GCArguments instance.
  59 static const SupportedGC SupportedGCs[] = {
  60        CMSGC_ONLY_ARG(SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments))
  61         G1GC_ONLY_ARG(SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments))
  62   PARALLELGC_ONLY_ARG(SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments))
  63   PARALLELGC_ONLY_ARG(SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments))
  64     SERIALGC_ONLY_ARG(SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments))


  65 };
  66 
  67 GCArguments* GCConfig::_arguments = NULL;
  68 bool GCConfig::_gc_selected_ergonomically = false;
  69 
  70 void GCConfig::select_gc_ergonomically() {

  71   if (os::is_server_class_machine()) {
  72 #if INCLUDE_G1GC
  73     FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
  74 #elif INCLUDE_PARALLELGC
  75     FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
  76 #elif INCLUDE_SERIALGC
  77     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  78 #endif
  79   } else {
  80 #if INCLUDE_SERIALGC
  81     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  82 #endif
  83   }
  84 
  85   NOT_CMSGC(UNSUPPORTED_OPTION(UseConcMarkSweepGC));
  86   NOT_G1GC(UNSUPPORTED_OPTION(UseG1GC);)
  87   NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelGC);)
  88   NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelOldGC));
  89   NOT_SERIALGC(UNSUPPORTED_OPTION(UseSerialGC);)

  90 }
  91 
  92 bool GCConfig::is_no_gc_selected() {
  93   for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
  94     if (SupportedGCs[i]._flag) {
  95       return false;
  96     }
  97   }
  98 
  99   return true;
 100 }
 101 
 102 bool GCConfig::is_exactly_one_gc_selected() {
 103   CollectedHeap::Name selected = CollectedHeap::None;
 104 
 105   for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
 106     if (SupportedGCs[i]._flag) {
 107       if (SupportedGCs[i]._name == selected || selected == CollectedHeap::None) {
 108         // Selected
 109         selected = SupportedGCs[i]._name;


< prev index next >