src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp
changeset 49857 31e07291ae29
parent 47216 71c04702a3d5
equal deleted inserted replaced
49856:5f63af8f9d7f 49857:31e07291ae29
       
     1 /*
       
     2  * Copyright (c) 2015, 2016, 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 #ifndef SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP
       
    26 #define SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP
       
    27 
       
    28 #include "memory/metaspaceShared.hpp"
       
    29 #include "runtime/flags/jvmFlag.hpp"
       
    30 #include "utilities/growableArray.hpp"
       
    31 
       
    32 /*
       
    33  * Here we have a mechanism for extracting ranges specified in flag macro tables.
       
    34  *
       
    35  * The specified ranges are used to verify that flags have valid values.
       
    36  *
       
    37  * An example of a range is "min <= flag <= max". Both "min" and "max" must be
       
    38  * constant and can not change. If either "min" or "max" can change,
       
    39  * then we need to use constraint instead.
       
    40  */
       
    41 
       
    42 class CommandLineError : public AllStatic {
       
    43 public:
       
    44   static void print(bool verbose, const char* msg, ...);
       
    45 };
       
    46 
       
    47 class JVMFlagRange : public CHeapObj<mtArguments> {
       
    48 private:
       
    49   const char* _name;
       
    50 public:
       
    51   // the "name" argument must be a string literal
       
    52   JVMFlagRange(const char* name) { _name=name; }
       
    53   ~JVMFlagRange() {}
       
    54   const char* name() { return _name; }
       
    55   virtual JVMFlag::Error check(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    56   virtual JVMFlag::Error check_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    57   virtual JVMFlag::Error check_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    58   virtual JVMFlag::Error check_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    59   virtual JVMFlag::Error check_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    60   virtual JVMFlag::Error check_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    61   virtual JVMFlag::Error check_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    62   virtual JVMFlag::Error check_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
       
    63   virtual void print(outputStream* st) { ; }
       
    64 };
       
    65 
       
    66 class JVMFlagRangeList : public AllStatic {
       
    67   static GrowableArray<JVMFlagRange*>* _ranges;
       
    68 public:
       
    69   static void init();
       
    70   static int length() { return (_ranges != NULL) ? _ranges->length() : 0; }
       
    71   static JVMFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; }
       
    72   static JVMFlagRange* find(const char* name);
       
    73   static void add(JVMFlagRange* range) { _ranges->append(range); }
       
    74   static void print(outputStream* st, const char* name, RangeStrFunc default_range_str_func);
       
    75   // Check the final values of all flags for ranges.
       
    76   static bool check_ranges();
       
    77 };
       
    78 
       
    79 #endif // SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP