src/hotspot/share/runtime/arguments.cpp
changeset 54678 93f09ca4a7f8
parent 54669 ad45b3802d4e
child 54786 ebf733a324d4
equal deleted inserted replaced
54677:beca9f8524c1 54678:93f09ca4a7f8
    27 #include "classfile/classLoader.hpp"
    27 #include "classfile/classLoader.hpp"
    28 #include "classfile/javaAssertions.hpp"
    28 #include "classfile/javaAssertions.hpp"
    29 #include "classfile/moduleEntry.hpp"
    29 #include "classfile/moduleEntry.hpp"
    30 #include "classfile/stringTable.hpp"
    30 #include "classfile/stringTable.hpp"
    31 #include "classfile/symbolTable.hpp"
    31 #include "classfile/symbolTable.hpp"
    32 #include "gc/shared/collectorPolicy.hpp"
       
    33 #include "gc/shared/gcArguments.hpp"
    32 #include "gc/shared/gcArguments.hpp"
    34 #include "gc/shared/gcConfig.hpp"
    33 #include "gc/shared/gcConfig.hpp"
    35 #include "logging/log.hpp"
    34 #include "logging/log.hpp"
    36 #include "logging/logConfiguration.hpp"
    35 #include "logging/logConfiguration.hpp"
    37 #include "logging/logStream.hpp"
    36 #include "logging/logStream.hpp"
    76 int    Arguments::_num_jvm_args                 = 0;
    75 int    Arguments::_num_jvm_args                 = 0;
    77 char*  Arguments::_java_command                 = NULL;
    76 char*  Arguments::_java_command                 = NULL;
    78 SystemProperty* Arguments::_system_properties   = NULL;
    77 SystemProperty* Arguments::_system_properties   = NULL;
    79 const char*  Arguments::_gc_log_filename        = NULL;
    78 const char*  Arguments::_gc_log_filename        = NULL;
    80 size_t Arguments::_conservative_max_heap_alignment = 0;
    79 size_t Arguments::_conservative_max_heap_alignment = 0;
    81 size_t Arguments::_min_heap_size                = 0;
       
    82 Arguments::Mode Arguments::_mode                = _mixed;
    80 Arguments::Mode Arguments::_mode                = _mixed;
    83 bool   Arguments::_java_compiler                = false;
    81 bool   Arguments::_java_compiler                = false;
    84 bool   Arguments::_xdebug_mode                  = false;
    82 bool   Arguments::_xdebug_mode                  = false;
    85 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
    83 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
    86 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
    84 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  1671 }
  1669 }
  1672 
  1670 
  1673 void Arguments::set_conservative_max_heap_alignment() {
  1671 void Arguments::set_conservative_max_heap_alignment() {
  1674   // The conservative maximum required alignment for the heap is the maximum of
  1672   // The conservative maximum required alignment for the heap is the maximum of
  1675   // the alignments imposed by several sources: any requirements from the heap
  1673   // the alignments imposed by several sources: any requirements from the heap
  1676   // itself, the collector policy and the maximum page size we may run the VM
  1674   // itself and the maximum page size we may run the VM with.
  1677   // with.
       
  1678   size_t heap_alignment = GCConfig::arguments()->conservative_max_heap_alignment();
  1675   size_t heap_alignment = GCConfig::arguments()->conservative_max_heap_alignment();
  1679   _conservative_max_heap_alignment = MAX4(heap_alignment,
  1676   _conservative_max_heap_alignment = MAX4(heap_alignment,
  1680                                           (size_t)os::vm_allocation_granularity(),
  1677                                           (size_t)os::vm_allocation_granularity(),
  1681                                           os::max_page_size(),
  1678                                           os::max_page_size(),
  1682                                           CollectorPolicy::compute_heap_alignment());
  1679                                           GCArguments::compute_heap_alignment());
  1683 }
  1680 }
  1684 
  1681 
  1685 jint Arguments::set_ergonomics_flags() {
  1682 jint Arguments::set_ergonomics_flags() {
  1686   GCConfig::initialize();
  1683   GCConfig::initialize();
  1687 
  1684 
  1790     FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
  1787     FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
  1791   }
  1788   }
  1792 
  1789 
  1793   // If the minimum or initial heap_size have not been set or requested to be set
  1790   // If the minimum or initial heap_size have not been set or requested to be set
  1794   // ergonomically, set them accordingly.
  1791   // ergonomically, set them accordingly.
  1795   if (InitialHeapSize == 0 || min_heap_size() == 0) {
  1792   if (InitialHeapSize == 0 || MinHeapSize == 0) {
  1796     julong reasonable_minimum = (julong)(OldSize + NewSize);
  1793     julong reasonable_minimum = (julong)(OldSize + NewSize);
  1797 
  1794 
  1798     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
  1795     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
  1799 
  1796 
  1800     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
  1797     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
  1801 
  1798 
  1802     if (InitialHeapSize == 0) {
  1799     if (InitialHeapSize == 0) {
  1803       julong reasonable_initial = (julong)((phys_mem * InitialRAMPercentage) / 100);
  1800       julong reasonable_initial = (julong)((phys_mem * InitialRAMPercentage) / 100);
  1804 
  1801 
  1805       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
  1802       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)MinHeapSize);
  1806       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
  1803       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
  1807 
  1804 
  1808       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
  1805       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
  1809 
  1806 
  1810       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
  1807       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
  1811       FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
  1808       FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
  1812     }
  1809     }
  1813     // If the minimum heap size has not been set (via -Xms),
  1810     // If the minimum heap size has not been set (via -Xms),
  1814     // synchronize with InitialHeapSize to avoid errors with the default value.
  1811     // synchronize with InitialHeapSize to avoid errors with the default value.
  1815     if (min_heap_size() == 0) {
  1812     if (MinHeapSize == 0) {
  1816       set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
  1813       MinHeapSize = MIN2((size_t)reasonable_minimum, InitialHeapSize);
  1817       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, min_heap_size());
  1814       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, MinHeapSize);
  1818     }
  1815     }
  1819   }
  1816   }
  1820 }
  1817 }
  1821 
  1818 
  1822 // This option inspects the machine and attempts to set various
  1819 // This option inspects the machine and attempts to set various
  1854     }
  1851     }
  1855     if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
  1852     if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
  1856       return JNI_EINVAL;
  1853       return JNI_EINVAL;
  1857     }
  1854     }
  1858     // Currently the minimum size and the initial heap sizes are the same.
  1855     // Currently the minimum size and the initial heap sizes are the same.
  1859     set_min_heap_size(initHeapSize);
  1856     MinHeapSize = initHeapSize;
  1860   }
  1857   }
  1861   if (FLAG_IS_DEFAULT(NewSize)) {
  1858   if (FLAG_IS_DEFAULT(NewSize)) {
  1862     // Make the young generation 3/8ths of the total heap.
  1859     // Make the young generation 3/8ths of the total heap.
  1863     if (FLAG_SET_CMDLINE(size_t, NewSize,
  1860     if (FLAG_SET_CMDLINE(size_t, NewSize,
  1864             ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != JVMFlag::SUCCESS) {
  1861             ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != JVMFlag::SUCCESS) {
  2554         jio_fprintf(defaultStream::error_stream(),
  2551         jio_fprintf(defaultStream::error_stream(),
  2555                     "Invalid initial heap size: %s\n", option->optionString);
  2552                     "Invalid initial heap size: %s\n", option->optionString);
  2556         describe_range_error(errcode);
  2553         describe_range_error(errcode);
  2557         return JNI_EINVAL;
  2554         return JNI_EINVAL;
  2558       }
  2555       }
  2559       set_min_heap_size((size_t)long_initial_heap_size);
  2556       MinHeapSize = (size_t)long_initial_heap_size;
  2560       // Currently the minimum size and the initial heap sizes are the same.
  2557       // Currently the minimum size and the initial heap sizes are the same.
  2561       // Can be overridden with -XX:InitialHeapSize.
  2558       // Can be overridden with -XX:InitialHeapSize.
  2562       if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size) != JVMFlag::SUCCESS) {
  2559       if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size) != JVMFlag::SUCCESS) {
  2563         return JNI_EINVAL;
  2560         return JNI_EINVAL;
  2564       }
  2561       }