src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp
author dfuchs
Fri, 04 May 2018 17:28:03 +0100
branchhttp-client-branch
changeset 56532 a594484f54db
parent 56497 598e0c5b6f8c
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     1
/*
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     4
 *
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     8
 *
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    13
 * accompanied this code).
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    14
 *
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    18
 *
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    21
 * questions.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    22
 *
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    23
 */
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    24
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTLIST_HPP
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    26
#define SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTLIST_HPP
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    27
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    28
#include "runtime/flags/jvmFlag.hpp"
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    29
#include "utilities/growableArray.hpp"
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    30
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    31
/*
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    32
 * Here we have a mechanism for extracting constraints (as custom functions) for flags,
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    33
 * which otherwise can not be expressed via simple range check, specified in flag macro tables.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    34
 *
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    35
 * An example of a constraint is "flag1 < flag2" where both flag1 and flag2 can change.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    36
 *
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    37
 * See runtime "runtime/flags/jvmFlagConstraintsCompiler.hpp",
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    38
 * "runtime/flags/jvmFlagConstraintsGC.hpp" and
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    39
 * "runtime/flags/jvmFlagConstraintsRuntime.hpp" for the functions themselves.
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    40
 */
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    41
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    42
typedef JVMFlag::Error (*JVMFlagConstraintFunc_bool)(bool value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    43
typedef JVMFlag::Error (*JVMFlagConstraintFunc_int)(int value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    44
typedef JVMFlag::Error (*JVMFlagConstraintFunc_intx)(intx value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    45
typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint)(uint value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    46
typedef JVMFlag::Error (*JVMFlagConstraintFunc_uintx)(uintx value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    47
typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint64_t)(uint64_t value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    48
typedef JVMFlag::Error (*JVMFlagConstraintFunc_size_t)(size_t value, bool verbose);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    49
typedef JVMFlag::Error (*JVMFlagConstraintFunc_double)(double value, bool verbose);
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    50
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    51
class JVMFlagConstraint : public CHeapObj<mtArguments> {
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    52
public:
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    53
  // During VM initialization, constraint validation will be done order of ConstraintType.
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    54
  enum ConstraintType {
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    55
    // Will be validated during argument processing (Arguments::parse_argument).
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    56
    AtParse         = 0,
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    57
    // Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo().
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    58
    AfterErgo       = 1,
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    59
    // Will be validated inside universe_init(), right after Metaspace::global_initialize().
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    60
    AfterMemoryInit = 2
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    61
  };
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    62
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    63
private:
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    64
  const char* _name;
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    65
  ConstraintType _validate_type;
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    66
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    67
public:
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    68
  // the "name" argument must be a string literal
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    69
  JVMFlagConstraint(const char* name, ConstraintType type) { _name=name; _validate_type=type; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    70
  ~JVMFlagConstraint() {};
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    71
  const char* name() const { return _name; }
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    72
  ConstraintType type() const { return _validate_type; }
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    73
  virtual JVMFlag::Error apply(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    74
  virtual JVMFlag::Error apply_bool(bool value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    75
  virtual JVMFlag::Error apply_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    76
  virtual JVMFlag::Error apply_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    77
  virtual JVMFlag::Error apply_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    78
  virtual JVMFlag::Error apply_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    79
  virtual JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    80
  virtual JVMFlag::Error apply_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    81
  virtual JVMFlag::Error apply_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    82
};
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    83
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    84
class JVMFlagConstraintList : public AllStatic {
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    85
private:
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    86
  static GrowableArray<JVMFlagConstraint*>* _constraints;
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    87
  // Latest constraint validation type.
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    88
  static JVMFlagConstraint::ConstraintType _validating_type;
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    89
public:
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    90
  static void init();
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    91
  static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    92
  static JVMFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    93
  static JVMFlagConstraint* find(const char* name);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    94
  static JVMFlagConstraint* find_if_needs_check(const char* name);
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    95
  static void add(JVMFlagConstraint* constraint) { _constraints->append(constraint); }
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    96
  // True if 'AfterErgo' or later constraint functions are validated.
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    97
  static bool validated_after_ergo() { return _validating_type >= JVMFlagConstraint::AfterErgo; };
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    98
  static bool check_constraints(JVMFlagConstraint::ConstraintType type);
49860
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    99
};
ca5216a2a2cc 8202151: [BACKOUT] Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   100
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
   101
#endif /* SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTLIST_HPP */