src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp
author gziemski
Wed, 03 Oct 2018 12:34:22 -0500
changeset 52004 22ca7ba0c50c
parent 50289 0195ee80e530
child 58015 dd84de796f2c
permissions -rw-r--r--
8204294: [REDO] - JVMFlag::printError missing ATTRIBUTE_PRINTF Summary: Added ATTRIBUTE_PRINTF to JVMFlag::printError Reviewed-by: kbarrett, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     1
/*
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     4
 *
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     8
 *
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    13
 * accompanied this code).
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    14
 *
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    18
 *
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    21
 * questions.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    22
 *
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    23
 */
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    24
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    25
#include "precompiled.hpp"
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    26
#include "gc/cms/jvmFlagConstraintsCMS.hpp"
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    27
#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    28
#include "gc/shared/cardTableRS.hpp"
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    29
#include "gc/shared/collectedHeap.hpp"
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    30
#include "gc/shared/genCollectedHeap.hpp"
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    31
#include "gc/shared/jvmFlagConstraintsGC.hpp"
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    32
#include "memory/universe.hpp"
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    33
#include "runtime/globals_extension.hpp"
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    34
#include "utilities/globalDefinitions.hpp"
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    35
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    36
static JVMFlag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    37
  // CMSWorkQueueDrainThreshold is verified to be less than max_juint
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    38
  if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    39
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    40
                        "ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold ("
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    41
                        UINTX_FORMAT ") is too large\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    42
                        threads, threshold);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    43
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    44
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    45
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    46
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    47
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    48
JVMFlag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    49
  // To avoid overflow at ParScanClosure::do_oop_work.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    50
  if (UseConcMarkSweepGC && (value > (max_jint / 10))) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    51
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    52
                        "ParallelGCThreads (" UINT32_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    53
                        "less than or equal to " UINT32_FORMAT " for CMS GC\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    54
                        value, (max_jint / 10));
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    55
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    56
  }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    57
  return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(value, CMSWorkQueueDrainThreshold, verbose);
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    58
}
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    59
JVMFlag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    60
  if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    61
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    62
                        "ParGCStridesPerThread (" UINTX_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    63
                        "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    64
                        value, ((uintx)max_jint / (uintx)ParallelGCThreads));
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    65
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    66
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    67
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    68
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    69
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    70
JVMFlag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    71
  if (UseConcMarkSweepGC) {
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    72
    // ParGCCardsPerStrideChunk should be compared with card table size.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    73
    size_t heap_size = Universe::heap()->reserved_region().word_size();
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    74
    CardTableRS* ct = GenCollectedHeap::heap()->rem_set();
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    75
    size_t card_table_size = ct->cards_required(heap_size) - 1; // Valid card table size
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    76
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    77
    if ((size_t)value > card_table_size) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    78
      JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    79
                          "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    80
                          "must be less than or equal to card table size (" SIZE_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    81
                          value, card_table_size);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    82
      return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    83
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    84
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    85
    // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    86
    // from CardTableRS::process_stride(). Note that ParGCStridesPerThread is already checked
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    87
    // not to make an overflow with ParallelGCThreads from its constraint function.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    88
    uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    89
    uintx ergo_max = max_uintx / n_strides;
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    90
    if ((uintx)value > ergo_max) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    91
      JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    92
                          "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    93
                          "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
    94
                          value, ergo_max);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    95
      return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    96
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    97
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
    98
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
    99
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   100
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   101
JVMFlag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   102
  JVMFlag::Error status = JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   103
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   104
  if (UseConcMarkSweepGC) {
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   105
    if (value > CMSOldPLABMax) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   106
      JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   107
                          "CMSOldPLABMin (" SIZE_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   108
                          "less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   109
                          value, CMSOldPLABMax);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   110
      return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   111
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   112
    status = MaxPLABSizeBounds("CMSOldPLABMin", value, verbose);
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   113
  }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   114
  return status;
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   115
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   116
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   117
JVMFlag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   118
  JVMFlag::Error status = JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   119
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   120
  if (UseConcMarkSweepGC) {
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   121
    status = MaxPLABSizeBounds("CMSOldPLABMax", value, verbose);
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   122
  }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   123
  return status;
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   124
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   125
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   126
static JVMFlag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   127
  if (UseConcMarkSweepGC) {
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49857
diff changeset
   128
    ConcurrentMarkSweepGeneration* cms = CMSHeap::heap()->old_gen();
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   129
    const size_t ergo_max = cms->cmsSpace()->max_flag_size_for_task_size();
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   130
    if (value > ergo_max) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   131
      JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   132
                          "%s (" SIZE_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   133
                          "less than or equal to ergonomic maximum (" SIZE_FORMAT ") "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   134
                          "which is based on the maximum size of the old generation of the Java heap\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   135
                          name, value, ergo_max);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   136
      return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   137
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   138
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   139
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   140
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   141
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   142
JVMFlag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   143
  JVMFlag::Error status = CMSReservedAreaConstraintFunc("CMSRescanMultiple", value, verbose);
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   144
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   145
  if (status == JVMFlag::SUCCESS && UseConcMarkSweepGC) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   146
    // CMSParRemarkTask::do_dirty_card_rescan_tasks requires CompactibleFreeListSpace::rescan_task_size()
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   147
    // to be aligned to CardTable::card_size * BitsPerWord.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   148
    // Note that rescan_task_size() will be aligned if CMSRescanMultiple is a multiple of 'HeapWordSize'
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   149
    // because rescan_task_size() is CardTable::card_size / HeapWordSize * BitsPerWord.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   150
    if (value % HeapWordSize != 0) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   151
      JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   152
                          "CMSRescanMultiple (" SIZE_FORMAT ") must be "
52004
22ca7ba0c50c 8204294: [REDO] - JVMFlag::printError missing ATTRIBUTE_PRINTF
gziemski
parents: 50289
diff changeset
   153
                          "a multiple of %d\n",
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   154
                          value, HeapWordSize);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   155
      status = JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   156
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   157
  }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   158
  return status;
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   159
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   160
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   161
JVMFlag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   162
  return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose);
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   163
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   164
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   165
JVMFlag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   166
  if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   167
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   168
                        "CMSPrecleanDenominator (" UINTX_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   169
                        "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   170
                        value, CMSPrecleanNumerator);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   171
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   172
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   173
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   174
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   175
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   176
JVMFlag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   177
  if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   178
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   179
                        "CMSPrecleanNumerator (" UINTX_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   180
                        "less than CMSPrecleanDenominator (" UINTX_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   181
                        value, CMSPrecleanDenominator);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   182
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   183
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   184
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   185
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   186
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   187
JVMFlag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   188
  if (UseConcMarkSweepGC) {
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49857
diff changeset
   189
    size_t max_capacity = CMSHeap::heap()->young_gen()->max_capacity();
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   190
    if (value > max_uintx - max_capacity) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   191
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   192
                        "CMSSamplingGrain (" UINTX_FORMAT ") must be "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   193
                        "less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   194
                        value, max_uintx - max_capacity);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   195
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   196
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   197
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   198
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   199
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   200
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   201
JVMFlag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   202
  if (UseConcMarkSweepGC) {
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   203
    return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(ParallelGCThreads, value, verbose);
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   204
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   205
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   206
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   207
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   208
JVMFlag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   209
  // Skip for current default value.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   210
  if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) {
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   211
    // CMSBitMapYieldQuantum should be compared with mark bitmap size.
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49857
diff changeset
   212
    ConcurrentMarkSweepGeneration* cms = CMSHeap::heap()->old_gen();
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   213
    size_t bitmap_size = cms->collector()->markBitMap()->sizeInWords();
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   214
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   215
    if (value > bitmap_size) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   216
      JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   217
                          "CMSBitMapYieldQuantum (" SIZE_FORMAT ") must "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   218
                          "be less than or equal to bitmap size (" SIZE_FORMAT ") "
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   219
                          "whose size corresponds to the size of old generation of the Java heap\n",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   220
                          value, bitmap_size);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   221
      return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   222
    }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   223
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   224
  return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   225
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   226
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   227
JVMFlag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   228
  if (value == 0) {
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   229
    JVMFlag::printError(verbose,
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   230
                        "OldPLABSize (" SIZE_FORMAT ") must be greater than 0",
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50033
diff changeset
   231
                        value);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49731
diff changeset
   232
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   233
  }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   234
  // For CMS, OldPLABSize is the number of free blocks of a given size that are used when
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   235
  // replenishing the local per-worker free list caches.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   236
  // For more details, please refer to Arguments::set_cms_and_parnew_gc_flags().
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   237
  return MaxPLABSizeBounds("OldPLABSize", value, verbose);
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents:
diff changeset
   238
}