< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




  49 #include "runtime/os.hpp"
  50 #include "runtime/vm_version.hpp"
  51 #include "services/management.hpp"
  52 #include "services/memTracker.hpp"
  53 #include "utilities/defaultStream.hpp"
  54 #include "utilities/macros.hpp"
  55 #include "utilities/stringUtils.hpp"
  56 #if INCLUDE_JVMCI
  57 #include "jvmci/jvmciRuntime.hpp"
  58 #endif
  59 #if INCLUDE_ALL_GCS
  60 #include "gc/cms/compactibleFreeListSpace.hpp"
  61 #include "gc/g1/g1CollectedHeap.inline.hpp"
  62 #include "gc/parallel/parallelScavengeHeap.hpp"
  63 #endif // INCLUDE_ALL_GCS
  64 
  65 // Note: This is a special bug reporting site for the JVM
  66 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  67 #define DEFAULT_JAVA_LAUNCHER  "generic"
  68 
  69 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  70 do {                                                                  \
  71   if (gc) {                                                           \
  72     if (FLAG_IS_CMDLINE(gc)) {                                        \
  73       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  74     }                                                                 \
  75     FLAG_SET_DEFAULT(gc, false);                                      \
  76   }                                                                   \
  77 } while(0)
  78 
  79 char*  Arguments::_jvm_flags_file               = NULL;
  80 char** Arguments::_jvm_flags_array              = NULL;
  81 int    Arguments::_num_jvm_flags                = 0;
  82 char** Arguments::_jvm_args_array               = NULL;
  83 int    Arguments::_num_jvm_args                 = 0;
  84 char*  Arguments::_java_command                 = NULL;
  85 SystemProperty* Arguments::_system_properties   = NULL;
  86 const char*  Arguments::_gc_log_filename        = NULL;
  87 bool   Arguments::_has_profile                  = false;
  88 size_t Arguments::_conservative_max_heap_alignment = 0;
  89 size_t Arguments::_min_heap_size                = 0;
  90 Arguments::Mode Arguments::_mode                = _mixed;
  91 bool   Arguments::_java_compiler                = false;
  92 bool   Arguments::_xdebug_mode                  = false;
  93 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
  94 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  95 int    Arguments::_sun_java_launcher_pid        = -1;
  96 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
  97 
  98 // These parameters are reset in method parse_vm_init_args()


1817 
1818 void Arguments::set_conservative_max_heap_alignment() {
1819   // The conservative maximum required alignment for the heap is the maximum of
1820   // the alignments imposed by several sources: any requirements from the heap
1821   // itself, the collector policy and the maximum page size we may run the VM
1822   // with.
1823   size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1824 #if INCLUDE_ALL_GCS
1825   if (UseParallelGC) {
1826     heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1827   } else if (UseG1GC) {
1828     heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1829   }
1830 #endif // INCLUDE_ALL_GCS
1831   _conservative_max_heap_alignment = MAX4(heap_alignment,
1832                                           (size_t)os::vm_allocation_granularity(),
1833                                           os::max_page_size(),
1834                                           CollectorPolicy::compute_heap_alignment());
1835 }
1836 








