src/hotspot/share/gc/shared/gcArguments.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54983 81becad91321
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
     3  * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     7  * under the terms of the GNU General Public License version 2 only, as
    30 #include "runtime/arguments.hpp"
    30 #include "runtime/arguments.hpp"
    31 #include "runtime/globals.hpp"
    31 #include "runtime/globals.hpp"
    32 #include "runtime/globals_extension.hpp"
    32 #include "runtime/globals_extension.hpp"
    33 #include "utilities/defaultStream.hpp"
    33 #include "utilities/defaultStream.hpp"
    34 #include "utilities/macros.hpp"
    34 #include "utilities/macros.hpp"
    35 
       
    36 size_t MinHeapSize = 0;
       
    37 
    35 
    38 size_t HeapAlignment = 0;
    36 size_t HeapAlignment = 0;
    39 size_t SpaceAlignment = 0;
    37 size_t SpaceAlignment = 0;
    40 
    38 
    41 void GCArguments::initialize() {
    39 void GCArguments::initialize() {
   120 
   118 
   121 void GCArguments::assert_size_info() {
   119 void GCArguments::assert_size_info() {
   122   assert(MaxHeapSize >= MinHeapSize, "Ergonomics decided on incompatible minimum and maximum heap sizes");
   120   assert(MaxHeapSize >= MinHeapSize, "Ergonomics decided on incompatible minimum and maximum heap sizes");
   123   assert(InitialHeapSize >= MinHeapSize, "Ergonomics decided on incompatible initial and minimum heap sizes");
   121   assert(InitialHeapSize >= MinHeapSize, "Ergonomics decided on incompatible initial and minimum heap sizes");
   124   assert(MaxHeapSize >= InitialHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes");
   122   assert(MaxHeapSize >= InitialHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes");
   125   assert(MaxHeapSize % HeapAlignment == 0, "MinHeapSize alignment");
   123   assert(MinHeapSize % HeapAlignment == 0, "MinHeapSize alignment");
   126   assert(InitialHeapSize % HeapAlignment == 0, "InitialHeapSize alignment");
   124   assert(InitialHeapSize % HeapAlignment == 0, "InitialHeapSize alignment");
   127   assert(MaxHeapSize % HeapAlignment == 0, "MaxHeapSize alignment");
   125   assert(MaxHeapSize % HeapAlignment == 0, "MaxHeapSize alignment");
   128 }
   126 }
   129 #endif // ASSERT
   127 #endif // ASSERT
   130 
   128 
   147 
   145 
   148   if (FLAG_IS_CMDLINE(MaxHeapSize)) {
   146   if (FLAG_IS_CMDLINE(MaxHeapSize)) {
   149     if (FLAG_IS_CMDLINE(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
   147     if (FLAG_IS_CMDLINE(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
   150       vm_exit_during_initialization("Initial heap size set to a larger value than the maximum heap size");
   148       vm_exit_during_initialization("Initial heap size set to a larger value than the maximum heap size");
   151     }
   149     }
   152     if (MinHeapSize != 0 && MaxHeapSize < MinHeapSize) {
   150     if (FLAG_IS_CMDLINE(MinHeapSize) && MaxHeapSize < MinHeapSize) {
   153       vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified");
   151       vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified");
   154     }
   152     }
   155   }
   153   }
   156 
   154 
   157   // Check heap parameter properties
   155   // Check heap parameter properties
   164   if (MinHeapSize < M) {
   162   if (MinHeapSize < M) {
   165     vm_exit_during_initialization("Too small minimum heap");
   163     vm_exit_during_initialization("Too small minimum heap");
   166   }
   164   }
   167 
   165 
   168   // User inputs from -Xmx and -Xms must be aligned
   166   // User inputs from -Xmx and -Xms must be aligned
   169   MinHeapSize = align_up(MinHeapSize, HeapAlignment);
       
   170   size_t aligned_initial_heap_size = align_up(InitialHeapSize, HeapAlignment);
       
   171   size_t aligned_max_heap_size = align_up(MaxHeapSize, HeapAlignment);
       
   172 
       
   173   // Write back to flags if the values changed
   167   // Write back to flags if the values changed
   174   if (aligned_initial_heap_size != InitialHeapSize) {
   168   if (!is_aligned(MinHeapSize, HeapAlignment)) {
   175     FLAG_SET_ERGO(InitialHeapSize, aligned_initial_heap_size);
   169     FLAG_SET_ERGO(MinHeapSize, align_up(MinHeapSize, HeapAlignment));
   176   }
   170   }
   177   if (aligned_max_heap_size != MaxHeapSize) {
   171   if (!is_aligned(InitialHeapSize, HeapAlignment)) {
   178     FLAG_SET_ERGO(MaxHeapSize, aligned_max_heap_size);
   172     FLAG_SET_ERGO(InitialHeapSize, align_up(InitialHeapSize, HeapAlignment));
       
   173   }
       
   174   if (!is_aligned(MaxHeapSize, HeapAlignment)) {
       
   175     FLAG_SET_ERGO(MaxHeapSize, align_up(MaxHeapSize, HeapAlignment));
   179   }
   176   }
   180 
   177 
   181   if (FLAG_IS_CMDLINE(InitialHeapSize) && MinHeapSize != 0 &&
   178   if (FLAG_IS_CMDLINE(InitialHeapSize) && FLAG_IS_CMDLINE(MinHeapSize) &&
   182       InitialHeapSize < MinHeapSize) {
   179       InitialHeapSize < MinHeapSize) {
   183     vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified");
   180     vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified");
   184   }
   181   }
       
   182 
   185   if (!FLAG_IS_DEFAULT(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
   183   if (!FLAG_IS_DEFAULT(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
   186     FLAG_SET_ERGO(MaxHeapSize, InitialHeapSize);
   184     FLAG_SET_ERGO(MaxHeapSize, InitialHeapSize);
   187   } else if (!FLAG_IS_DEFAULT(MaxHeapSize) && InitialHeapSize > MaxHeapSize) {
   185   } else if (!FLAG_IS_DEFAULT(MaxHeapSize) && InitialHeapSize > MaxHeapSize) {
   188     FLAG_SET_ERGO(InitialHeapSize, MaxHeapSize);
   186     FLAG_SET_ERGO(InitialHeapSize, MaxHeapSize);
   189     if (InitialHeapSize < MinHeapSize) {
   187     if (InitialHeapSize < MinHeapSize) {
   190       MinHeapSize = InitialHeapSize;
   188       FLAG_SET_ERGO(MinHeapSize, InitialHeapSize);
   191     }
   189     }
       
   190   }
       
   191 
       
   192   if (FLAG_IS_DEFAULT(SoftMaxHeapSize)) {
       
   193     FLAG_SET_ERGO(SoftMaxHeapSize, MaxHeapSize);
   192   }
   194   }
   193 
   195 
   194   FLAG_SET_ERGO(MinHeapDeltaBytes, align_up(MinHeapDeltaBytes, SpaceAlignment));
   196   FLAG_SET_ERGO(MinHeapDeltaBytes, align_up(MinHeapDeltaBytes, SpaceAlignment));
   195 
   197 
   196   DEBUG_ONLY(assert_flags();)
   198   DEBUG_ONLY(assert_flags();)