< prev index next >

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

Print this page
rev 48019 : 8191821: Finer granularity for GC verification
Reviewed-by:
rev 48020 : [mq]: 8191821-rev-sang-poonam


   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/gcArguments.hpp"
  27 #include "gc/serial/serialArguments.hpp"

  28 #include "memory/allocation.inline.hpp"
  29 #include "runtime/arguments.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/os.hpp"
  34 #include "utilities/defaultStream.hpp"
  35 #include "utilities/macros.hpp"
  36 
  37 #if INCLUDE_ALL_GCS
  38 #include "gc/parallel/parallelArguments.hpp"
  39 #include "gc/cms/cmsArguments.hpp"
  40 #include "gc/g1/g1Arguments.hpp"
  41 #endif
  42 
  43 GCArguments* GCArguments::_instance = NULL;
  44 
  45 GCArguments* GCArguments::arguments() {
  46   assert(is_initialized(), "Heap factory not yet created");
  47   return _instance;


  67     }
  68   }
  69 }
  70 
  71 void GCArguments::select_gc_ergonomically() {
  72 #if INCLUDE_ALL_GCS
  73   if (os::is_server_class_machine()) {
  74     FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
  75   } else {
  76     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  77   }
  78 #else
  79   UNSUPPORTED_OPTION(UseG1GC);
  80   UNSUPPORTED_OPTION(UseParallelGC);
  81   UNSUPPORTED_OPTION(UseParallelOldGC);
  82   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
  83   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  84 #endif // INCLUDE_ALL_GCS
  85 }
  86 






  87 void GCArguments::initialize_flags() {
  88 #if INCLUDE_ALL_GCS
  89   if (MinHeapFreeRatio == 100) {
  90     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
  91     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
  92   }
  93 
  94   // If class unloading is disabled, also disable concurrent class unloading.
  95   if (!ClassUnloading) {
  96     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
  97     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
  98   }
  99 #endif // INCLUDE_ALL_GCS


















 100 }
 101 
 102 jint GCArguments::initialize() {
 103   assert(!is_initialized(), "GC arguments already initialized");
 104 
 105   select_gc();
 106 
 107 #if !INCLUDE_ALL_GCS
 108   if (UseParallelGC || UseParallelOldGC) {
 109     jio_fprintf(defaultStream::error_stream(), "UseParallelGC not supported in this VM.\n");
 110     return JNI_ERR;
 111   } else if (UseG1GC) {
 112     jio_fprintf(defaultStream::error_stream(), "UseG1GC not supported in this VM.\n");
 113     return JNI_ERR;
 114   } else if (UseConcMarkSweepGC) {
 115     jio_fprintf(defaultStream::error_stream(), "UseConcMarkSweepGC not supported in this VM.\n");
 116     return JNI_ERR;
 117 #else
 118   if (UseParallelGC || UseParallelOldGC) {
 119     _instance = new ParallelArguments();


   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/gcArguments.hpp"
  27 #include "gc/serial/serialArguments.hpp"
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "runtime/arguments.hpp"
  31 #include "runtime/globals.hpp"
  32 #include "runtime/globals_extension.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/os.hpp"
  35 #include "utilities/defaultStream.hpp"
  36 #include "utilities/macros.hpp"
  37 
  38 #if INCLUDE_ALL_GCS
  39 #include "gc/parallel/parallelArguments.hpp"
  40 #include "gc/cms/cmsArguments.hpp"
  41 #include "gc/g1/g1Arguments.hpp"
  42 #endif
  43 
  44 GCArguments* GCArguments::_instance = NULL;
  45 
  46 GCArguments* GCArguments::arguments() {
  47   assert(is_initialized(), "Heap factory not yet created");
  48   return _instance;


  68     }
  69   }
  70 }
  71 
  72 void GCArguments::select_gc_ergonomically() {
  73 #if INCLUDE_ALL_GCS
  74   if (os::is_server_class_machine()) {
  75     FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
  76   } else {
  77     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  78   }
  79 #else
  80   UNSUPPORTED_OPTION(UseG1GC);
  81   UNSUPPORTED_OPTION(UseParallelGC);
  82   UNSUPPORTED_OPTION(UseParallelOldGC);
  83   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
  84   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
  85 #endif // INCLUDE_ALL_GCS
  86 }
  87 
  88 bool GCArguments::parse_verification_type(const char* type) {
  89   log_warning(gc, verify)("VerifyGCType is not supported by this collector.");
  90   // Return false to avoid multiple warnings.
  91   return false;
  92 }
  93 
  94 void GCArguments::initialize_flags() {
  95 #if INCLUDE_ALL_GCS
  96   if (MinHeapFreeRatio == 100) {
  97     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
  98     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
  99   }
 100 
 101   // If class unloading is disabled, also disable concurrent class unloading.
 102   if (!ClassUnloading) {
 103     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
 104     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
 105   }
 106 #endif // INCLUDE_ALL_GCS
 107 }
 108 
 109 void GCArguments::post_heap_initialize() {
 110   if (strlen(VerifyGCType) > 0) {
 111     const char delimiter[] = " ,\n";
 112     size_t length = strlen(VerifyGCType);
 113     char* type_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
 114     strncpy(type_list, VerifyGCType, length + 1);
 115     char* token = strtok(type_list, delimiter);
 116     while (token != NULL) {
 117       bool success = parse_verification_type(token);
 118       if (!success) {
 119         break;
 120       }
 121       token = strtok(NULL, delimiter);
 122     }
 123     FREE_C_HEAP_ARRAY(char, type_list);
 124   }
 125 }
 126 
 127 jint GCArguments::initialize() {
 128   assert(!is_initialized(), "GC arguments already initialized");
 129 
 130   select_gc();
 131 
 132 #if !INCLUDE_ALL_GCS
 133   if (UseParallelGC || UseParallelOldGC) {
 134     jio_fprintf(defaultStream::error_stream(), "UseParallelGC not supported in this VM.\n");
 135     return JNI_ERR;
 136   } else if (UseG1GC) {
 137     jio_fprintf(defaultStream::error_stream(), "UseG1GC not supported in this VM.\n");
 138     return JNI_ERR;
 139   } else if (UseConcMarkSweepGC) {
 140     jio_fprintf(defaultStream::error_stream(), "UseConcMarkSweepGC not supported in this VM.\n");
 141     return JNI_ERR;
 142 #else
 143   if (UseParallelGC || UseParallelOldGC) {
 144     _instance = new ParallelArguments();
< prev index next >