src/share/vm/runtime/arguments.cpp

Print this page
rev 6853 : 8046070: Class Data Sharing clean up and refactoring
Summary: Cleaned up CDS to be more configurable, maintainable and extensible
Reviewed-by: dholmes, coleenp, acorn, mchung


   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 "classfile/javaAssertions.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/cardTableRS.hpp"
  32 #include "memory/genCollectedHeap.hpp"
  33 #include "memory/referenceProcessor.hpp"
  34 #include "memory/universe.inline.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "prims/jvmtiExport.hpp"
  37 #include "runtime/arguments.hpp"
  38 #include "runtime/globals_extension.hpp"
  39 #include "runtime/java.hpp"
  40 #include "runtime/os.hpp"
  41 #include "runtime/vm_version.hpp"
  42 #include "services/management.hpp"
  43 #include "services/memTracker.hpp"
  44 #include "utilities/defaultStream.hpp"
  45 #include "utilities/macros.hpp"

  46 #include "utilities/taskqueue.hpp"
  47 #if INCLUDE_ALL_GCS
  48 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
  49 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  50 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  51 #endif // INCLUDE_ALL_GCS
  52 
  53 // Note: This is a special bug reporting site for the JVM
  54 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
  55 #define DEFAULT_JAVA_LAUNCHER  "generic"
  56 
  57 // Disable options not supported in this release, with a warning if they
  58 // were explicitly requested on the command-line
  59 #define UNSUPPORTED_OPTION(opt, description)                    \
  60 do {                                                            \
  61   if (opt) {                                                    \
  62     if (FLAG_IS_CMDLINE(opt)) {                                 \
  63       warning(description " is disabled in this release.");     \
  64     }                                                           \
  65     FLAG_SET_DEFAULT(opt, false);                               \


1098     break;
1099   case _comp:
1100     UseInterpreter           = false;
1101     BackgroundCompilation    = false;
1102     ClipInlining             = false;
1103     // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
1104     // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
1105     // compile a level 4 (C2) and then continue executing it.
1106     if (TieredCompilation) {
1107       Tier3InvokeNotifyFreqLog = 0;
1108       Tier4InvocationThreshold = 0;
1109     }
1110     break;
1111   }
1112 }
1113 
1114 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
1115 // Conflict: required to use shared spaces (-Xshare:on), but
1116 // incompatible command line options were chosen.
1117 
1118 static void no_shared_spaces() {
1119   if (RequireSharedSpaces) {
1120     jio_fprintf(defaultStream::error_stream(),
1121       "Class data sharing is inconsistent with other specified options.\n");
1122     vm_exit_during_initialization("Unable to use shared archive.", NULL);
1123   } else {
1124     FLAG_SET_DEFAULT(UseSharedSpaces, false);
1125   }
1126 }
1127 #endif
1128 
1129 void Arguments::set_tiered_flags() {
1130   // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
1131   if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
1132     FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
1133   }
1134   if (CompilationPolicyChoice < 2) {
1135     vm_exit_during_initialization(
1136       "Incompatible compilation policy selected", NULL);
1137   }
1138   // Increase the code cache size - tiered compiles a lot more.
1139   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
1140     FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
1141   }
1142   if (!UseInterpreter) { // -Xcomp


1564     if (!UseSerialGC &&
1565         !UseConcMarkSweepGC &&
1566         !UseG1GC &&
1567         !UseParNewGC &&
1568         FLAG_IS_DEFAULT(UseParallelGC)) {
1569       if (should_auto_select_low_pause_collector()) {
1570         FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1571       } else {
1572         FLAG_SET_ERGO(bool, UseParallelGC, true);
1573       }
1574     }
1575   }
1576 #ifdef COMPILER2
1577   // Shared spaces work fine with other GCs but causes bytecode rewriting
1578   // to be disabled, which hurts interpreter performance and decreases
1579   // server performance.  When -server is specified, keep the default off
1580   // unless it is asked for.  Future work: either add bytecode rewriting
1581   // at link time, or rewrite bytecodes in non-shared methods.
1582   if (!DumpSharedSpaces && !RequireSharedSpaces &&
1583       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1584     no_shared_spaces();
1585   }
1586 #endif
1587 
1588   set_conservative_max_heap_alignment();
1589 
1590 #ifndef ZERO
1591 #ifdef _LP64
1592   set_use_compressed_oops();
1593 
1594   // set_use_compressed_klass_ptrs() must be called after calling
1595   // set_use_compressed_oops().
1596   set_use_compressed_klass_ptrs();
1597 
1598   // Also checks that certain machines are slower with compressed oops
1599   // in vm_version initialization code.
1600 #endif // _LP64
1601 #endif // !ZERO
1602 }
1603 
1604 void Arguments::set_parallel_gc_flags() {


3285       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3286 #if !INCLUDE_MANAGEMENT
3287     } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
3288         jio_fprintf(defaultStream::error_stream(),
3289           "ManagementServer is not supported in this VM.\n");
3290         return JNI_ERR;
3291 #endif // INCLUDE_MANAGEMENT
3292     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3293       // Skip -XX:Flags= since that case has already been handled
3294       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3295         if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3296           return JNI_EINVAL;
3297         }
3298       }
3299     // Unknown option
3300     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3301       return JNI_ERR;
3302     }
3303   }
3304 









3305   // Change the default value for flags  which have different default values
3306   // when working with older JDKs.
3307 #ifdef LINUX
3308  if (JDK_Version::current().compare_major(6) <= 0 &&
3309       FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
3310     FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
3311   }
3312 #endif // LINUX

3313   return JNI_OK;
3314 }
3315 













































3316 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3317   // This must be done after all -D arguments have been processed.
3318   scp_p->expand_endorsed();
3319 
3320   if (scp_assembly_required || scp_p->get_endorsed() != NULL) {
3321     // Assemble the bootclasspath elements into the final path.
3322     Arguments::set_sysclasspath(scp_p->combined_path());
3323   }
3324 
3325   // This must be done after all arguments have been processed.
3326   // java_compiler() true means set to "NONE" or empty.
3327   if (java_compiler() && !xdebug_mode()) {
3328     // For backwards compatibility, we switch to interpreted mode if
3329     // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3330     // not specified.
3331     set_mode_flags(_int);
3332   }
3333   if (CompileThreshold == 0) {
3334     set_mode_flags(_int);
3335   }


3466       }
3467     }
3468 
3469     return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
3470   }
3471   return JNI_OK;
3472 }
3473 
3474 void Arguments::set_shared_spaces_flags() {
3475   if (DumpSharedSpaces) {
3476     if (RequireSharedSpaces) {
3477       warning("cannot dump shared archive while using shared archive");
3478     }
3479     UseSharedSpaces = false;
3480 #ifdef _LP64
3481     if (!UseCompressedOops || !UseCompressedClassPointers) {
3482       vm_exit_during_initialization(
3483         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3484     }
3485   } else {
3486     // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.
3487     if (!UseCompressedOops || !UseCompressedClassPointers) {
3488       no_shared_spaces();
3489     }
3490 #endif
3491   }
3492 }
3493 
3494 #if !INCLUDE_ALL_GCS
3495 static void force_serial_gc() {
3496   FLAG_SET_DEFAULT(UseSerialGC, true);
3497   FLAG_SET_DEFAULT(CMSIncrementalMode, false);  // special CMS suboption
3498   UNSUPPORTED_GC_OPTION(UseG1GC);
3499   UNSUPPORTED_GC_OPTION(UseParallelGC);
3500   UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3501   UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3502   UNSUPPORTED_GC_OPTION(UseParNewGC);
3503 }
3504 #endif // INCLUDE_ALL_GCS
3505 
3506 // Sharing support
3507 // Construct the path to the archive
3508 static char* get_shared_archive_path() {


3708     PrintGC = true;
3709   }
3710 
3711   // Set object alignment values.
3712   set_object_alignment();
3713 
3714 #if !INCLUDE_ALL_GCS
3715   force_serial_gc();
3716 #endif // INCLUDE_ALL_GCS
3717 #if !INCLUDE_CDS
3718   if (DumpSharedSpaces || RequireSharedSpaces) {
3719     jio_fprintf(defaultStream::error_stream(),
3720       "Shared spaces are not supported in this VM\n");
3721     return JNI_ERR;
3722   }
3723   if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3724     warning("Shared spaces are not supported in this VM");
3725     FLAG_SET_DEFAULT(UseSharedSpaces, false);
3726     FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3727   }
3728   no_shared_spaces();
3729 #endif // INCLUDE_CDS
3730 
3731   return JNI_OK;
3732 }
3733 
3734 jint Arguments::apply_ergo() {
3735 
3736   // Set flags based on ergonomics.
3737   set_ergonomics_flags();
3738 
3739   set_shared_spaces_flags();
3740 
3741   // Check the GC selections again.
3742   if (!check_gc_consistency()) {
3743     return JNI_EINVAL;
3744   }
3745 
3746   if (TieredCompilation) {
3747     set_tiered_flags();
3748   } else {




   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 "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "compiler/compilerOracle.hpp"
  31 #include "memory/allocation.inline.hpp"
  32 #include "memory/cardTableRS.hpp"
  33 #include "memory/genCollectedHeap.hpp"
  34 #include "memory/referenceProcessor.hpp"
  35 #include "memory/universe.inline.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/jvmtiExport.hpp"
  38 #include "runtime/arguments.hpp"
  39 #include "runtime/globals_extension.hpp"
  40 #include "runtime/java.hpp"
  41 #include "runtime/os.hpp"
  42 #include "runtime/vm_version.hpp"
  43 #include "services/management.hpp"
  44 #include "services/memTracker.hpp"
  45 #include "utilities/defaultStream.hpp"
  46 #include "utilities/macros.hpp"
  47 #include "utilities/stringUtils.hpp"
  48 #include "utilities/taskqueue.hpp"
  49 #if INCLUDE_ALL_GCS
  50 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
  51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  52 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  53 #endif // INCLUDE_ALL_GCS
  54 
  55 // Note: This is a special bug reporting site for the JVM
  56 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
  57 #define DEFAULT_JAVA_LAUNCHER  "generic"
  58 
  59 // Disable options not supported in this release, with a warning if they
  60 // were explicitly requested on the command-line
  61 #define UNSUPPORTED_OPTION(opt, description)                    \
  62 do {                                                            \
  63   if (opt) {                                                    \
  64     if (FLAG_IS_CMDLINE(opt)) {                                 \
  65       warning(description " is disabled in this release.");     \
  66     }                                                           \
  67     FLAG_SET_DEFAULT(opt, false);                               \


1100     break;
1101   case _comp:
1102     UseInterpreter           = false;
1103     BackgroundCompilation    = false;
1104     ClipInlining             = false;
1105     // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
1106     // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
1107     // compile a level 4 (C2) and then continue executing it.
1108     if (TieredCompilation) {
1109       Tier3InvokeNotifyFreqLog = 0;
1110       Tier4InvocationThreshold = 0;
1111     }
1112     break;
1113   }
1114 }
1115 
1116 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
1117 // Conflict: required to use shared spaces (-Xshare:on), but
1118 // incompatible command line options were chosen.
1119 
1120 static void no_shared_spaces(const char* message) {
1121   if (RequireSharedSpaces) {
1122     jio_fprintf(defaultStream::error_stream(),
1123       "Class data sharing is inconsistent with other specified options.\n");
1124     vm_exit_during_initialization("Unable to use shared archive.", message);
1125   } else {
1126     FLAG_SET_DEFAULT(UseSharedSpaces, false);
1127   }
1128 }
1129 #endif
1130 
1131 void Arguments::set_tiered_flags() {
1132   // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
1133   if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
1134     FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
1135   }
1136   if (CompilationPolicyChoice < 2) {
1137     vm_exit_during_initialization(
1138       "Incompatible compilation policy selected", NULL);
1139   }
1140   // Increase the code cache size - tiered compiles a lot more.
1141   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
1142     FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
1143   }
1144   if (!UseInterpreter) { // -Xcomp


1566     if (!UseSerialGC &&
1567         !UseConcMarkSweepGC &&
1568         !UseG1GC &&
1569         !UseParNewGC &&
1570         FLAG_IS_DEFAULT(UseParallelGC)) {
1571       if (should_auto_select_low_pause_collector()) {
1572         FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1573       } else {
1574         FLAG_SET_ERGO(bool, UseParallelGC, true);
1575       }
1576     }
1577   }
1578 #ifdef COMPILER2
1579   // Shared spaces work fine with other GCs but causes bytecode rewriting
1580   // to be disabled, which hurts interpreter performance and decreases
1581   // server performance.  When -server is specified, keep the default off
1582   // unless it is asked for.  Future work: either add bytecode rewriting
1583   // at link time, or rewrite bytecodes in non-shared methods.
1584   if (!DumpSharedSpaces && !RequireSharedSpaces &&
1585       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1586     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1587   }
1588 #endif
1589 
1590   set_conservative_max_heap_alignment();
1591 
1592 #ifndef ZERO
1593 #ifdef _LP64
1594   set_use_compressed_oops();
1595 
1596   // set_use_compressed_klass_ptrs() must be called after calling
1597   // set_use_compressed_oops().
1598   set_use_compressed_klass_ptrs();
1599 
1600   // Also checks that certain machines are slower with compressed oops
1601   // in vm_version initialization code.
1602 #endif // _LP64
1603 #endif // !ZERO
1604 }
1605 
1606 void Arguments::set_parallel_gc_flags() {


3287       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3288 #if !INCLUDE_MANAGEMENT
3289     } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
3290         jio_fprintf(defaultStream::error_stream(),
3291           "ManagementServer is not supported in this VM.\n");
3292         return JNI_ERR;
3293 #endif // INCLUDE_MANAGEMENT
3294     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3295       // Skip -XX:Flags= since that case has already been handled
3296       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3297         if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3298           return JNI_EINVAL;
3299         }
3300       }
3301     // Unknown option
3302     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3303       return JNI_ERR;
3304     }
3305   }
3306 
3307   // PrintSharedArchiveAndExit will turn on
3308   //   -Xshare:on
3309   //   -XX:+TraceClassPaths
3310   if (PrintSharedArchiveAndExit) {
3311     FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3312     FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
3313     FLAG_SET_CMDLINE(bool, TraceClassPaths, true);
3314   }
3315 
3316   // Change the default value for flags  which have different default values
3317   // when working with older JDKs.
3318 #ifdef LINUX
3319  if (JDK_Version::current().compare_major(6) <= 0 &&
3320       FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
3321     FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
3322   }
3323 #endif // LINUX
3324   fix_appclasspath();
3325   return JNI_OK;
3326 }
3327 
3328 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
3329 //
3330 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
3331 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
3332 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
3333 // path is treated as the current directory.
3334 //
3335 // This causes problems with CDS, which requires that all directories specified in the classpath
3336 // must be empty. In most cases, applications do NOT want to load classes from the current
3337 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
3338 // scripts compatible with CDS.
3339 void Arguments::fix_appclasspath() {
3340   if (IgnoreEmptyClassPaths) {
3341     const char separator = *os::path_separator();
3342     const char* src = _java_class_path->value();
3343 
3344     // skip over all the leading empty paths
3345     while (*src == separator) {
3346       src ++;
3347     }
3348 
3349     char* copy = AllocateHeap(strlen(src) + 1, mtInternal);
3350     strncpy(copy, src, strlen(src) + 1);
3351 
3352     // trim all trailing empty paths
3353     for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
3354       *tail = '\0';
3355     }
3356 
3357     char from[3] = {separator, separator, '\0'};
3358     char to  [2] = {separator, '\0'};
3359     while (StringUtils::replace_no_expand(copy, from, to) > 0) {
3360       // Keep replacing "::" -> ":" until we have no more "::" (non-windows)
3361       // Keep replacing ";;" -> ";" until we have no more ";;" (windows)
3362     }
3363 
3364     _java_class_path->set_value(copy);
3365     FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
3366   }
3367 
3368   if (!PrintSharedArchiveAndExit) {
3369     ClassLoader::trace_class_path("[classpath: ", _java_class_path->value());
3370   }
3371 }
3372 
3373 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3374   // This must be done after all -D arguments have been processed.
3375   scp_p->expand_endorsed();
3376 
3377   if (scp_assembly_required || scp_p->get_endorsed() != NULL) {
3378     // Assemble the bootclasspath elements into the final path.
3379     Arguments::set_sysclasspath(scp_p->combined_path());
3380   }
3381 
3382   // This must be done after all arguments have been processed.
3383   // java_compiler() true means set to "NONE" or empty.
3384   if (java_compiler() && !xdebug_mode()) {
3385     // For backwards compatibility, we switch to interpreted mode if
3386     // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3387     // not specified.
3388     set_mode_flags(_int);
3389   }
3390   if (CompileThreshold == 0) {
3391     set_mode_flags(_int);
3392   }


3523       }
3524     }
3525 
3526     return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
3527   }
3528   return JNI_OK;
3529 }
3530 
3531 void Arguments::set_shared_spaces_flags() {
3532   if (DumpSharedSpaces) {
3533     if (RequireSharedSpaces) {
3534       warning("cannot dump shared archive while using shared archive");
3535     }
3536     UseSharedSpaces = false;
3537 #ifdef _LP64
3538     if (!UseCompressedOops || !UseCompressedClassPointers) {
3539       vm_exit_during_initialization(
3540         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3541     }
3542   } else {

3543     if (!UseCompressedOops || !UseCompressedClassPointers) {
3544       no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3545     }
3546 #endif
3547   }
3548 }
3549 
3550 #if !INCLUDE_ALL_GCS
3551 static void force_serial_gc() {
3552   FLAG_SET_DEFAULT(UseSerialGC, true);
3553   FLAG_SET_DEFAULT(CMSIncrementalMode, false);  // special CMS suboption
3554   UNSUPPORTED_GC_OPTION(UseG1GC);
3555   UNSUPPORTED_GC_OPTION(UseParallelGC);
3556   UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3557   UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3558   UNSUPPORTED_GC_OPTION(UseParNewGC);
3559 }
3560 #endif // INCLUDE_ALL_GCS
3561 
3562 // Sharing support
3563 // Construct the path to the archive
3564 static char* get_shared_archive_path() {


3764     PrintGC = true;
3765   }
3766 
3767   // Set object alignment values.
3768   set_object_alignment();
3769 
3770 #if !INCLUDE_ALL_GCS
3771   force_serial_gc();
3772 #endif // INCLUDE_ALL_GCS
3773 #if !INCLUDE_CDS
3774   if (DumpSharedSpaces || RequireSharedSpaces) {
3775     jio_fprintf(defaultStream::error_stream(),
3776       "Shared spaces are not supported in this VM\n");
3777     return JNI_ERR;
3778   }
3779   if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3780     warning("Shared spaces are not supported in this VM");
3781     FLAG_SET_DEFAULT(UseSharedSpaces, false);
3782     FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3783   }
3784   no_shared_spaces("CDS Disabled");
3785 #endif // INCLUDE_CDS
3786 
3787   return JNI_OK;
3788 }
3789 
3790 jint Arguments::apply_ergo() {
3791 
3792   // Set flags based on ergonomics.
3793   set_ergonomics_flags();
3794 
3795   set_shared_spaces_flags();
3796 
3797   // Check the GC selections again.
3798   if (!check_gc_consistency()) {
3799     return JNI_EINVAL;
3800   }
3801 
3802   if (TieredCompilation) {
3803     set_tiered_flags();
3804   } else {