src/hotspot/share/gc/shared/gcConfig.cpp
author stefank
Fri, 04 May 2018 11:41:35 +0200
changeset 49982 9042ffe5b7fe
parent 49923 764aea6237ad
child 50523 7b7c75d87f9b
child 56533 28a4f284ad83
permissions -rw-r--r--
8200729: Conditional compilation of GCs Reviewed-by: ehelin, coleenp, kvn, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     1
/*
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     4
 *
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     8
 *
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    13
 * accompanied this code).
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    14
 *
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    18
 *
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    21
 * questions.
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    22
 *
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    23
 */
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    24
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    25
#include "precompiled.hpp"
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    26
#include "gc/shared/gcConfig.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    27
#include "runtime/globals_extension.hpp"
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    28
#include "runtime/java.hpp"
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    29
#include "runtime/os.hpp"
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    30
#include "utilities/macros.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    31
#if INCLUDE_CMSGC
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    32
#include "gc/cms/cmsArguments.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    33
#endif
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    34
#if INCLUDE_G1GC
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    35
#include "gc/g1/g1Arguments.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    36
#endif
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    37
#if INCLUDE_PARALLELGC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    38
#include "gc/parallel/parallelArguments.hpp"
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    39
#endif
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    40
#if INCLUDE_SERIALGC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    41
#include "gc/serial/serialArguments.hpp"
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    42
#endif
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    43
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    44
struct SupportedGC {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    45
  bool&               _flag;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    46
  CollectedHeap::Name _name;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    47
  GCArguments&        _arguments;
49922
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
    48
  const char*         _hs_err_name;
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    49
49922
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
    50
  SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) :
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
    51
      _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {}
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    52
};
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    53
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    54
     CMSGC_ONLY(static CMSArguments      cmsArguments;)
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    55
      G1GC_ONLY(static G1Arguments       g1Arguments;)
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    56
PARALLELGC_ONLY(static ParallelArguments parallelArguments;)
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    57
  SERIALGC_ONLY(static SerialArguments   serialArguments;)
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    58
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    59
// Table of supported GCs, for translating between command
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    60
// line flag, CollectedHeap::Name and GCArguments instance.
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    61
static const SupportedGC SupportedGCs[] = {
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    62
       CMSGC_ONLY_ARG(SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments,      "concurrent mark sweep gc"))
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    63
        G1GC_ONLY_ARG(SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments,       "g1 gc"))
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    64
  PARALLELGC_ONLY_ARG(SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments, "parallel gc"))
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    65
  PARALLELGC_ONLY_ARG(SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments, "parallel gc"))
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    66
    SERIALGC_ONLY_ARG(SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments,   "serial gc"))
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    67
};
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    68
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
    69
#define FOR_EACH_SUPPORTED_GC(var) \
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
    70
  for (const SupportedGC* var = &SupportedGCs[0]; var < &SupportedGCs[ARRAY_SIZE(SupportedGCs)]; var++)
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
    71
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    72
GCArguments* GCConfig::_arguments = NULL;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    73
bool GCConfig::_gc_selected_ergonomically = false;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    74
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    75
void GCConfig::select_gc_ergonomically() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    76
  if (os::is_server_class_machine()) {
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    77
#if INCLUDE_G1GC
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    78
    FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    79
#elif INCLUDE_PARALLELGC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    80
    FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    81
#elif INCLUDE_SERIALGC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    82
    FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    83
#endif
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    84
  } else {
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    85
#if INCLUDE_SERIALGC
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    86
    FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    87
#endif
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    88
  }
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    89
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    90
  NOT_CMSGC(     UNSUPPORTED_OPTION(UseConcMarkSweepGC));
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    91
  NOT_G1GC(      UNSUPPORTED_OPTION(UseG1GC);)
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    92
  NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelGC);)
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    93
  NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelOldGC));
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
    94
  NOT_SERIALGC(  UNSUPPORTED_OPTION(UseSerialGC);)
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    95
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    96
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
    97
