src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54982 b18c8301b8c2
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    30 #include "runtime/flags/jvmFlag.hpp"
    30 #include "runtime/flags/jvmFlag.hpp"
    31 #include "runtime/flags/jvmFlagConstraintList.hpp"
    31 #include "runtime/flags/jvmFlagConstraintList.hpp"
    32 #include "runtime/flags/jvmFlagConstraintsCompiler.hpp"
    32 #include "runtime/flags/jvmFlagConstraintsCompiler.hpp"
    33 #include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
    33 #include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
    34 #include "runtime/globals.hpp"
    34 #include "runtime/globals.hpp"
       
    35 #include "runtime/globals_extension.hpp"
    35 #include "runtime/os.hpp"
    36 #include "runtime/os.hpp"
    36 #include "utilities/macros.hpp"
    37 #include "utilities/macros.hpp"
    37 
    38 
    38 class JVMFlagConstraint_bool : public JVMFlagConstraint {
    39 class JVMFlagConstraint_bool : public JVMFlagConstraint {
    39   JVMFlagConstraintFunc_bool _constraint;
    40   JVMFlagConstraintFunc_bool _constraint;
    40   const bool* _ptr;
    41 
    41 
    42 public:
    42 public:
    43   JVMFlagConstraint_bool(const JVMFlag* flag,
    43   // the "name" argument must be a string literal
    44                          JVMFlagConstraintFunc_bool func,
    44   JVMFlagConstraint_bool(const char* name, const bool* ptr,
    45                          ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
    45                                  JVMFlagConstraintFunc_bool func,
    46 
    46                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
    47   JVMFlag::Error apply(bool verbose) {
    47 
    48     return _constraint(_flag->get_bool(), verbose);
    48   JVMFlag::Error apply(bool verbose) {
       
    49     bool value = *_ptr;
       
    50     return _constraint(value, verbose);
       
    51   }
    49   }
    52 
    50 
    53   JVMFlag::Error apply_bool(bool value, bool verbose) {
    51   JVMFlag::Error apply_bool(bool value, bool verbose) {
    54     return _constraint(value, verbose);
    52     return _constraint(value, verbose);
    55   }
    53   }
    56 };
    54 };
    57 
    55 
    58 class JVMFlagConstraint_int : public JVMFlagConstraint {
    56 class JVMFlagConstraint_int : public JVMFlagConstraint {
    59   JVMFlagConstraintFunc_int _constraint;
    57   JVMFlagConstraintFunc_int _constraint;
    60   const int* _ptr;
    58 
    61 
    59 public:
    62 public:
    60   JVMFlagConstraint_int(const JVMFlag* flag,
    63   // the "name" argument must be a string literal
    61                         JVMFlagConstraintFunc_int func,
    64   JVMFlagConstraint_int(const char* name, const int* ptr,
    62                         ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
    65                                 JVMFlagConstraintFunc_int func,
    63 
    66                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
    64   JVMFlag::Error apply(bool verbose) {
    67 
    65     return _constraint(_flag->get_int(), verbose);
    68   JVMFlag::Error apply(bool verbose) {
       
    69     int value = *_ptr;
       
    70     return _constraint(value, verbose);
       
    71   }
    66   }
    72 
    67 
    73   JVMFlag::Error apply_int(int value, bool verbose) {
    68   JVMFlag::Error apply_int(int value, bool verbose) {
    74     return _constraint(value, verbose);
    69     return _constraint(value, verbose);
    75   }
    70   }
    76 };
    71 };
    77 
    72 
    78 class JVMFlagConstraint_intx : public JVMFlagConstraint {
    73 class JVMFlagConstraint_intx : public JVMFlagConstraint {
    79   JVMFlagConstraintFunc_intx _constraint;
    74   JVMFlagConstraintFunc_intx _constraint;
    80   const intx* _ptr;
    75 
    81 
    76 public:
    82 public:
    77   JVMFlagConstraint_intx(const JVMFlag* flag,
    83   // the "name" argument must be a string literal
    78                          JVMFlagConstraintFunc_intx func,
    84   JVMFlagConstraint_intx(const char* name, const intx* ptr,
    79                          ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
    85                                  JVMFlagConstraintFunc_intx func,
    80 
    86                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
    81   JVMFlag::Error apply(bool verbose) {
    87 
    82     return _constraint(_flag->get_intx(), verbose);
    88   JVMFlag::Error apply(bool verbose) {
       
    89     intx value = *_ptr;
       
    90     return _constraint(value, verbose);
       
    91   }
    83   }
    92 
    84 
    93   JVMFlag::Error apply_intx(intx value, bool verbose) {
    85   JVMFlag::Error apply_intx(intx value, bool verbose) {
    94     return _constraint(value, verbose);
    86     return _constraint(value, verbose);
    95   }
    87   }
    96 };
    88 };
    97 
    89 
    98 class JVMFlagConstraint_uint : public JVMFlagConstraint {
    90 class JVMFlagConstraint_uint : public JVMFlagConstraint {
    99   JVMFlagConstraintFunc_uint _constraint;
    91   JVMFlagConstraintFunc_uint _constraint;
   100   const uint* _ptr;
    92 
   101 
    93 public:
   102 public:
    94   JVMFlagConstraint_uint(const JVMFlag* flag,
   103   // the "name" argument must be a string literal
    95                          JVMFlagConstraintFunc_uint func,
   104   JVMFlagConstraint_uint(const char* name, const uint* ptr,
    96                          ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
   105                                  JVMFlagConstraintFunc_uint func,
    97 
   106                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
    98   JVMFlag::Error apply(bool verbose) {
   107 
    99     return _constraint(_flag->get_uint(), verbose);
   108   JVMFlag::Error apply(bool verbose) {
       
   109     uint value = *_ptr;
       
   110     return _constraint(value, verbose);
       
   111   }
   100   }
   112 
   101 
   113   JVMFlag::Error apply_uint(uint value, bool verbose) {
   102   JVMFlag::Error apply_uint(uint value, bool verbose) {
   114     return _constraint(value, verbose);
   103     return _constraint(value, verbose);
   115   }
   104   }
   116 };
   105 };
   117 
   106 
   118 class JVMFlagConstraint_uintx : public JVMFlagConstraint {
   107 class JVMFlagConstraint_uintx : public JVMFlagConstraint {
   119   JVMFlagConstraintFunc_uintx _constraint;
   108   JVMFlagConstraintFunc_uintx _constraint;
   120   const uintx* _ptr;
   109 
   121 
   110 public:
   122 public:
   111   JVMFlagConstraint_uintx(const JVMFlag* flag,
   123   // the "name" argument must be a string literal
   112                           JVMFlagConstraintFunc_uintx func,
   124   JVMFlagConstraint_uintx(const char* name, const uintx* ptr,
   113                           ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
   125                                   JVMFlagConstraintFunc_uintx func,
   114 
   126                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
   115   JVMFlag::Error apply(bool verbose) {
   127 
   116     return _constraint(_flag->get_uintx(), verbose);
   128   JVMFlag::Error apply(bool verbose) {
       
   129     uintx value = *_ptr;
       
   130     return _constraint(value, verbose);
       
   131   }
   117   }
   132 
   118 
   133   JVMFlag::Error apply_uintx(uintx value, bool verbose) {
   119   JVMFlag::Error apply_uintx(uintx value, bool verbose) {
   134     return _constraint(value, verbose);
   120     return _constraint(value, verbose);
   135   }
   121   }
   136 };
   122 };
   137 
   123 
   138 class JVMFlagConstraint_uint64_t : public JVMFlagConstraint {
   124 class JVMFlagConstraint_uint64_t : public JVMFlagConstraint {
   139   JVMFlagConstraintFunc_uint64_t _constraint;
   125   JVMFlagConstraintFunc_uint64_t _constraint;
   140   const uint64_t* _ptr;
   126 
   141 
   127 public:
   142 public:
   128   JVMFlagConstraint_uint64_t(const JVMFlag* flag,
   143   // the "name" argument must be a string literal
   129                              JVMFlagConstraintFunc_uint64_t func,
   144   JVMFlagConstraint_uint64_t(const char* name, const uint64_t* ptr,
   130                              ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
   145                                      JVMFlagConstraintFunc_uint64_t func,
   131 
   146                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
   132   JVMFlag::Error apply(bool verbose) {
   147 
   133     return _constraint(_flag->get_uint64_t(), verbose);
   148   JVMFlag::Error apply(bool verbose) {
       
   149     uint64_t value = *_ptr;
       
   150     return _constraint(value, verbose);
       
   151   }
   134   }
   152 
   135 
   153   JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose) {
   136   JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose) {
   154     return _constraint(value, verbose);
   137     return _constraint(value, verbose);
   155   }
   138   }
   156 };
   139 };
   157 
   140 
   158 class JVMFlagConstraint_size_t : public JVMFlagConstraint {
   141 class JVMFlagConstraint_size_t : public JVMFlagConstraint {
   159   JVMFlagConstraintFunc_size_t _constraint;
   142   JVMFlagConstraintFunc_size_t _constraint;
   160   const size_t* _ptr;
   143 
   161 public:
   144 public:
   162   // the "name" argument must be a string literal
   145   JVMFlagConstraint_size_t(const JVMFlag* flag,
   163   JVMFlagConstraint_size_t(const char* name, const size_t* ptr,
   146                            JVMFlagConstraintFunc_size_t func,
   164                                    JVMFlagConstraintFunc_size_t func,
   147                            ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
   165                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
   148 
   166 
   149   JVMFlag::Error apply(bool verbose) {
   167   JVMFlag::Error apply(bool verbose) {
   150     return _constraint(_flag->get_size_t(), verbose);
   168     size_t value = *_ptr;
       
   169     return _constraint(value, verbose);
       
   170   }
   151   }
   171 
   152 
   172   JVMFlag::Error apply_size_t(size_t value, bool verbose) {
   153   JVMFlag::Error apply_size_t(size_t value, bool verbose) {
   173     return _constraint(value, verbose);
   154     return _constraint(value, verbose);
   174   }
   155   }
   175 };
   156 };
   176 
   157 
   177 class JVMFlagConstraint_double : public JVMFlagConstraint {
   158 class JVMFlagConstraint_double : public JVMFlagConstraint {
   178   JVMFlagConstraintFunc_double _constraint;
   159   JVMFlagConstraintFunc_double _constraint;
   179   const double* _ptr;
   160 
   180 
   161 public:
   181 public:
   162   JVMFlagConstraint_double(const JVMFlag* flag,
   182   // the "name" argument must be a string literal
   163                            JVMFlagConstraintFunc_double func,
   183   JVMFlagConstraint_double(const char* name, const double* ptr,
   164                            ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
   184                                    JVMFlagConstraintFunc_double func,
   165 
   185                                  ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
   166   JVMFlag::Error apply(bool verbose) {
   186 
   167     return _constraint(_flag->get_double(), verbose);
   187   JVMFlag::Error apply(bool verbose) {
       
   188     double value = *_ptr;
       
   189     return _constraint(value, verbose);
       
   190   }
   168   }
   191 
   169 
   192   JVMFlag::Error apply_double(double value, bool verbose) {
   170   JVMFlag::Error apply_double(double value, bool verbose) {
   193     return _constraint(value, verbose);
   171     return _constraint(value, verbose);
   194   }
   172   }
   195 };
   173 };
   196 
   174 
   197 // No constraint emitting
   175 // No constraint emitting
   198 void emit_constraint_no(...)                                                      { /* NOP */ }
   176 void emit_constraint_no(...)                            { /* NOP */ }
   199 
   177 
   200 // No constraint emitting if function argument is NOT provided
   178 // No constraint emitting if function argument is NOT provided
   201 void emit_constraint_bool(const char* /*name*/, const bool* /*value*/)            { /* NOP */ }
   179 void emit_constraint_bool(const JVMFlag* /*flag*/)      { /* NOP */ }
   202 void emit_constraint_ccstr(const char* /*name*/, const ccstr* /*value*/)          { /* NOP */ }
   180 void emit_constraint_ccstr(const JVMFlag* /*flag*/)     { /* NOP */ }
   203 void emit_constraint_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/)  { /* NOP */ }
   181 void emit_constraint_ccstrlist(const JVMFlag* /*flag*/) { /* NOP */ }
   204 void emit_constraint_int(const char* /*name*/, const int* /*value*/)              { /* NOP */ }
   182 void emit_constraint_int(const JVMFlag* /*flag*/)       { /* NOP */ }
   205 void emit_constraint_intx(const char* /*name*/, const intx* /*value*/)            { /* NOP */ }
   183 void emit_constraint_intx(const JVMFlag* /*flag*/)      { /* NOP */ }
   206 void emit_constraint_uint(const char* /*name*/, const uint* /*value*/)            { /* NOP */ }
   184 void emit_constraint_uint(const JVMFlag* /*flag*/)      { /* NOP */ }
   207 void emit_constraint_uintx(const char* /*name*/, const uintx* /*value*/)          { /* NOP */ }
   185 void emit_constraint_uintx(const JVMFlag* /*flag*/)     { /* NOP */ }
   208 void emit_constraint_uint64_t(const char* /*name*/, const uint64_t* /*value*/)    { /* NOP */ }
   186 void emit_constraint_uint64_t(const JVMFlag* /*flag*/)  { /* NOP */ }
   209 void emit_constraint_size_t(const char* /*name*/, const size_t* /*value*/)        { /* NOP */ }
   187 void emit_constraint_size_t(const JVMFlag* /*flag*/)    { /* NOP */ }
   210 void emit_constraint_double(const char* /*name*/, const double* /*value*/)        { /* NOP */ }
   188 void emit_constraint_double(const JVMFlag* /*flag*/)    { /* NOP */ }
   211 
   189 
   212 // JVMFlagConstraint emitting code functions if function argument is provided
   190 // JVMFlagConstraint emitting code functions if function argument is provided
   213 void emit_constraint_bool(const char* name, const bool* ptr, JVMFlagConstraintFunc_bool func, JVMFlagConstraint::ConstraintType type) {
   191 void emit_constraint_bool(const JVMFlag* flag, JVMFlagConstraintFunc_bool func, JVMFlagConstraint::ConstraintType type) {
   214   JVMFlagConstraintList::add(new JVMFlagConstraint_bool(name, ptr, func, type));
   192   JVMFlagConstraintList::add(new JVMFlagConstraint_bool(flag, func, type));
   215 }
   193 }
   216 void emit_constraint_int(const char* name, const int* ptr, JVMFlagConstraintFunc_int func, JVMFlagConstraint::ConstraintType type) {
   194 void emit_constraint_int(const JVMFlag* flag, JVMFlagConstraintFunc_int func, JVMFlagConstraint::ConstraintType type) {
   217   JVMFlagConstraintList::add(new JVMFlagConstraint_int(name, ptr, func, type));
   195   JVMFlagConstraintList::add(new JVMFlagConstraint_int(flag, func, type));
   218 }
   196 }
   219 void emit_constraint_intx(const char* name, const intx* ptr, JVMFlagConstraintFunc_intx func, JVMFlagConstraint::ConstraintType type) {
   197 void emit_constraint_intx(const JVMFlag* flag, JVMFlagConstraintFunc_intx func, JVMFlagConstraint::ConstraintType type) {
   220   JVMFlagConstraintList::add(new JVMFlagConstraint_intx(name, ptr, func, type));
   198   JVMFlagConstraintList::add(new JVMFlagConstraint_intx(flag, func, type));
   221 }
   199 }
   222 void emit_constraint_uint(const char* name, const uint* ptr, JVMFlagConstraintFunc_uint func, JVMFlagConstraint::ConstraintType type) {
   200 void emit_constraint_uint(const JVMFlag* flag, JVMFlagConstraintFunc_uint func, JVMFlagConstraint::ConstraintType type) {
   223   JVMFlagConstraintList::add(new JVMFlagConstraint_uint(name, ptr, func, type));
   201   JVMFlagConstraintList::add(new JVMFlagConstraint_uint(flag, func, type));
   224 }
   202 }
   225 void emit_constraint_uintx(const char* name, const uintx* ptr, JVMFlagConstraintFunc_uintx func, JVMFlagConstraint::ConstraintType type) {
   203 void emit_constraint_uintx(const JVMFlag* flag, JVMFlagConstraintFunc_uintx func, JVMFlagConstraint::ConstraintType type) {
   226   JVMFlagConstraintList::add(new JVMFlagConstraint_uintx(name, ptr, func, type));
   204   JVMFlagConstraintList::add(new JVMFlagConstraint_uintx(flag, func, type));
   227 }
   205 }
   228 void emit_constraint_uint64_t(const char* name, const uint64_t* ptr, JVMFlagConstraintFunc_uint64_t func, JVMFlagConstraint::ConstraintType type) {
   206 void emit_constraint_uint64_t(const JVMFlag* flag, JVMFlagConstraintFunc_uint64_t func, JVMFlagConstraint::ConstraintType type) {
   229   JVMFlagConstraintList::add(new JVMFlagConstraint_uint64_t(name, ptr, func, type));
   207   JVMFlagConstraintList::add(new JVMFlagConstraint_uint64_t(flag, func, type));
   230 }
   208 }
   231 void emit_constraint_size_t(const char* name, const size_t* ptr, JVMFlagConstraintFunc_size_t func, JVMFlagConstraint::ConstraintType type) {
   209 void emit_constraint_size_t(const JVMFlag* flag, JVMFlagConstraintFunc_size_t func, JVMFlagConstraint::ConstraintType type) {
   232   JVMFlagConstraintList::add(new JVMFlagConstraint_size_t(name, ptr, func, type));
   210   JVMFlagConstraintList::add(new JVMFlagConstraint_size_t(flag, func, type));
   233 }
   211 }
   234 void emit_constraint_double(const char* name, const double* ptr, JVMFlagConstraintFunc_double func, JVMFlagConstraint::ConstraintType type) {
   212 void emit_constraint_double(const JVMFlag* flag, JVMFlagConstraintFunc_double func, JVMFlagConstraint::ConstraintType type) {
   235   JVMFlagConstraintList::add(new JVMFlagConstraint_double(name, ptr, func, type));
   213   JVMFlagConstraintList::add(new JVMFlagConstraint_double(flag, func, type));
   236 }
   214 }
   237 
   215 
   238 // Generate code to call emit_constraint_xxx function
   216 // Generate code to call emit_constraint_xxx function
   239 #define EMIT_CONSTRAINT_START       (void)(0
   217 #define EMIT_CONSTRAINT_START       (void)(0
   240 #define EMIT_CONSTRAINT(type, name) ); emit_constraint_##type(#name, &name
   218 #define EMIT_CONSTRAINT(type, name) ); emit_constraint_##type(JVMFlagEx::flag_from_enum(FLAG_MEMBER_ENUM(name))
   241 #define EMIT_CONSTRAINT_NO          ); emit_constraint_no(0
   219 #define EMIT_CONSTRAINT_NO          ); emit_constraint_no(0
   242 #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc)      EMIT_CONSTRAINT(type, name)
   220 #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc)      EMIT_CONSTRAINT(type, name)
   243 #define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc)   EMIT_CONSTRAINT(type, name)
   221 #define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc)   EMIT_CONSTRAINT(type, name)
   244 #define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) EMIT_CONSTRAINT(type, name)
   222 #define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) EMIT_CONSTRAINT(type, name)
   245 #define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc)   EMIT_CONSTRAINT(type, name)
   223 #define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc)   EMIT_CONSTRAINT(type, name)
   289             EMIT_CONSTRAINT_LP64_PRODUCT_FLAG,
   267             EMIT_CONSTRAINT_LP64_PRODUCT_FLAG,
   290             IGNORE_RANGE,
   268             IGNORE_RANGE,
   291             EMIT_CONSTRAINT_CHECK,
   269             EMIT_CONSTRAINT_CHECK,
   292             IGNORE_WRITEABLE)
   270             IGNORE_WRITEABLE)
   293 
   271 
   294   EMIT_CONSTRAINTS_FOR_GLOBALS_EXT
       
   295 
       
   296   EMIT_CONSTRAINT_END
   272   EMIT_CONSTRAINT_END
   297 }
   273 }
   298 
   274 
   299 JVMFlagConstraint* JVMFlagConstraintList::find(const char* name) {
   275 JVMFlagConstraint* JVMFlagConstraintList::find(const JVMFlag* flag) {
   300   JVMFlagConstraint* found = NULL;
   276   JVMFlagConstraint* found = NULL;
   301   for (int i=0; i<length(); i++) {
   277   for (int i=0; i<length(); i++) {
   302     JVMFlagConstraint* constraint = at(i);
   278     JVMFlagConstraint* constraint = at(i);
   303     if (strcmp(constraint->name(), name) == 0) {
   279     if (constraint->flag() == flag) {
   304       found = constraint;
   280       found = constraint;
   305       break;
   281       break;
   306     }
   282     }
   307   }
   283   }
   308   return found;
   284   return found;
   309 }
   285 }
   310 
   286 
   311 // Find constraints by name and return only if found constraint's type is equal or lower than current validating type.
   287 // Find constraints and return only if found constraint's type is equal or lower than current validating type.
   312 JVMFlagConstraint* JVMFlagConstraintList::find_if_needs_check(const char* name) {
   288 JVMFlagConstraint* JVMFlagConstraintList::find_if_needs_check(const JVMFlag* flag) {
   313   JVMFlagConstraint* found = NULL;
   289   JVMFlagConstraint* found = NULL;
   314   JVMFlagConstraint* constraint = find(name);
   290   JVMFlagConstraint* constraint = find(flag);
   315   if (constraint && (constraint->type() <= _validating_type)) {
   291   if (constraint != NULL && (constraint->type() <= _validating_type)) {
   316     found = constraint;
   292     found = constraint;
   317   }
   293   }
   318   return found;
   294   return found;
   319 }
   295 }
   320 
   296