< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   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  *


 302   }
 303   return JVMFlag::SUCCESS;
 304 }
 305 
 306 static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
 307   size_t heap_alignment;
 308 
 309 #if INCLUDE_G1GC
 310   if (UseG1GC) {
 311     // For G1 GC, we don't know until G1CollectedHeap is created.
 312     heap_alignment = MaxSizeForHeapAlignmentG1();
 313   } else
 314 #endif
 315   {
 316     heap_alignment = GCArguments::compute_heap_alignment();
 317   }
 318 
 319   return MaxSizeForAlignment(name, value, heap_alignment, verbose);
 320 }
 321 
 322 JVMFlag::Error MinHeapSizeConstraintFunc(size_t value, bool verbose) {
 323   return MaxSizeForHeapAlignment("MinHeapSize", value, verbose);
 324 }
 325 
 326 JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
 327   return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
 328 }
 329 
 330 JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
 331   JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
 332 
 333   if (status == JVMFlag::SUCCESS) {
 334     status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
 335   }
 336   return status;
 337 }
 338 
 339 JVMFlag::Error SoftMaxHeapSizeConstraintFunc(size_t value, bool verbose) {
 340   if (value > MaxHeapSize) {
 341     JVMFlag::printError(verbose, "SoftMaxHeapSize must be less than or equal to the maximum heap size\n");
 342     return JVMFlag::VIOLATES_CONSTRAINT;
 343   }
 344 
 345   return JVMFlag::SUCCESS;
 346 }
 347 
 348 JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
 349   // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value.
 350   // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx.
 351   if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) {
 352     JVMFlag::printError(verbose,
 353                         "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. "
 354                         "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n",
 355                         value, MaxHeapSize, max_uintx);
 356     return JVMFlag::VIOLATES_CONSTRAINT;
 357   }
 358 
 359   return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
 360 }
 361 
 362 JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
 363 #if INCLUDE_G1GC
 364   JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
 365   if (status != JVMFlag::SUCCESS) {


   1 /*
   2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   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  *


 302   }
 303   return JVMFlag::SUCCESS;
 304 }
 305 
 306 static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
 307   size_t heap_alignment;
 308 
 309 #if INCLUDE_G1GC
 310   if (UseG1GC) {
 311     // For G1 GC, we don't know until G1CollectedHeap is created.
 312     heap_alignment = MaxSizeForHeapAlignmentG1();
 313   } else
 314 #endif
 315   {
 316     heap_alignment = GCArguments::compute_heap_alignment();
 317   }
 318 
 319   return MaxSizeForAlignment(name, value, heap_alignment, verbose);
 320 }
 321 




 322 JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
 323   return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
 324 }
 325 
 326 JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
 327   JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
 328 
 329   if (status == JVMFlag::SUCCESS) {
 330     status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
 331   }
 332   return status;









 333 }
 334 
 335 JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
 336   // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value.
 337   // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx.
 338   if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) {
 339     JVMFlag::printError(verbose,
 340                         "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. "
 341                         "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n",
 342                         value, MaxHeapSize, max_uintx);
 343     return JVMFlag::VIOLATES_CONSTRAINT;
 344   }
 345 
 346   return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
 347 }
 348 
 349 JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
 350 #if INCLUDE_G1GC
 351   JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
 352   if (status != JVMFlag::SUCCESS) {


< prev index next >