bool GCConfig::is_no_gc_selected() {
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
    98
  FOR_EACH_SUPPORTED_GC(gc) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
    99
    if (gc->_flag) {
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   100
      return false;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   101
    }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   102
  }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   103
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   104
  return true;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   105
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   106
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   107
bool GCConfig::is_exactly_one_gc_selected() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   108
  CollectedHeap::Name selected = CollectedHeap::None;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   109
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   110
  FOR_EACH_SUPPORTED_GC(gc) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   111
    if (gc->_flag) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   112
      if (gc->_name == selected || selected == CollectedHeap::None) {
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   113
        // Selected
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   114
        selected = gc->_name;
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   115
      } else {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   116
        // More than one selected
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   117
        return false;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   118
      }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   119
    }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   120
  }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   121
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   122
  return selected != CollectedHeap::None;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   123
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   124
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   125
GCArguments* GCConfig::select_gc() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   126
  if (is_no_gc_selected()) {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   127
    // Try select GC ergonomically
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   128
    select_gc_ergonomically();
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   129
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   130
    if (is_no_gc_selected()) {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   131
      // Failed to select GC ergonomically
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   132
      vm_exit_during_initialization("Garbage collector not selected "
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   133
                                    "(default collector explicitly disabled)", NULL);
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   134
    }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   135
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   136
    // Succeeded to select GC ergonomically
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   137
    _gc_selected_ergonomically = true;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   138
  }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   139
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   140
  if (!is_exactly_one_gc_selected()) {
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   141
    // More than one GC selected
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   142
    vm_exit_during_initialization("Multiple garbage collectors selected", NULL);
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   143
  }
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   144
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   145
#if INCLUDE_PARALLELGC && !INCLUDE_SERIALGC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   146
  if (FLAG_IS_CMDLINE(UseParallelOldGC) && !UseParallelOldGC) {
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   147
    vm_exit_during_initialization("This JVM build only supports UseParallelOldGC as the full GC");
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   148
  }
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   149
#endif
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   150
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   151
  // Exactly one GC selected
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   152
  FOR_EACH_SUPPORTED_GC(gc) {
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   153
    if (gc->_flag) {
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   154
      return &gc->_arguments;
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   155
    }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   156
  }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   157
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49923
diff changeset
   158
  fatal("Should have found the selected GC");
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   159
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   160
  return NULL;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   161
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   162
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   163
void GCConfig::initialize() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   164
  assert(_arguments == NULL, "Already initialized");
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   165
  _arguments = select_gc();
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   166
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   167
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   168
bool GCConfig::is_gc_supported(CollectedHeap::Name name) {
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   169
  FOR_EACH_SUPPORTED_GC(gc) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   170
    if (gc->_name == name) {
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   171
      // Supported
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   172
      return true;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   173
    }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   174
  }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   175
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   176
  // Not supported
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   177
  return false;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   178
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   179
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   180
bool GCConfig::is_gc_selected(CollectedHeap::Name name) {
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   181
  FOR_EACH_SUPPORTED_GC(gc) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   182
    if (gc->_name == name && gc->_flag) {
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   183
      // Selected
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   184
      return true;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   185
    }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   186
  }
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   187
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   188
  // Not selected
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   189
  return false;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   190
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   191
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   192
bool GCConfig::is_gc_selected_ergonomically() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   193
  return _gc_selected_ergonomically;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   194
}
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   195
49922
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   196
const char* GCConfig::hs_err_name() {
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   197
  if (is_exactly_one_gc_selected()) {
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   198
    // Exacly one GC selected
49923
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   199
    FOR_EACH_SUPPORTED_GC(gc) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   200
      if (gc->_flag) {
764aea6237ad 8202366: Add macro for common loop in GCConfig
pliden
parents: 49922
diff changeset
   201
        return gc->_hs_err_name;
49922
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   202
      }
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   203
    }
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   204
  }
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   205
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   206
  // Zero or more than one GC selected
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   207
  return "unknown gc";
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   208
}
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49629
diff changeset
   209
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   210
GCArguments* GCConfig::arguments() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   211
  assert(_arguments != NULL, "Not initialized");
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   212
  return _arguments;
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff changeset
   213
}