1837 void Arguments::select_gc_ergonomically() {

1838   if (os::is_server_class_machine()) {
1839     if (should_auto_select_low_pause_collector()) {
1840       FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1841     } else {
1842 #if defined(JAVASE_EMBEDDED)
1843       FLAG_SET_ERGO(bool, UseParallelGC, true);
1844 #else
1845       FLAG_SET_ERGO(bool, UseG1GC, true);
1846 #endif
1847     }
1848   } else {
1849     FLAG_SET_ERGO(bool, UseSerialGC, true);
1850   }








1851 }
1852 
1853 void Arguments::select_gc() {
1854   if (!gc_selected()) {
1855     select_gc_ergonomically();
1856     guarantee(gc_selected(), "No GC selected");


1857   }
1858 }
1859 
1860 void Arguments::set_ergonomics_flags() {
1861   select_gc();
1862 
1863 #if defined(COMPILER2) || INCLUDE_JVMCI
1864   // Shared spaces work fine with other GCs but causes bytecode rewriting
1865   // to be disabled, which hurts interpreter performance and decreases
1866   // server performance.  When -server is specified, keep the default off
1867   // unless it is asked for.  Future work: either add bytecode rewriting
1868   // at link time, or rewrite bytecodes in non-shared methods.
1869   if (!DumpSharedSpaces && !RequireSharedSpaces &&
1870       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1871     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1872   }
1873 #endif
1874 
1875   set_conservative_max_heap_alignment();
1876 


1961 
1962   // MarkStackSize will be set (if it hasn't been set by the user)
1963   // when concurrent marking is initialized.
1964   // Its value will be based upon the number of parallel marking threads.
1965   // But we do set the maximum mark stack size here.
1966   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1967     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1968   }
1969 
1970   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1971     // In G1, we want the default GC overhead goal to be higher than
1972     // it is for PS, or the heap might be expanded too aggressively.
1973     // We set it here to ~8%.
1974     FLAG_SET_DEFAULT(GCTimeRatio, 12);
1975   }
1976 
1977   log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1978   log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
1979 }
1980 
1981 #if !INCLUDE_ALL_GCS
1982 #ifdef ASSERT
1983 static bool verify_serial_gc_flags() {
1984   return (UseSerialGC &&
1985         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1986           UseParallelGC || UseParallelOldGC));
1987 }
1988 #endif // ASSERT
1989 #endif // INCLUDE_ALL_GCS
1990 
1991 void Arguments::set_gc_specific_flags() {
1992 #if INCLUDE_ALL_GCS
1993   // Set per-collector flags
1994   if (UseParallelGC || UseParallelOldGC) {
1995     set_parallel_gc_flags();
1996   } else if (UseConcMarkSweepGC) {
1997     set_cms_and_parnew_gc_flags();
1998   } else if (UseG1GC) {
1999     set_g1_gc_flags();
2000   }
2001   if (AssumeMP && !UseSerialGC) {
2002     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
2003       warning("If the number of processors is expected to increase from one, then"
2004               " you should configure the number of parallel GC threads appropriately"
2005               " using -XX:ParallelGCThreads=N");
2006     }
2007   }
2008   if (MinHeapFreeRatio == 100) {
2009     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
2010     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
2011   }
2012 #else // INCLUDE_ALL_GCS
2013   assert(verify_serial_gc_flags(), "SerialGC unset");
2014 #endif // INCLUDE_ALL_GCS
2015 }
2016 
2017 julong Arguments::limit_by_allocatable_memory(julong limit) {
2018   julong max_allocatable;
2019   julong result = limit;
2020   if (os::has_allocatable_memory_limit(&max_allocatable)) {
2021     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
2022   }
2023   return result;
2024 }
2025 
2026 // Use static initialization to get the default before parsing
2027 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
2028 
2029 void Arguments::set_heap_size() {
2030   const julong phys_mem =
2031     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
2032                             : (julong)MaxRAM;
2033 


3446   }
3447 
3448 #if !defined(COMPILER2) && !INCLUDE_JVMCI
3449   // Don't degrade server performance for footprint
3450   if (FLAG_IS_DEFAULT(UseLargePages) &&
3451       MaxHeapSize < LargePageHeapSizeThreshold) {
3452     // No need for large granularity pages w/small heaps.
3453     // Note that large pages are enabled/disabled for both the
3454     // Java heap and the code cache.
3455     FLAG_SET_DEFAULT(UseLargePages, false);
3456   }
3457 
3458 #elif defined(COMPILER2)
3459   if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
3460     FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
3461   }
3462 #endif
3463 
3464 #ifndef TIERED
3465   // Tiered compilation is undefined.
3466   UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3467 #endif
3468 
3469   // If we are running in a headless jre, force java.awt.headless property
3470   // to be true unless the property has already been set.
3471   // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3472   if (os::is_headless_jre()) {
3473     const char* headless = Arguments::get_property("java.awt.headless");
3474     if (headless == NULL) {
3475       const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3476       if (headless_env == NULL) {
3477         if (!add_property("java.awt.headless=true")) {
3478           return JNI_ENOMEM;
3479         }
3480       } else {
3481         char buffer[256];
3482         jio_snprintf(buffer, sizeof(buffer), "java.awt.headless=%s", headless_env);
3483         if (!add_property(buffer)) {
3484           return JNI_ENOMEM;
3485         }
3486       }


3767 
3768 void Arguments::set_shared_spaces_flags() {
3769   if (DumpSharedSpaces) {
3770     if (RequireSharedSpaces) {
3771       warning("Cannot dump shared archive while using shared archive");
3772     }
3773     UseSharedSpaces = false;
3774 #ifdef _LP64
3775     if (!UseCompressedOops || !UseCompressedClassPointers) {
3776       vm_exit_during_initialization(
3777         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3778     }
3779   } else {
3780     if (!UseCompressedOops || !UseCompressedClassPointers) {
3781       no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3782     }
3783 #endif
3784   }
3785 }
3786 
3787 #if !INCLUDE_ALL_GCS
3788 static void force_serial_gc() {
3789   FLAG_SET_DEFAULT(UseSerialGC, true);
3790   UNSUPPORTED_GC_OPTION(UseG1GC);
3791   UNSUPPORTED_GC_OPTION(UseParallelGC);
3792   UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3793   UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3794   UNSUPPORTED_GC_OPTION(UseParNewGC);
3795 }
3796 #endif // INCLUDE_ALL_GCS
3797 
3798 // Sharing support
3799 // Construct the path to the archive
3800 static char* get_shared_archive_path() {
3801   char *shared_archive_path;
3802   if (SharedArchiveFile == NULL) {
3803     char jvm_path[JVM_MAXPATHLEN];
3804     os::jvm_path(jvm_path, sizeof(jvm_path));
3805     char *end = strrchr(jvm_path, *os::file_separator());
3806     if (end != NULL) *end = '\0';
3807     size_t jvm_path_len = strlen(jvm_path);
3808     size_t file_sep_len = strlen(os::file_separator());
3809     const size_t len = jvm_path_len + file_sep_len + 20;
3810     shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
3811     if (shared_archive_path != NULL) {
3812       jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa",
3813         jvm_path, os::file_separator());
3814     }
3815   } else {
3816     shared_archive_path = os::strdup_check_oom(SharedArchiveFile, mtInternal);
3817   }


4141   // Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
4142   SharedArchivePath = get_shared_archive_path();
4143   if (SharedArchivePath == NULL) {
4144     return JNI_ENOMEM;
4145   }
4146 
4147   // Set up VerifySharedSpaces
4148   if (FLAG_IS_DEFAULT(VerifySharedSpaces) && SharedArchiveFile != NULL) {
4149     VerifySharedSpaces = true;
4150   }
4151 
4152   // Delay warning until here so that we've had a chance to process
4153   // the -XX:-PrintWarnings flag
4154   if (needs_hotspotrc_warning) {
4155     warning("%s file is present but has been ignored.  "
4156             "Run with -XX:Flags=%s to load the file.",
4157             hotspotrc, hotspotrc);
4158   }
4159 
4160 #if defined(_ALLBSD_SOURCE) || defined(AIX)  // UseLargePages is not yet supported on BSD and AIX.
4161   UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages");
4162 #endif
4163 
4164   ArgumentsExt::report_unsupported_options();
4165 
4166 #ifndef PRODUCT
4167   if (TraceBytecodesAt != 0) {
4168     TraceBytecodes = true;
4169   }
4170   if (CountCompiledCalls) {
4171     if (UseCounterDecay) {
4172       warning("UseCounterDecay disabled because CountCalls is set");
4173       UseCounterDecay = false;
4174     }
4175   }
4176 #endif // PRODUCT
4177 
4178   if (ScavengeRootsInCode == 0) {
4179     if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4180       warning("Forcing ScavengeRootsInCode non-zero");
4181     }
4182     ScavengeRootsInCode = 1;
4183   }
4184 
4185   if (!handle_deprecated_print_gc_flags()) {
4186     return JNI_EINVAL;
4187   }
4188 
4189   // Set object alignment values.
4190   set_object_alignment();
4191 
4192 #if !INCLUDE_ALL_GCS
4193   force_serial_gc();
4194 #endif // INCLUDE_ALL_GCS
4195 #if !INCLUDE_CDS
4196   if (DumpSharedSpaces || RequireSharedSpaces) {
4197     jio_fprintf(defaultStream::error_stream(),
4198       "Shared spaces are not supported in this VM\n");
4199     return JNI_ERR;
4200   }
4201   if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
4202     warning("Shared spaces are not supported in this VM");
4203     FLAG_SET_DEFAULT(UseSharedSpaces, false);
4204     FLAG_SET_DEFAULT(PrintSharedSpaces, false);
4205   }
4206   no_shared_spaces("CDS Disabled");
4207 #endif // INCLUDE_CDS
4208 
4209   return JNI_OK;
4210 }
4211 
4212 jint Arguments::apply_ergo() {
4213 
4214   // Set flags based on ergonomics.




  49 #include "runtime/os.hpp"
  50 #include "runtime/vm_version.hpp"
  51 #include "services/management.hpp"
  52 #include "services/memTracker.hpp"
  53 #include "utilities/defaultStream.hpp"
  54 #include "utilities/macros.hpp"
  55 #include "utilities/stringUtils.hpp"
  56 #if INCLUDE_JVMCI
  57 #include "jvmci/jvmciRuntime.hpp"
  58 #endif
  59 #if INCLUDE_ALL_GCS
  60 #include "gc/cms/compactibleFreeListSpace.hpp"
  61 #include "gc/g1/g1CollectedHeap.inline.hpp"
  62 #include "gc/parallel/parallelScavengeHeap.hpp"
  63 #endif // INCLUDE_ALL_GCS
  64 
  65 // Note: This is a special bug reporting site for the JVM
  66 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  67 #define DEFAULT_JAVA_LAUNCHER  "generic"
  68 










  69 char*  Arguments::_jvm_flags_file               = NULL;
  70 char** Arguments::_jvm_flags_array              = NULL;
  71 int    Arguments::_num_jvm_flags                = 0;
  72 char** Arguments::_jvm_args_array               = NULL;
  73 int    Arguments::_num_jvm_args                 = 0;
  74 char*  Arguments::_java_command                 = NULL;
  75 SystemProperty* Arguments::_system_properties   = NULL;
  76 const char*  Arguments::_gc_log_filename        = NULL;
  77 bool   Arguments::_has_profile                  = false;
  78 size_t Arguments::_conservative_max_heap_alignment = 0;
  79 size_t Arguments::_min_heap_size                = 0;
  80 Arguments::Mode Arguments::_mode                = _mixed;
  81 bool   Arguments::_java_compiler                = false;
  82 bool   Arguments::_xdebug_mode                  = false;
  83 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
  84 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  85 int    Arguments::_sun_java_launcher_pid        = -1;
  86 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
  87 
  88 // These parameters are reset in method parse_vm_init_args()


1807 
1808 void Arguments::set_conservative_max_heap_alignment() {
1809   // The conservative maximum required alignment for the heap is the maximum of
1810   // the alignments imposed by several sources: any requirements from the heap
1811   // itself, the collector policy and the maximum page size we may run the VM
1812   // with.
1813   size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1814 #if INCLUDE_ALL_GCS
1815   if (UseParallelGC) {
1816     heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1817   } else if (UseG1GC) {
1818     heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1819   }
1820 #endif // INCLUDE_ALL_GCS
1821   _conservative_max_heap_alignment = MAX4(heap_alignment,
1822                                           (size_t)os::vm_allocation_granularity(),
1823                                           os::max_page_size(),
1824                                           CollectorPolicy::compute_heap_alignment());
1825 }
1826 
1827 bool Arguments::gc_selected() {
1828 #if INCLUDE_ALL_GCS
1829   return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
1830 #else
1831   return UseSerialGC;
1832 #endif // INCLUDE_ALL_GCS
1833 }
1834 
1835 void Arguments::select_gc_ergonomically() {
1836 #if INCLUDE_ALL_GCS
1837   if (os::is_server_class_machine()) {
1838     if (should_auto_select_low_pause_collector()) {
1839       FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
1840     } else {
1841 #if defined(JAVASE_EMBEDDED)
1842       FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
1843 #else
1844       FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
1845 #endif
1846     }
1847   } else {
1848     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
1849   }
1850 #else
1851   UNSUPPORTED_OPTION(UseG1GC);
1852   UNSUPPORTED_OPTION(UseParallelGC);
1853   UNSUPPORTED_OPTION(UseParallelOldGC);
1854   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
1855   UNSUPPORTED_OPTION(UseParNewGC);
1856   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
1857 #endif // INCLUDE_ALL_GCS
1858 }
1859 
1860 void Arguments::select_gc() {
1861   if (!gc_selected()) {
1862     select_gc_ergonomically();
1863     if (!gc_selected()) {
1864       vm_exit_during_initialization("Garbage collector not selected (default collector explicitly disabled)", NULL);
1865     }
1866   }
1867 }
1868 
1869 void Arguments::set_ergonomics_flags() {
1870   select_gc();
1871 
1872 #if defined(COMPILER2) || INCLUDE_JVMCI
1873   // Shared spaces work fine with other GCs but causes bytecode rewriting
1874   // to be disabled, which hurts interpreter performance and decreases
1875   // server performance.  When -server is specified, keep the default off
1876   // unless it is asked for.  Future work: either add bytecode rewriting
1877   // at link time, or rewrite bytecodes in non-shared methods.
1878   if (!DumpSharedSpaces && !RequireSharedSpaces &&
1879       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1880     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1881   }
1882 #endif
1883 
1884   set_conservative_max_heap_alignment();
1885 


1970 
1971   // MarkStackSize will be set (if it hasn't been set by the user)
1972   // when concurrent marking is initialized.
1973   // Its value will be based upon the number of parallel marking threads.
1974   // But we do set the maximum mark stack size here.
1975   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1976     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1977   }
1978 
1979   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1980     // In G1, we want the default GC overhead goal to be higher than
1981     // it is for PS, or the heap might be expanded too aggressively.
1982     // We set it here to ~8%.
1983     FLAG_SET_DEFAULT(GCTimeRatio, 12);
1984   }
1985 
1986   log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1987   log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
1988 }
1989 










1990 void Arguments::set_gc_specific_flags() {
1991 #if INCLUDE_ALL_GCS
1992   // Set per-collector flags
1993   if (UseParallelGC || UseParallelOldGC) {
1994     set_parallel_gc_flags();
1995   } else if (UseConcMarkSweepGC) {
1996     set_cms_and_parnew_gc_flags();
1997   } else if (UseG1GC) {
1998     set_g1_gc_flags();
1999   }
2000   if (AssumeMP && !UseSerialGC) {
2001     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
2002       warning("If the number of processors is expected to increase from one, then"
2003               " you should configure the number of parallel GC threads appropriately"
2004               " using -XX:ParallelGCThreads=N");
2005     }
2006   }
2007   if (MinHeapFreeRatio == 100) {
2008     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
2009     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
2010   }


2011 #endif // INCLUDE_ALL_GCS
2012 }
2013 
2014 julong Arguments::limit_by_allocatable_memory(julong limit) {
2015   julong max_allocatable;
2016   julong result = limit;
2017   if (os::has_allocatable_memory_limit(&max_allocatable)) {
2018     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
2019   }
2020   return result;
2021 }
2022 
2023 // Use static initialization to get the default before parsing
2024 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
2025 
2026 void Arguments::set_heap_size() {
2027   const julong phys_mem =
2028     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
2029                             : (julong)MaxRAM;
2030 


3443   }
3444 
3445 #if !defined(COMPILER2) && !INCLUDE_JVMCI
3446   // Don't degrade server performance for footprint
3447   if (FLAG_IS_DEFAULT(UseLargePages) &&
3448       MaxHeapSize < LargePageHeapSizeThreshold) {
3449     // No need for large granularity pages w/small heaps.
3450     // Note that large pages are enabled/disabled for both the
3451     // Java heap and the code cache.
3452     FLAG_SET_DEFAULT(UseLargePages, false);
3453   }
3454 
3455 #elif defined(COMPILER2)
3456   if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
3457     FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
3458   }
3459 #endif
3460 
3461 #ifndef TIERED
3462   // Tiered compilation is undefined.
3463   UNSUPPORTED_OPTION(TieredCompilation);
3464 #endif
3465 
3466   // If we are running in a headless jre, force java.awt.headless property
3467   // to be true unless the property has already been set.
3468   // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3469   if (os::is_headless_jre()) {
3470     const char* headless = Arguments::get_property("java.awt.headless");
3471     if (headless == NULL) {
3472       const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3473       if (headless_env == NULL) {
3474         if (!add_property("java.awt.headless=true")) {
3475           return JNI_ENOMEM;
3476         }
3477       } else {
3478         char buffer[256];
3479         jio_snprintf(buffer, sizeof(buffer), "java.awt.headless=%s", headless_env);
3480         if (!add_property(buffer)) {
3481           return JNI_ENOMEM;
3482         }
3483       }


3764 
3765 void Arguments::set_shared_spaces_flags() {
3766   if (DumpSharedSpaces) {
3767     if (RequireSharedSpaces) {
3768       warning("Cannot dump shared archive while using shared archive");
3769     }
3770     UseSharedSpaces = false;
3771 #ifdef _LP64
3772     if (!UseCompressedOops || !UseCompressedClassPointers) {
3773       vm_exit_during_initialization(
3774         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3775     }
3776   } else {
3777     if (!UseCompressedOops || !UseCompressedClassPointers) {
3778       no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3779     }
3780 #endif
3781   }
3782 }
3783 











3784 // Sharing support
3785 // Construct the path to the archive
3786 static char* get_shared_archive_path() {
3787   char *shared_archive_path;
3788   if (SharedArchiveFile == NULL) {
3789     char jvm_path[JVM_MAXPATHLEN];
3790     os::jvm_path(jvm_path, sizeof(jvm_path));
3791     char *end = strrchr(jvm_path, *os::file_separator());
3792     if (end != NULL) *end = '\0';
3793     size_t jvm_path_len = strlen(jvm_path);
3794     size_t file_sep_len = strlen(os::file_separator());
3795     const size_t len = jvm_path_len + file_sep_len + 20;
3796     shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
3797     if (shared_archive_path != NULL) {
3798       jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa",
3799         jvm_path, os::file_separator());
3800     }
3801   } else {
3802     shared_archive_path = os::strdup_check_oom(SharedArchiveFile, mtInternal);
3803   }


4127   // Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
4128   SharedArchivePath = get_shared_archive_path();
4129   if (SharedArchivePath == NULL) {
4130     return JNI_ENOMEM;
4131   }
4132 
4133   // Set up VerifySharedSpaces
4134   if (FLAG_IS_DEFAULT(VerifySharedSpaces) && SharedArchiveFile != NULL) {
4135     VerifySharedSpaces = true;
4136   }
4137 
4138   // Delay warning until here so that we've had a chance to process
4139   // the -XX:-PrintWarnings flag
4140   if (needs_hotspotrc_warning) {
4141     warning("%s file is present but has been ignored.  "
4142             "Run with -XX:Flags=%s to load the file.",
4143             hotspotrc, hotspotrc);
4144   }
4145 
4146 #if defined(_ALLBSD_SOURCE) || defined(AIX)  // UseLargePages is not yet supported on BSD and AIX.
4147   UNSUPPORTED_OPTION(UseLargePages);
4148 #endif
4149 
4150   ArgumentsExt::report_unsupported_options();
4151 
4152 #ifndef PRODUCT
4153   if (TraceBytecodesAt != 0) {
4154     TraceBytecodes = true;
4155   }
4156   if (CountCompiledCalls) {
4157     if (UseCounterDecay) {
4158       warning("UseCounterDecay disabled because CountCalls is set");
4159       UseCounterDecay = false;
4160     }
4161   }
4162 #endif // PRODUCT
4163 
4164   if (ScavengeRootsInCode == 0) {
4165     if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4166       warning("Forcing ScavengeRootsInCode non-zero");
4167     }
4168     ScavengeRootsInCode = 1;
4169   }
4170 
4171   if (!handle_deprecated_print_gc_flags()) {
4172     return JNI_EINVAL;
4173   }
4174 
4175   // Set object alignment values.
4176   set_object_alignment();
4177 



4178 #if !INCLUDE_CDS
4179   if (DumpSharedSpaces || RequireSharedSpaces) {
4180     jio_fprintf(defaultStream::error_stream(),
4181       "Shared spaces are not supported in this VM\n");
4182     return JNI_ERR;
4183   }
4184   if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
4185     warning("Shared spaces are not supported in this VM");
4186     FLAG_SET_DEFAULT(UseSharedSpaces, false);
4187     FLAG_SET_DEFAULT(PrintSharedSpaces, false);
4188   }
4189   no_shared_spaces("CDS Disabled");
4190 #endif // INCLUDE_CDS
4191 
4192   return JNI_OK;
4193 }
4194 
4195 jint Arguments::apply_ergo() {
4196 
4197   // Set flags based on ergonomics.


< prev index next >