hotspot/src/share/vm/runtime/commandLineFlagConstraintList.hpp
changeset 31371 311143309e73
child 31995 aa4049b4184a
equal deleted inserted replaced
31362:8957ccbb5821 31371:311143309e73
       
     1 /*
       
     2  * Copyright (c) 2015, 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_COMMANDLINEFLAGCONSTRAINTLIST_HPP
       
    26 #define SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP
       
    27 
       
    28 #include "runtime/globals.hpp"
       
    29 #include "utilities/growableArray.hpp"
       
    30 
       
    31 /*
       
    32  * Here we have a mechanism for extracting constraints (as custom functions) for flags,
       
    33  * which otherwise can not be expressed via simple range check, specified in flag macro tables.
       
    34  *
       
    35  * An example of a constraint is "flag1 < flag2" where both flag1 and flag2 can change.
       
    36  *
       
    37  * See runtime "runtime/commandLineFlagConstraintsCompiler.hpp",
       
    38  * "runtime/commandLineFlagConstraintsGC.hpp" and
       
    39  * "runtime/commandLineFlagConstraintsRuntime.hpp" for the functions themselves.
       
    40  */
       
    41 
       
    42 typedef Flag::Error (*CommandLineFlagConstraintFunc_bool)(bool verbose, bool* value);
       
    43 typedef Flag::Error (*CommandLineFlagConstraintFunc_int)(bool verbose, int* value);
       
    44 typedef Flag::Error (*CommandLineFlagConstraintFunc_intx)(bool verbose, intx* value);
       
    45 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint)(bool verbose, uint* value);
       
    46 typedef Flag::Error (*CommandLineFlagConstraintFunc_uintx)(bool verbose, uintx* value);
       
    47 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint64_t)(bool verbose, uint64_t* value);
       
    48 typedef Flag::Error (*CommandLineFlagConstraintFunc_size_t)(bool verbose, size_t* value);
       
    49 typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(bool verbose, double* value);
       
    50 
       
    51 class CommandLineFlagConstraint : public CHeapObj<mtInternal> {
       
    52 private:
       
    53   const char* _name;
       
    54 public:
       
    55   // the "name" argument must be a string literal
       
    56   CommandLineFlagConstraint(const char* name) { _name=name; };
       
    57   ~CommandLineFlagConstraint() {};
       
    58   const char* name() { return _name; }
       
    59   virtual Flag::Error apply_bool(bool* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    60   virtual Flag::Error apply_int(int* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    61   virtual Flag::Error apply_intx(intx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    62   virtual Flag::Error apply_uint(uint* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    63   virtual Flag::Error apply_uintx(uintx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    64   virtual Flag::Error apply_uint64_t(uint64_t* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    65   virtual Flag::Error apply_size_t(size_t* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    66   virtual Flag::Error apply_double(double* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
       
    67 };
       
    68 
       
    69 class CommandLineFlagConstraintList : public AllStatic {
       
    70 private:
       
    71   static GrowableArray<CommandLineFlagConstraint*>* _constraints;
       
    72 public:
       
    73   static void init();
       
    74   static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
       
    75   static CommandLineFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
       
    76   static CommandLineFlagConstraint* find(const char* name);
       
    77   static void add(CommandLineFlagConstraint* constraint) { _constraints->append(constraint); }
       
    78 };
       
    79 
       
    80 #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP */