src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.cpp
branchhttp-client-branch
changeset 56497 598e0c5b6f8c
parent 56496 a3937ca907f1
parent 49911 358be4680d12
child 56498 0908e8e61f9c
equal deleted inserted replaced
56496:a3937ca907f1 56497:598e0c5b6f8c
     1 /*
       
     2  * Copyright (c) 2015, 2017, 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  *
       
    23  */
       
    24 
       
    25 #include "precompiled.hpp"
       
    26 #include "runtime/arguments.hpp"
       
    27 #include "runtime/commandLineFlagConstraintsRuntime.hpp"
       
    28 #include "runtime/commandLineFlagRangeList.hpp"
       
    29 #include "runtime/globals.hpp"
       
    30 #include "runtime/safepointMechanism.hpp"
       
    31 #include "runtime/task.hpp"
       
    32 #include "utilities/defaultStream.hpp"
       
    33 
       
    34 Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) {
       
    35   if (!is_power_of_2(value)) {
       
    36     CommandLineError::print(verbose,
       
    37                             "ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
       
    38                             "power of 2\n",
       
    39                             value);
       
    40     return Flag::VIOLATES_CONSTRAINT;
       
    41   }
       
    42   // In case page size is very small.
       
    43   if (value >= (intx)os::vm_page_size()) {
       
    44     CommandLineError::print(verbose,
       
    45                             "ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
       
    46                             "less than page size (" INTX_FORMAT ")\n",
       
    47                             value, (intx)os::vm_page_size());
       
    48     return Flag::VIOLATES_CONSTRAINT;
       
    49   }
       
    50   return Flag::SUCCESS;
       
    51 }
       
    52 
       
    53 // Need to enforce the padding not to break the existing field alignments.
       
    54 // It is sufficient to check against the largest type size.
       
    55 Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) {
       
    56   if ((value % BytesPerLong) != 0) {
       
    57     CommandLineError::print(verbose,
       
    58                             "ContendedPaddingWidth (" INTX_FORMAT ") must be "
       
    59                             "a multiple of %d\n",
       
    60                             value, BytesPerLong);
       
    61     return Flag::VIOLATES_CONSTRAINT;
       
    62   } else {
       
    63     return Flag::SUCCESS;
       
    64   }
       
    65 }
       
    66 
       
    67 Flag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) {
       
    68   if (value > BiasedLockingBulkRevokeThreshold) {
       
    69     CommandLineError::print(verbose,
       
    70                             "BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be "
       
    71                             "less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n",
       
    72                             value, BiasedLockingBulkRevokeThreshold);
       
    73     return Flag::VIOLATES_CONSTRAINT;
       
    74   } else {
       
    75     return Flag::SUCCESS;
       
    76   }
       
    77 }
       
    78 
       
    79 Flag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) {
       
    80   if ((value % PeriodicTask::interval_gran) != 0) {
       
    81     CommandLineError::print(verbose,
       
    82                             "BiasedLockingStartupDelay (" INTX_FORMAT ") must be "
       
    83                             "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n",
       
    84                             value, PeriodicTask::interval_gran);
       
    85     return Flag::VIOLATES_CONSTRAINT;
       
    86   } else {
       
    87     return Flag::SUCCESS;
       
    88   }
       
    89 }
       
    90 
       
    91 Flag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) {
       
    92   if (value < BiasedLockingBulkRebiasThreshold) {
       
    93     CommandLineError::print(verbose,
       
    94                             "BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be "
       
    95                             "greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n",
       
    96                             value, BiasedLockingBulkRebiasThreshold);
       
    97     return Flag::VIOLATES_CONSTRAINT;
       
    98   } else if ((double)value/(double)BiasedLockingDecayTime > 0.1) {
       
    99     CommandLineError::print(verbose,
       
   100                             "The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")"
       
   101                             " to BiasedLockingDecayTime (" INTX_FORMAT ") must be "
       
   102                             "less than or equal to 0.1\n",
       
   103                             value, BiasedLockingBulkRebiasThreshold);
       
   104     return Flag::VIOLATES_CONSTRAINT;
       
   105   } else {
       
   106     return Flag::SUCCESS;
       
   107   }
       
   108 }
       
   109 
       
   110 Flag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) {
       
   111   if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) {
       
   112     CommandLineError::print(verbose,
       
   113                             "The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")"
       
   114                             " to BiasedLockingDecayTime (" INTX_FORMAT ") must be "
       
   115                             "less than or equal to 0.1\n",
       
   116                             BiasedLockingBulkRebiasThreshold, value);
       
   117     return Flag::VIOLATES_CONSTRAINT;
       
   118   } else {
       
   119     return Flag::SUCCESS;
       
   120   }
       
   121 }
       
   122 
       
   123 Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) {
       
   124   if ((value % PeriodicTask::interval_gran != 0)) {
       
   125     CommandLineError::print(verbose,
       
   126                             "PerfDataSamplingInterval (" INTX_FORMAT ") must be "
       
   127                             "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n",
       
   128                             value, PeriodicTask::interval_gran);
       
   129     return Flag::VIOLATES_CONSTRAINT;
       
   130   } else {
       
   131     return Flag::SUCCESS;
       
   132   }
       
   133 }
       
   134 
       
   135 Flag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) {
       
   136   if (value) {
       
   137     if (!SafepointMechanism::supports_thread_local_poll()) {
       
   138       CommandLineError::print(verbose, "ThreadLocalHandshakes not yet supported on this platform\n");
       
   139       return Flag::VIOLATES_CONSTRAINT;
       
   140     }
       
   141   }
       
   142   return Flag::SUCCESS;
       
   143 }