src/hotspot/share/runtime/flags/jvmFlag.cpp
author stefank
Mon, 26 Aug 2019 09:15:43 +0200
changeset 57876 30db6422848b
parent 55544 e846a51e8966
child 58044 3277a7454dc5
permissions -rw-r--r--
8224878: Use JVMFlag parameters instead of name strings Reviewed-by: gziemski, dholmes, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     1
/*
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
31e07291ae29 8081519: 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.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     4
 *
31e07291ae29 8081519: 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
31e07291ae29 8081519: 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
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     7
 * published by the Free Software Foundation.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
     8
 *
31e07291ae29 8081519: 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
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
31e07291ae29 8081519: 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
31e07291ae29 8081519: 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
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    13
 * accompanied this code).
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    14
 *
31e07291ae29 8081519: 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
31e07291ae29 8081519: 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,
31e07291ae29 8081519: 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.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    18
 *
31e07291ae29 8081519: 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
31e07291ae29 8081519: 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
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    21
 * questions.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    22
 *
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    23
 */
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    24
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    25
#include "precompiled.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 49857
diff changeset
    26
#include "jfr/jfrEvents.hpp"
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    27
#include "memory/allocation.inline.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    28
#include "runtime/arguments.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    29
#include "runtime/flags/jvmFlag.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    30
#include "runtime/flags/jvmFlagConstraintList.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    31
#include "runtime/flags/jvmFlagWriteableList.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    32
#include "runtime/flags/jvmFlagRangeList.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    33
#include "runtime/globals_extension.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    34
#include "utilities/defaultStream.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    35
#include "utilities/stringUtils.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    36
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    37
#define DEFAULT_RANGE_STR_CHUNK_SIZE 64
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    38
static char* create_range_str(const char *fmt, ...) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    39
  static size_t string_length = DEFAULT_RANGE_STR_CHUNK_SIZE;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    40
  static char* range_string = NEW_C_HEAP_ARRAY(char, string_length, mtLogging);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    41
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    42
  int size_needed = 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    43
  do {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    44
    va_list args;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    45
    va_start(args, fmt);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    46
    size_needed = jio_vsnprintf(range_string, string_length, fmt, args);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    47
    va_end(args);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    48
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    49
    if (size_needed < 0) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    50
      string_length += DEFAULT_RANGE_STR_CHUNK_SIZE;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    51
      range_string = REALLOC_C_HEAP_ARRAY(char, range_string, string_length, mtLogging);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    52
      guarantee(range_string != NULL, "create_range_str string should not be NULL");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    53
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    54
  } while (size_needed < 0);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    55
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    56
  return range_string;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    57
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    58
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    59
const char* JVMFlag::get_int_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    60
  return create_range_str("[ " INT32_FORMAT_W(-25) " ... " INT32_FORMAT_W(25) " ]", INT_MIN, INT_MAX);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    61
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    62
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    63
const char* JVMFlag::get_uint_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    64
  return create_range_str("[ " UINT32_FORMAT_W(-25) " ... " UINT32_FORMAT_W(25) " ]", 0, UINT_MAX);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    65
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    66
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    67
const char* JVMFlag::get_intx_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    68
  return create_range_str("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", min_intx, max_intx);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    69
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    70
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    71
const char* JVMFlag::get_uintx_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    72
  return create_range_str("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", 0, max_uintx);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    73
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    74
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    75
const char* JVMFlag::get_uint64_t_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    76
  return create_range_str("[ " UINT64_FORMAT_W(-25) " ... " UINT64_FORMAT_W(25) " ]", 0, uint64_t(max_juint));
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    77
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    78
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    79
const char* JVMFlag::get_size_t_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    80
  return create_range_str("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", 0, SIZE_MAX);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    81
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    82
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    83
const char* JVMFlag::get_double_default_range_str() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    84
  return create_range_str("[ %-25.3f ... %25.3f ]", DBL_MIN, DBL_MAX);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    85
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    86
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    87
static bool is_product_build() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    88
#ifdef PRODUCT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    89
  return true;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    90
#else
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    91
  return false;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    92
#endif
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    93
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    94
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    95
JVMFlag::Error JVMFlag::check_writable(bool changed) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    96
  if (is_constant_in_binary()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    97
    fatal("flag is constant: %s", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    98
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
    99
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   100
  JVMFlag::Error error = JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   101
  if (changed) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   102
    JVMFlagWriteable* writeable = JVMFlagWriteableList::find(_name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   103
    if (writeable) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   104
      if (writeable->is_writeable() == false) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   105
        switch (writeable->type())
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   106
        {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   107
          case JVMFlagWriteable::Once:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   108
            error = JVMFlag::SET_ONLY_ONCE;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   109
            jio_fprintf(defaultStream::error_stream(), "Error: %s may not be set more than once\n", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   110
            break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   111
          case JVMFlagWriteable::CommandLineOnly:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   112
            error = JVMFlag::COMMAND_LINE_ONLY;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   113
            jio_fprintf(defaultStream::error_stream(), "Error: %s may be modified only from commad line\n", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   114
            break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   115
          default:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   116
            ShouldNotReachHere();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   117
            break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   118
        }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   119
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   120
      writeable->mark_once();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   121
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   122
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   123
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   124
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   125
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   126
bool JVMFlag::is_bool() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   127
  return strcmp(_type, "bool") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   128
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   129
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   130
bool JVMFlag::get_bool() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   131
  return *((bool*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   132
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   133
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   134
JVMFlag::Error JVMFlag::set_bool(bool value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   135
  JVMFlag::Error error = check_writable(value!=get_bool());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   136
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   137
    *((bool*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   138
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   139
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   140
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   141
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   142
bool JVMFlag::is_int() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   143
  return strcmp(_type, "int")  == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   144
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   145
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   146
int JVMFlag::get_int() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   147
  return *((int*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   148
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   149
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   150
JVMFlag::Error JVMFlag::set_int(int value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   151
  JVMFlag::Error error = check_writable(value!=get_int());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   152
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   153
    *((int*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   154
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   155
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   156
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   157
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   158
bool JVMFlag::is_uint() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   159
  return strcmp(_type, "uint")  == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   160
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   161
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   162
uint JVMFlag::get_uint() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   163
  return *((uint*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   164
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   165
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   166
JVMFlag::Error JVMFlag::set_uint(uint value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   167
  JVMFlag::Error error = check_writable(value!=get_uint());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   168
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   169
    *((uint*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   170
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   171
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   172
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   173
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   174
bool JVMFlag::is_intx() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   175
  return strcmp(_type, "intx")  == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   176
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   177
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   178
intx JVMFlag::get_intx() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   179
  return *((intx*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   180
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   181
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   182
JVMFlag::Error JVMFlag::set_intx(intx value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   183
  JVMFlag::Error error = check_writable(value!=get_intx());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   184
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   185
    *((intx*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   186
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   187
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   188
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   189
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   190
bool JVMFlag::is_uintx() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   191
  return strcmp(_type, "uintx") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   192
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   193
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   194
uintx JVMFlag::get_uintx() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   195
  return *((uintx*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   196
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   197
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   198
JVMFlag::Error JVMFlag::set_uintx(uintx value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   199
  JVMFlag::Error error = check_writable(value!=get_uintx());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   200
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   201
    *((uintx*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   202
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   203
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   204
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   205
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   206
bool JVMFlag::is_uint64_t() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   207
  return strcmp(_type, "uint64_t") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   208
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   209
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   210
uint64_t JVMFlag::get_uint64_t() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   211
  return *((uint64_t*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   212
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   213
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   214
JVMFlag::Error JVMFlag::set_uint64_t(uint64_t value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   215
  JVMFlag::Error error = check_writable(value!=get_uint64_t());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   216
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   217
    *((uint64_t*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   218
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   219
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   220
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   221
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   222
bool JVMFlag::is_size_t() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   223
  return strcmp(_type, "size_t") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   224
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   225
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   226
size_t JVMFlag::get_size_t() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   227
  return *((size_t*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   228
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   229
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   230
JVMFlag::Error JVMFlag::set_size_t(size_t value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   231
  JVMFlag::Error error = check_writable(value!=get_size_t());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   232
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   233
    *((size_t*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   234
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   235
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   236
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   237
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   238
bool JVMFlag::is_double() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   239
  return strcmp(_type, "double") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   240
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   241
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   242
double JVMFlag::get_double() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   243
  return *((double*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   244
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   245
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   246
JVMFlag::Error JVMFlag::set_double(double value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   247
  JVMFlag::Error error = check_writable(value!=get_double());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   248
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   249
    *((double*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   250
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   251
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   252
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   253
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   254
bool JVMFlag::is_ccstr() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   255
  return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   256
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   257
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   258
bool JVMFlag::ccstr_accumulates() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   259
  return strcmp(_type, "ccstrlist") == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   260
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   261
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   262
ccstr JVMFlag::get_ccstr() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   263
  return *((ccstr*) _addr);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   264
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   265
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   266
JVMFlag::Error JVMFlag::set_ccstr(ccstr value) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   267
  JVMFlag::Error error = check_writable(value!=get_ccstr());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   268
  if (error == JVMFlag::SUCCESS) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   269
    *((ccstr*) _addr) = value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   270
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   271
  return error;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   272
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   273
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   274
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   275
JVMFlag::Flags JVMFlag::get_origin() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   276
  return Flags(_flags & VALUE_ORIGIN_MASK);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   277
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   278
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   279
void JVMFlag::set_origin(Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   280
  assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   281
  Flags new_origin = Flags((origin == COMMAND_LINE) ? Flags(origin | ORIG_COMMAND_LINE) : origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   282
  _flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | new_origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   283
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   284
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   285
bool JVMFlag::is_default() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   286
  return (get_origin() == DEFAULT);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   287
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   288
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   289
bool JVMFlag::is_ergonomic() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   290
  return (get_origin() == ERGONOMIC);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   291
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   292
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   293
bool JVMFlag::is_command_line() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   294
  return (_flags & ORIG_COMMAND_LINE) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   295
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   296
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   297
void JVMFlag::set_command_line() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   298
  _flags = Flags(_flags | ORIG_COMMAND_LINE);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   299
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   300
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   301
bool JVMFlag::is_product() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   302
  return (_flags & KIND_PRODUCT) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   303
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   304
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   305
bool JVMFlag::is_manageable() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   306
  return (_flags & KIND_MANAGEABLE) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   307
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   308
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   309
bool JVMFlag::is_diagnostic() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   310
  return (_flags & KIND_DIAGNOSTIC) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   311
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   312
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   313
bool JVMFlag::is_experimental() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   314
  return (_flags & KIND_EXPERIMENTAL) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   315
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   316
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   317
bool JVMFlag::is_notproduct() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   318
  return (_flags & KIND_NOT_PRODUCT) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   319
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   320
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   321
bool JVMFlag::is_develop() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   322
  return (_flags & KIND_DEVELOP) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   323
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   324
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   325
bool JVMFlag::is_read_write() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   326
  return (_flags & KIND_READ_WRITE) != 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   327
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   328
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   329
/**
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   330
 * Returns if this flag is a constant in the binary.  Right now this is
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   331
 * true for notproduct and develop flags in product builds.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   332
 */
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   333
bool JVMFlag::is_constant_in_binary() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   334
#ifdef PRODUCT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   335
  return is_notproduct() || is_develop();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   336
#else
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   337
  return false;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   338
#endif
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   339
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   340
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   341
bool JVMFlag::is_unlocker() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   342
  return strcmp(_name, "UnlockDiagnosticVMOptions") == 0     ||
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   343
  strcmp(_name, "UnlockExperimentalVMOptions") == 0   ||
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   344
  is_unlocker_ext();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   345
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   346
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   347
bool JVMFlag::is_unlocked() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   348
  if (is_diagnostic()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   349
    return UnlockDiagnosticVMOptions;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   350
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   351
  if (is_experimental()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   352
    return UnlockExperimentalVMOptions;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   353
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   354
  return is_unlocked_ext();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   355
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   356
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   357
void JVMFlag::clear_diagnostic() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   358
  assert(is_diagnostic(), "sanity");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   359
  _flags = Flags(_flags & ~KIND_DIAGNOSTIC);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   360
  assert(!is_diagnostic(), "sanity");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   361
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   362
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   363
// Get custom message for this locked flag, or NULL if
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   364
// none is available. Returns message type produced.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   365
JVMFlag::MsgType JVMFlag::get_locked_message(char* buf, int buflen) const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   366
  buf[0] = '\0';
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   367
  if (is_diagnostic() && !is_unlocked()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   368
    jio_snprintf(buf, buflen,
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   369
                 "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   370
                 "Error: The unlock option must precede '%s'.\n",
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   371
                 _name, _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   372
    return JVMFlag::DIAGNOSTIC_FLAG_BUT_LOCKED;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   373
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   374
  if (is_experimental() && !is_unlocked()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   375
    jio_snprintf(buf, buflen,
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   376
                 "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   377
                 "Error: The unlock option must precede '%s'.\n",
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   378
                 _name, _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   379
    return JVMFlag::EXPERIMENTAL_FLAG_BUT_LOCKED;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   380
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   381
  if (is_develop() && is_product_build()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   382
    jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n",
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   383
                 _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   384
    return JVMFlag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   385
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   386
  if (is_notproduct() && is_product_build()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   387
    jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n",
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   388
                 _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   389
    return JVMFlag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   390
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   391
  return get_locked_message_ext(buf, buflen);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   392
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   393
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   394
bool JVMFlag::is_writeable() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   395
  return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   396
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   397
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   398
// All flags except "manageable" are assumed to be internal flags.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   399
// Long term, we need to define a mechanism to specify which flags
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   400
// are external/stable and change this function accordingly.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   401
bool JVMFlag::is_external() const {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   402
  return is_manageable() || is_external_ext();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   403
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   404
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   405
// Helper function for JVMFlag::print_on().
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   406
// Fills current line up to requested position.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   407
// Should the current position already be past the requested position,
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   408
// one separator blank is enforced.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   409
void fill_to_pos(outputStream* st, unsigned int req_pos) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   410
  if ((unsigned int)st->position() < req_pos) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   411
    st->fill_to(req_pos);  // need to fill with blanks to reach req_pos
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   412
  } else {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   413
    st->print(" ");        // enforce blank separation. Previous field too long.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   414
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   415
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   416
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   417
void JVMFlag::print_on(outputStream* st, bool withComments, bool printRanges) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   418
  // Don't print notproduct and develop flags in a product build.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   419
  if (is_constant_in_binary()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   420
    return;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   421
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   422
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   423
  if (!printRanges) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   424
    // The command line options -XX:+PrintFlags* cause this function to be called
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   425
    // for each existing flag to print information pertinent to this flag. The data
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   426
    // is displayed in columnar form, with the following layout:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   427
    //  col1 - data type, right-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   428
    //  col2 - name,      left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   429
    //  col3 - ' ='       double-char, leading space to align with possible '+='
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   430
    //  col4 - value      left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   431
    //  col5 - kind       right-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   432
    //  col6 - origin     left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   433
    //  col7 - comments   left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   434
    //
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   435
    //  The column widths are fixed. They are defined such that, for most cases,
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   436
    //  an eye-pleasing tabular output is created.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   437
    //
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   438
    //  Sample output:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   439
    //       bool CMSScavengeBeforeRemark                  = false                                     {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   440
    //      uintx CMSScheduleRemarkEdenPenetration         = 50                                        {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   441
    //     size_t CMSScheduleRemarkEdenSizeThreshold       = 2097152                                   {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   442
    //      uintx CMSScheduleRemarkSamplingRatio           = 5                                         {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   443
    //     double CMSSmallCoalSurplusPercent               = 1.050000                                  {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   444
    //      ccstr CompileCommandFile                       = MyFile.cmd                                {product} {command line}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   445
    //  ccstrlist CompileOnly                              = Method1
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   446
    //            CompileOnly                             += Method2                                   {product} {command line}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   447
    //  |         |                                       |  |                              |                    |               |
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   448
    //  |         |                                       |  |                              |                    |               +-- col7
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   449
    //  |         |                                       |  |                              |                    +-- col6
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   450
    //  |         |                                       |  |                              +-- col5
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   451
    //  |         |                                       |  +-- col4
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   452
    //  |         |                                       +-- col3
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   453
    //  |         +-- col2
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   454
    //  +-- col1
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   455
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   456
    const unsigned int col_spacing = 1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   457
    const unsigned int col1_pos    = 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   458
    const unsigned int col1_width  = 9;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   459
    const unsigned int col2_pos    = col1_pos + col1_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   460
    const unsigned int col2_width  = 39;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   461
    const unsigned int col3_pos    = col2_pos + col2_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   462
    const unsigned int col3_width  = 2;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   463
    const unsigned int col4_pos    = col3_pos + col3_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   464
    const unsigned int col4_width  = 30;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   465
    const unsigned int col5_pos    = col4_pos + col4_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   466
    const unsigned int col5_width  = 20;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   467
    const unsigned int col6_pos    = col5_pos + col5_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   468
    const unsigned int col6_width  = 15;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   469
    const unsigned int col7_pos    = col6_pos + col6_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   470
    const unsigned int col7_width  = 1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   471
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   472
    st->fill_to(col1_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   473
    st->print("%*s", col1_width, _type);  // right-justified, therefore width is required.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   474
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   475
    fill_to_pos(st, col2_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   476
    st->print("%s", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   477
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   478
    fill_to_pos(st, col3_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   479
    st->print(" =");  // use " =" for proper alignment with multiline ccstr output.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   480
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   481
    fill_to_pos(st, col4_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   482
    if (is_bool()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   483
      st->print("%s", get_bool() ? "true" : "false");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   484
    } else if (is_int()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   485
      st->print("%d", get_int());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   486
    } else if (is_uint()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   487
      st->print("%u", get_uint());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   488
    } else if (is_intx()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   489
      st->print(INTX_FORMAT, get_intx());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   490
    } else if (is_uintx()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   491
      st->print(UINTX_FORMAT, get_uintx());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   492
    } else if (is_uint64_t()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   493
      st->print(UINT64_FORMAT, get_uint64_t());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   494
    } else if (is_size_t()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   495
      st->print(SIZE_FORMAT, get_size_t());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   496
    } else if (is_double()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   497
      st->print("%f", get_double());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   498
    } else if (is_ccstr()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   499
      // Honor <newline> characters in ccstr: print multiple lines.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   500
      const char* cp = get_ccstr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   501
      if (cp != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   502
        const char* eol;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   503
        while ((eol = strchr(cp, '\n')) != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   504
          size_t llen = pointer_delta(eol, cp, sizeof(char));
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   505
          st->print("%.*s", (int)llen, cp);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   506
          st->cr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   507
          cp = eol+1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   508
          fill_to_pos(st, col2_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   509
          st->print("%s", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   510
          fill_to_pos(st, col3_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   511
          st->print("+=");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   512
          fill_to_pos(st, col4_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   513
        }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   514
        st->print("%s", cp);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   515
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   516
    } else {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   517
      st->print("unhandled  type %s", _type);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   518
      st->cr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   519
      return;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   520
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   521
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   522
    fill_to_pos(st, col5_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   523
    print_kind(st, col5_width);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   524
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   525
    fill_to_pos(st, col6_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   526
    print_origin(st, col6_width);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   527
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   528
#ifndef PRODUCT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   529
    if (withComments) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   530
      fill_to_pos(st, col7_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   531
      st->print("%s", _doc);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   532
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   533
#endif
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   534
    st->cr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   535
  } else if (!is_bool() && !is_ccstr()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   536
    // The command line options -XX:+PrintFlags* cause this function to be called
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   537
    // for each existing flag to print information pertinent to this flag. The data
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   538
    // is displayed in columnar form, with the following layout:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   539
    //  col1 - data type, right-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   540
    //  col2 - name,      left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   541
    //  col4 - range      [ min ... max]
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   542
    //  col5 - kind       right-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   543
    //  col6 - origin     left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   544
    //  col7 - comments   left-justified
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   545
    //
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   546
    //  The column widths are fixed. They are defined such that, for most cases,
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   547
    //  an eye-pleasing tabular output is created.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   548
    //
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   549
    //  Sample output:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   550
    //       intx MinPassesBeforeFlush                               [ 0                         ...       9223372036854775807 ]                         {diagnostic} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   551
    //      uintx MinRAMFraction                                     [ 1                         ...      18446744073709551615 ]                            {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   552
    //     double MinRAMPercentage                                   [ 0.000                     ...                   100.000 ]                            {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   553
    //      uintx MinSurvivorRatio                                   [ 3                         ...      18446744073709551615 ]                            {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   554
    //     size_t MinTLABSize                                        [ 1                         ...       9223372036854775807 ]                            {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   555
    //       intx MonitorBound                                       [ 0                         ...                2147483647 ]                            {product} {default}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   556
    //  |         |                                                  |                                                           |                                    |               |
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   557
    //  |         |                                                  |                                                           |                                    |               +-- col7
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   558
    //  |         |                                                  |                                                           |                                    +-- col6
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   559
    //  |         |                                                  |                                                           +-- col5
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   560
    //  |         |                                                  +-- col4
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   561
    //  |         +-- col2
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   562
    //  +-- col1
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   563
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   564
    const unsigned int col_spacing = 1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   565
    const unsigned int col1_pos    = 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   566
    const unsigned int col1_width  = 9;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   567
    const unsigned int col2_pos    = col1_pos + col1_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   568
    const unsigned int col2_width  = 49;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   569
    const unsigned int col3_pos    = col2_pos + col2_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   570
    const unsigned int col3_width  = 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   571
    const unsigned int col4_pos    = col3_pos + col3_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   572
    const unsigned int col4_width  = 60;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   573
    const unsigned int col5_pos    = col4_pos + col4_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   574
    const unsigned int col5_width  = 35;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   575
    const unsigned int col6_pos    = col5_pos + col5_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   576
    const unsigned int col6_width  = 15;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   577
    const unsigned int col7_pos    = col6_pos + col6_width + col_spacing;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   578
    const unsigned int col7_width  = 1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   579
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   580
    st->fill_to(col1_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   581
    st->print("%*s", col1_width, _type);  // right-justified, therefore width is required.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   582
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   583
    fill_to_pos(st, col2_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   584
    st->print("%s", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   585
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   586
    fill_to_pos(st, col4_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   587
    RangeStrFunc func = NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   588
    if (is_int()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   589
      func = JVMFlag::get_int_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   590
    } else if (is_uint()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   591
      func = JVMFlag::get_uint_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   592
    } else if (is_intx()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   593
      func = JVMFlag::get_intx_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   594
    } else if (is_uintx()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   595
      func = JVMFlag::get_uintx_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   596
    } else if (is_uint64_t()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   597
      func = JVMFlag::get_uint64_t_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   598
    } else if (is_size_t()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   599
      func = JVMFlag::get_size_t_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   600
    } else if (is_double()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   601
      func = JVMFlag::get_double_default_range_str;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   602
    } else {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   603
      st->print("unhandled  type %s", _type);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   604
      st->cr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   605
      return;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   606
    }
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   607
    JVMFlagRangeList::print(st, this, func);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   608
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   609
    fill_to_pos(st, col5_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   610
    print_kind(st, col5_width);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   611
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   612
    fill_to_pos(st, col6_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   613
    print_origin(st, col6_width);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   614
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   615
#ifndef PRODUCT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   616
    if (withComments) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   617
      fill_to_pos(st, col7_pos);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   618
      st->print("%s", _doc);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   619
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   620
#endif
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   621
    st->cr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   622
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   623
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   624
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   625
void JVMFlag::print_kind(outputStream* st, unsigned int width) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   626
  struct Data {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   627
    int flag;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   628
    const char* name;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   629
  };
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   630
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   631
  Data data[] = {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   632
    { KIND_JVMCI, "JVMCI" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   633
    { KIND_C1, "C1" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   634
    { KIND_C2, "C2" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   635
    { KIND_ARCH, "ARCH" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   636
    { KIND_PLATFORM_DEPENDENT, "pd" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   637
    { KIND_PRODUCT, "product" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   638
    { KIND_MANAGEABLE, "manageable" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   639
    { KIND_DIAGNOSTIC, "diagnostic" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   640
    { KIND_EXPERIMENTAL, "experimental" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   641
    { KIND_NOT_PRODUCT, "notproduct" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   642
    { KIND_DEVELOP, "develop" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   643
    { KIND_LP64_PRODUCT, "lp64_product" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   644
    { KIND_READ_WRITE, "rw" },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   645
    { -1, "" }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   646
  };
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   647
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   648
  if ((_flags & KIND_MASK) != 0) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   649
    bool is_first = true;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   650
    const size_t buffer_size = 64;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   651
    size_t buffer_used = 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   652
    char kind[buffer_size];
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   653
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   654
    jio_snprintf(kind, buffer_size, "{");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   655
    buffer_used++;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   656
    for (int i = 0; data[i].flag != -1; i++) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   657
      Data d = data[i];
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   658
      if ((_flags & d.flag) != 0) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   659
        if (is_first) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   660
          is_first = false;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   661
        } else {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   662
          assert(buffer_used + 1 < buffer_size, "Too small buffer");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   663
          jio_snprintf(kind + buffer_used, buffer_size - buffer_used, " ");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   664
          buffer_used++;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   665
        }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   666
        size_t length = strlen(d.name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   667
        assert(buffer_used + length < buffer_size, "Too small buffer");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   668
        jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "%s", d.name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   669
        buffer_used += length;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   670
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   671
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   672
    assert(buffer_used + 2 <= buffer_size, "Too small buffer");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   673
    jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "}");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   674
    st->print("%*s", width, kind);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   675
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   676
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   677
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   678
void JVMFlag::print_origin(outputStream* st, unsigned int width) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   679
  int origin = _flags & VALUE_ORIGIN_MASK;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   680
  st->print("{");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   681
  switch(origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   682
    case DEFAULT:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   683
      st->print("default"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   684
    case COMMAND_LINE:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   685
      st->print("command line"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   686
    case ENVIRON_VAR:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   687
      st->print("environment"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   688
    case CONFIG_FILE:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   689
      st->print("config file"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   690
    case MANAGEMENT:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   691
      st->print("management"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   692
    case ERGONOMIC:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   693
      if (_flags & ORIG_COMMAND_LINE) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   694
        st->print("command line, ");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   695
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   696
      st->print("ergonomic"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   697
    case ATTACH_ON_DEMAND:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   698
      st->print("attach"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   699
    case INTERNAL:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   700
      st->print("internal"); break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   701
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   702
  st->print("}");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   703
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   704
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   705
void JVMFlag::print_as_flag(outputStream* st) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   706
  if (is_bool()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   707
    st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   708
  } else if (is_int()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   709
    st->print("-XX:%s=%d", _name, get_int());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   710
  } else if (is_uint()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   711
    st->print("-XX:%s=%u", _name, get_uint());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   712
  } else if (is_intx()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   713
    st->print("-XX:%s=" INTX_FORMAT, _name, get_intx());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   714
  } else if (is_uintx()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   715
    st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   716
  } else if (is_uint64_t()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   717
    st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   718
  } else if (is_size_t()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   719
    st->print("-XX:%s=" SIZE_FORMAT, _name, get_size_t());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   720
  } else if (is_double()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   721
    st->print("-XX:%s=%f", _name, get_double());
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   722
  } else if (is_ccstr()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   723
    st->print("-XX:%s=", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   724
    const char* cp = get_ccstr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   725
    if (cp != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   726
      // Need to turn embedded '\n's back into separate arguments
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   727
      // Not so efficient to print one character at a time,
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   728
      // but the choice is to do the transformation to a buffer
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   729
      // and print that.  And this need not be efficient.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   730
      for (; *cp != '\0'; cp += 1) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   731
        switch (*cp) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   732
          default:
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   733
            st->print("%c", *cp);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   734
            break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   735
          case '\n':
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   736
            st->print(" -XX:%s=", _name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   737
            break;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   738
        }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   739
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   740
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   741
  } else {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   742
    ShouldNotReachHere();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   743
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   744
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   745
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   746
const char* JVMFlag::flag_error_str(JVMFlag::Error error) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   747
  switch (error) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   748
    case JVMFlag::MISSING_NAME: return "MISSING_NAME";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   749
    case JVMFlag::MISSING_VALUE: return "MISSING_VALUE";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   750
    case JVMFlag::NON_WRITABLE: return "NON_WRITABLE";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   751
    case JVMFlag::OUT_OF_BOUNDS: return "OUT_OF_BOUNDS";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   752
    case JVMFlag::VIOLATES_CONSTRAINT: return "VIOLATES_CONSTRAINT";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   753
    case JVMFlag::INVALID_FLAG: return "INVALID_FLAG";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   754
    case JVMFlag::ERR_OTHER: return "ERR_OTHER";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   755
    case JVMFlag::SUCCESS: return "SUCCESS";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   756
    default: ShouldNotReachHere(); return "NULL";
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   757
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   758
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   759
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   760
// 4991491 do not "optimize out" the was_set false values: omitting them
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   761
// tickles a Microsoft compiler bug causing flagTable to be malformed
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   762
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   763
#define RUNTIME_PRODUCT_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   764
#define RUNTIME_PD_PRODUCT_FLAG_STRUCT(  type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   765
#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DIAGNOSTIC) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   766
#define RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT(type, name,       doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   767
#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_EXPERIMENTAL) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   768
#define RUNTIME_MANAGEABLE_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_MANAGEABLE) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   769
#define RUNTIME_PRODUCT_RW_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_READ_WRITE) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   770
#define RUNTIME_DEVELOP_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DEVELOP) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   771
#define RUNTIME_PD_DEVELOP_FLAG_STRUCT(  type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   772
#define RUNTIME_NOTPRODUCT_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_NOT_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   773
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   774
#define JVMCI_PRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   775
#define JVMCI_PD_PRODUCT_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   776
#define JVMCI_DIAGNOSTIC_FLAG_STRUCT(    type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DIAGNOSTIC) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   777
#define JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT( type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   778
#define JVMCI_EXPERIMENTAL_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_EXPERIMENTAL) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   779
#define JVMCI_DEVELOP_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DEVELOP) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   780
#define JVMCI_PD_DEVELOP_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   781
#define JVMCI_NOTPRODUCT_FLAG_STRUCT(    type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_NOT_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   782
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   783
#ifdef _LP64
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   784
#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_LP64_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   785
#else
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   786
#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   787
#endif // _LP64
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   788
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   789
#define C1_PRODUCT_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   790
#define C1_PD_PRODUCT_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   791
#define C1_DIAGNOSTIC_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DIAGNOSTIC) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   792
#define C1_PD_DIAGNOSTIC_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   793
#define C1_DEVELOP_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DEVELOP) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   794
#define C1_PD_DEVELOP_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   795
#define C1_NOTPRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_NOT_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   796
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   797
#define C2_PRODUCT_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   798
#define C2_PD_PRODUCT_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   799
#define C2_DIAGNOSTIC_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DIAGNOSTIC) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   800
#define C2_PD_DIAGNOSTIC_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   801
#define C2_EXPERIMENTAL_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_EXPERIMENTAL) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   802
#define C2_DEVELOP_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DEVELOP) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   803
#define C2_PD_DEVELOP_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   804
#define C2_NOTPRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_NOT_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   805
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   806
#define ARCH_PRODUCT_FLAG_STRUCT(        type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   807
#define ARCH_DIAGNOSTIC_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_DIAGNOSTIC) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   808
#define ARCH_EXPERIMENTAL_FLAG_STRUCT(   type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_EXPERIMENTAL) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   809
#define ARCH_DEVELOP_FLAG_STRUCT(        type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_DEVELOP) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   810
#define ARCH_NOTPRODUCT_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_NOT_PRODUCT) },
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   811
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   812
static JVMFlag flagTable[] = {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   813
  VM_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   814
           RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   815
           RUNTIME_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   816
           RUNTIME_PD_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   817
           RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   818
           RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   819
           RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   820
           RUNTIME_NOTPRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   821
           RUNTIME_MANAGEABLE_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   822
           RUNTIME_PRODUCT_RW_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   823
           RUNTIME_LP64_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   824
           IGNORE_RANGE, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   825
           IGNORE_CONSTRAINT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   826
           IGNORE_WRITEABLE)
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   827
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   828
  RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   829
                   RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   830
                   RUNTIME_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   831
                   RUNTIME_PD_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   832
                   RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   833
                   RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   834
                   RUNTIME_NOTPRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   835
                   IGNORE_RANGE, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   836
                   IGNORE_CONSTRAINT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   837
                   IGNORE_WRITEABLE)
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   838
#if INCLUDE_JVMCI
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   839
  JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   840
              JVMCI_PD_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   841
              JVMCI_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   842
              JVMCI_PD_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   843
              JVMCI_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   844
              JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   845
              JVMCI_EXPERIMENTAL_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   846
              JVMCI_NOTPRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   847
              IGNORE_RANGE, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   848
              IGNORE_CONSTRAINT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   849
              IGNORE_WRITEABLE)
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   850
#endif // INCLUDE_JVMCI
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   851
#ifdef COMPILER1
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   852
  C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   853
           C1_PD_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   854
           C1_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   855
           C1_PD_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   856
           C1_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   857
           C1_PD_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   858
           C1_NOTPRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   859
           IGNORE_RANGE, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   860
           IGNORE_CONSTRAINT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   861
           IGNORE_WRITEABLE)
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   862
#endif // COMPILER1
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   863
#ifdef COMPILER2
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   864
  C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   865
           C2_PD_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   866
           C2_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   867
           C2_PD_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   868
           C2_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   869
           C2_PD_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   870
           C2_EXPERIMENTAL_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   871
           C2_NOTPRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   872
           IGNORE_RANGE, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   873
           IGNORE_CONSTRAINT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   874
           IGNORE_WRITEABLE)
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   875
#endif // COMPILER2
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   876
  ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   877
             ARCH_PRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   878
             ARCH_DIAGNOSTIC_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   879
             ARCH_EXPERIMENTAL_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   880
             ARCH_NOTPRODUCT_FLAG_STRUCT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   881
             IGNORE_RANGE, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   882
             IGNORE_CONSTRAINT, \
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   883
             IGNORE_WRITEABLE)
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   884
  FLAGTABLE_EXT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   885
  {0, NULL, NULL}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   886
};
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   887
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   888
JVMFlag* JVMFlag::flags = flagTable;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   889
size_t JVMFlag::numFlags = (sizeof(flagTable) / sizeof(JVMFlag));
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   890
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   891
inline bool str_equal(const char* s, size_t s_len, const char* q, size_t q_len) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   892
  if (s_len != q_len) return false;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   893
  return memcmp(s, q, q_len) == 0;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   894
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   895
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   896
// Search the flag table for a named flag
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   897
JVMFlag* JVMFlag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   898
  for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   899
    if (str_equal(current->_name, current->get_name_length(), name, length)) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   900
      // Found a matching entry.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   901
      // Don't report notproduct and develop flags in product builds.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   902
      if (current->is_constant_in_binary()) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   903
        return (return_flag ? current : NULL);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   904
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   905
      // Report locked flags only if allowed.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   906
      if (!(current->is_unlocked() || current->is_unlocker())) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   907
        if (!allow_locked) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   908
          // disable use of locked flags, e.g. diagnostic, experimental,
50708
bd3a8f48597e 8202331: Obsolete support for commercial features
mikael
parents: 50289
diff changeset
   909
          // etc. until they are explicitly unlocked
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   910
          return NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   911
        }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   912
      }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   913
      return current;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   914
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   915
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   916
  // JVMFlag name is not in the flag table
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   917
  return NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   918
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   919
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   920
// Get or compute the flag name length
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   921
size_t JVMFlag::get_name_length() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   922
  if (_name_len == 0) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   923
    _name_len = strlen(_name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   924
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   925
  return _name_len;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   926
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   927
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   928
JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   929
  float VMOptionsFuzzyMatchSimilarity = 0.7f;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   930
  JVMFlag* match = NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   931
  float score;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   932
  float max_score = -1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   933
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   934
  for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   935
    score = StringUtils::similarity(current->_name, strlen(current->_name), name, length);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   936
    if (score > max_score) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   937
      max_score = score;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   938
      match = current;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   939
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   940
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   941
51070
2f4c3cac8556 8206977: Minor improvements of runtime code.
goetz
parents: 50708
diff changeset
   942
  if (match == NULL) {
2f4c3cac8556 8206977: Minor improvements of runtime code.
goetz
parents: 50708
diff changeset
   943
    return NULL;
2f4c3cac8556 8206977: Minor improvements of runtime code.
goetz
parents: 50708
diff changeset
   944
  }
2f4c3cac8556 8206977: Minor improvements of runtime code.
goetz
parents: 50708
diff changeset
   945
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   946
  if (!(match->is_unlocked() || match->is_unlocker())) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   947
    if (!allow_locked) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   948
      return NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   949
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   950
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   951
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   952
  if (max_score < VMOptionsFuzzyMatchSimilarity) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   953
    return NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   954
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   955
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   956
  return match;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   957
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   958
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   959
// Returns the address of the index'th element
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   960
JVMFlag* JVMFlagEx::flag_from_enum(JVMFlagsEnum flag) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   961
  assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   962
  return &JVMFlag::flags[flag];
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   963
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   964
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
   965
bool JVMFlagEx::is_default(JVMFlagsEnum flag) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   966
  return flag_from_enum(flag)->is_default();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   967
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   968
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
   969
bool JVMFlagEx::is_ergo(JVMFlagsEnum flag) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   970
  return flag_from_enum(flag)->is_ergonomic();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   971
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   972
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
   973
bool JVMFlagEx::is_cmdline(JVMFlagsEnum flag) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   974
  return flag_from_enum(flag)->is_command_line();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   975
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   976
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
   977
void JVMFlagEx::setOnCmdLine(JVMFlagsEnum flag) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   978
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   979
  assert(faddr != NULL, "Unknown flag");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   980
  faddr->set_command_line();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   981
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   982
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   983
template<class E, class T>
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   984
static void trace_flag_changed(const JVMFlag* flag, const T old_value, const T new_value, const JVMFlag::Flags origin) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   985
  E e;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   986
  e.set_name(flag->_name);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   987
  e.set_oldValue(old_value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   988
  e.set_newValue(new_value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   989
  e.set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   990
  e.commit();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   991
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   992
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   993
static JVMFlag::Error apply_constraint_and_check_range_bool(const JVMFlag* flag, bool new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   994
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
   995
  JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   996
  if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   997
    status = constraint->apply_bool(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   998
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
   999
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1000
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1001
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1002
JVMFlag::Error JVMFlag::boolAt(const JVMFlag* flag, bool* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1003
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1004
  if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1005
  *value = flag->get_bool();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1006
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1007
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1008
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1009
JVMFlag::Error JVMFlag::boolAtPut(JVMFlag* flag, bool* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1010
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1011
  if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1012
  JVMFlag::Error check = apply_constraint_and_check_range_bool(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1013
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1014
  bool old_value = flag->get_bool();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1015
  trace_flag_changed<EventBooleanFlagChanged, bool>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1016
  check = flag->set_bool(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1017
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1018
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1019
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1020
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1021
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1022
JVMFlag::Error JVMFlagEx::boolAtPut(JVMFlagsEnum flag, bool value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1023
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1024
  guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1025
  return JVMFlag::boolAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1026
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1027
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1028
static JVMFlag::Error apply_constraint_and_check_range_int(const JVMFlag* flag, int new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1029
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1030
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1031
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1032
    status = range->check_int(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1033
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1034
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1035
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1036
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1037
      status = constraint->apply_int(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1038
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1039
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1040
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1041
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1042
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1043
JVMFlag::Error JVMFlag::intAt(const JVMFlag* flag, int* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1044
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1045
  if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1046
  *value = flag->get_int();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1047
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1048
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1049
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1050
JVMFlag::Error JVMFlag::intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1051
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1052
  if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1053
  JVMFlag::Error check = apply_constraint_and_check_range_int(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1054
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1055
  int old_value = flag->get_int();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1056
  trace_flag_changed<EventIntFlagChanged, s4>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1057
  check = flag->set_int(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1058
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1059
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1060
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1061
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1062
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1063
JVMFlag::Error JVMFlagEx::intAtPut(JVMFlagsEnum flag, int value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1064
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1065
  guarantee(faddr != NULL && faddr->is_int(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1066
  return JVMFlag::intAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1067
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1068
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1069
static JVMFlag::Error apply_constraint_and_check_range_uint(const JVMFlag* flag, uint new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1070
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1071
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1072
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1073
    status = range->check_uint(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1074
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1075
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1076
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1077
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1078
      status = constraint->apply_uint(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1079
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1080
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1081
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1082
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1083
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1084
JVMFlag::Error JVMFlag::uintAt(const JVMFlag* flag, uint* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1085
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1086
  if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1087
  *value = flag->get_uint();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1088
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1089
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1090
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1091
JVMFlag::Error JVMFlag::uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1092
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1093
  if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1094
  JVMFlag::Error check = apply_constraint_and_check_range_uint(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1095
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1096
  uint old_value = flag->get_uint();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1097
  trace_flag_changed<EventUnsignedIntFlagChanged, u4>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1098
  check = flag->set_uint(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1099
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1100
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1101
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1102
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1103
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1104
JVMFlag::Error JVMFlagEx::uintAtPut(JVMFlagsEnum flag, uint value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1105
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1106
  guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1107
  return JVMFlag::uintAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1108
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1109
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1110
JVMFlag::Error JVMFlag::intxAt(const JVMFlag* flag, intx* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1111
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1112
  if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1113
  *value = flag->get_intx();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1114
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1115
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1116
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1117
static JVMFlag::Error apply_constraint_and_check_range_intx(const JVMFlag* flag, intx new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1118
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1119
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1120
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1121
    status = range->check_intx(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1122
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1123
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1124
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1125
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1126
      status = constraint->apply_intx(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1127
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1128
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1129
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1130
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1131
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1132
JVMFlag::Error JVMFlag::intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1133
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1134
  if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1135
  JVMFlag::Error check = apply_constraint_and_check_range_intx(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1136
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1137
  intx old_value = flag->get_intx();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1138
  trace_flag_changed<EventLongFlagChanged, intx>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1139
  check = flag->set_intx(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1140
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1141
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1142
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1143
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1144
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1145
JVMFlag::Error JVMFlagEx::intxAtPut(JVMFlagsEnum flag, intx value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1146
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1147
  guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1148
  return JVMFlag::intxAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1149
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1150
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1151
JVMFlag::Error JVMFlag::uintxAt(const JVMFlag* flag, uintx* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1152
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1153
  if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1154
  *value = flag->get_uintx();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1155
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1156
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1157
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1158
static JVMFlag::Error apply_constraint_and_check_range_uintx(const JVMFlag* flag, uintx new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1159
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1160
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1161
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1162
    status = range->check_uintx(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1163
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1164
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1165
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1166
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1167
      status = constraint->apply_uintx(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1168
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1169
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1170
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1171
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1172
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1173
JVMFlag::Error JVMFlag::uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1174
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1175
  if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1176
  JVMFlag::Error check = apply_constraint_and_check_range_uintx(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1177
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1178
  uintx old_value = flag->get_uintx();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1179
  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1180
  check = flag->set_uintx(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1181
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1182
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1183
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1184
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1185
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1186
JVMFlag::Error JVMFlagEx::uintxAtPut(JVMFlagsEnum flag, uintx value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1187
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1188
  guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1189
  return JVMFlag::uintxAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1190
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1191
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1192
JVMFlag::Error JVMFlag::uint64_tAt(const JVMFlag* flag, uint64_t* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1193
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1194
  if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1195
  *value = flag->get_uint64_t();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1196
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1197
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1198
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1199
static JVMFlag::Error apply_constraint_and_check_range_uint64_t(const JVMFlag* flag, uint64_t new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1200
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1201
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1202
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1203
    status = range->check_uint64_t(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1204
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1205
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1206
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1207
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1208
      status = constraint->apply_uint64_t(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1209
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1210
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1211
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1212
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1213
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1214
JVMFlag::Error JVMFlag::uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1215
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1216
  if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1217
  JVMFlag::Error check = apply_constraint_and_check_range_uint64_t(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1218
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1219
  uint64_t old_value = flag->get_uint64_t();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1220
  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1221
  check = flag->set_uint64_t(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1222
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1223
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1224
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1225
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1226
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1227
JVMFlag::Error JVMFlagEx::uint64_tAtPut(JVMFlagsEnum flag, uint64_t value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1228
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1229
  guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1230
  return JVMFlag::uint64_tAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1231
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1232
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1233
JVMFlag::Error JVMFlag::size_tAt(const JVMFlag* flag, size_t* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1234
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1235
  if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1236
  *value = flag->get_size_t();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1237
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1238
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1239
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1240
static JVMFlag::Error apply_constraint_and_check_range_size_t(const JVMFlag* flag, size_t new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1241
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1242
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1243
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1244
    status = range->check_size_t(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1245
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1246
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1247
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1248
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1249
      status = constraint->apply_size_t(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1250
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1251
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1252
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1253
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1254
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1255
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1256
JVMFlag::Error JVMFlag::size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1257
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1258
  if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1259
  JVMFlag::Error check = apply_constraint_and_check_range_size_t(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1260
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1261
  size_t old_value = flag->get_size_t();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1262
  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1263
  check = flag->set_size_t(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1264
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1265
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1266
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1267
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1268
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1269
JVMFlag::Error JVMFlagEx::size_tAtPut(JVMFlagsEnum flag, size_t value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1270
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1271
  guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1272
  return JVMFlag::size_tAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1273
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1274
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1275
JVMFlag::Error JVMFlag::doubleAt(const JVMFlag* flag, double* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1276
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1277
  if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1278
  *value = flag->get_double();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1279
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1280
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1281
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1282
static JVMFlag::Error apply_constraint_and_check_range_double(const JVMFlag* flag, double new_value, bool verbose) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1283
  JVMFlag::Error status = JVMFlag::SUCCESS;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1284
  JVMFlagRange* range = JVMFlagRangeList::find(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1285
  if (range != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1286
    status = range->check_double(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1287
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1288
  if (status == JVMFlag::SUCCESS) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1289
    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1290
    if (constraint != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1291
      status = constraint->apply_double(new_value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1292
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1293
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1294
  return status;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1295
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1296
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1297
JVMFlag::Error JVMFlag::doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags origin) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1298
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1299
  if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1300
  JVMFlag::Error check = apply_constraint_and_check_range_double(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1301
  if (check != JVMFlag::SUCCESS) return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1302
  double old_value = flag->get_double();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1303
  trace_flag_changed<EventDoubleFlagChanged, double>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1304
  check = flag->set_double(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1305
  *value = old_value;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1306
  flag->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1307
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1308
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1309
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1310
JVMFlag::Error JVMFlagEx::doubleAtPut(JVMFlagsEnum flag, double value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1311
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1312
  guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1313
  return JVMFlag::doubleAtPut(faddr, &value, origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1314
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1315
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1316
JVMFlag::Error JVMFlag::ccstrAt(const JVMFlag* flag, ccstr* value) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1317
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1318
  if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1319
  *value = flag->get_ccstr();
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1320
  return JVMFlag::SUCCESS;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1321
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1322
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1323
JVMFlag::Error JVMFlag::ccstrAtPut(JVMFlag* flag, ccstr* value, JVMFlag::Flags origin) {
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1324
  if (flag == NULL) return JVMFlag::INVALID_FLAG;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1325
  if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1326
  ccstr old_value = flag->get_ccstr();
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1327
  trace_flag_changed<EventStringFlagChanged, const char*>(flag, old_value, *value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1328
  char* new_value = NULL;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1329
  if (*value != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1330
    new_value = os::strdup_check_oom(*value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1331
  }
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1332
  JVMFlag::Error check = flag->set_ccstr(new_value);
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1333
  if (flag->is_default() && old_value != NULL) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1334
    // Prior value is NOT heap allocated, but was a literal constant.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1335
    old_value = os::strdup_check_oom(old_value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1336
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1337
  *value = old_value;
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1338
  flag->set_origin(origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1339
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1340
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1341
54982
b18c8301b8c2 8224201: Simplify JVM flag macro expansions
stefank
parents: 51070
diff changeset
  1342
JVMFlag::Error JVMFlagEx::ccstrAtPut(JVMFlagsEnum flag, ccstr value, JVMFlag::Flags origin) {
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1343
  JVMFlag* faddr = flag_from_enum(flag);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1344
  guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1345
  ccstr old_value = faddr->get_ccstr();
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 55544
diff changeset
  1346
  trace_flag_changed<EventStringFlagChanged, const char*>(faddr, old_value, value, origin);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1347
  char* new_value = os::strdup_check_oom(value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1348
  JVMFlag::Error check = faddr->set_ccstr(new_value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1349
  if (!faddr->is_default() && old_value != NULL) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1350
    // Prior value is heap allocated so free it.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1351
    FREE_C_HEAP_ARRAY(char, old_value);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1352
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1353
  faddr->set_origin(origin);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1354
  return check;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1355
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1356
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1357
extern "C" {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1358
  static int compare_flags(const void* void_a, const void* void_b) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1359
    return strcmp((*((JVMFlag**) void_a))->_name, (*((JVMFlag**) void_b))->_name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1360
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1361
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1362
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1363
void JVMFlag::printSetFlags(outputStream* out) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1364
  // Print which flags were set on the command line
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1365
  // note: this method is called before the thread structure is in place
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1366
  //       which means resource allocation cannot be used.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1367
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1368
  // The last entry is the null entry.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1369
  const size_t length = JVMFlag::numFlags - 1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1370
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1371
  // Sort
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1372
  JVMFlag** array = NEW_C_HEAP_ARRAY(JVMFlag*, length, mtArguments);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1373
  for (size_t i = 0; i < length; i++) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1374
    array[i] = &flagTable[i];
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1375
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1376
  qsort(array, length, sizeof(JVMFlag*), compare_flags);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1377
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1378
  // Print
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1379
  for (size_t i = 0; i < length; i++) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1380
    if (array[i]->get_origin() /* naked field! */) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1381
      array[i]->print_as_flag(out);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1382
      out->print(" ");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1383
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1384
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1385
  out->cr();
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1386
  FREE_C_HEAP_ARRAY(JVMFlag*, array);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1387
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1388
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1389
#ifndef PRODUCT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1390
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1391
void JVMFlag::verify() {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1392
  assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1393
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1394
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1395
#endif // PRODUCT
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1396
50196
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
  1397
void JVMFlag::printFlags(outputStream* out, bool withComments, bool printRanges, bool skipDefaults) {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1398
  // Print the flags sorted by name
55544
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1399
  // Note: This method may be called before the thread structure is in place
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1400
  //       which means resource allocation cannot be used. Also, it may be
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1401
  //       called as part of error reporting, so handle native OOMs gracefully.
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1402
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1403
  // The last entry is the null entry.
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1404
  const size_t length = JVMFlag::numFlags - 1;
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1405
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1406
  // Print
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1407
  if (!printRanges) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1408
    out->print_cr("[Global flags]");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1409
  } else {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1410
    out->print_cr("[Global flags ranges]");
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1411
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1412
55544
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1413
  // Sort
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1414
  JVMFlag** array = NEW_C_HEAP_ARRAY_RETURN_NULL(JVMFlag*, length, mtArguments);
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1415
  if (array != NULL) {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1416
    for (size_t i = 0; i < length; i++) {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1417
      array[i] = &flagTable[i];
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1418
    }
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1419
    qsort(array, length, sizeof(JVMFlag*), compare_flags);
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1420
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1421
    for (size_t i = 0; i < length; i++) {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1422
      if (array[i]->is_unlocked() && !(skipDefaults && array[i]->is_default())) {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1423
        array[i]->print_on(out, withComments, printRanges);
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1424
      }
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1425
    }
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1426
    FREE_C_HEAP_ARRAY(JVMFlag*, array);
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1427
  } else {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1428
    // OOM? Print unsorted.
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1429
    for (size_t i = 0; i < length; i++) {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1430
      if (flagTable[i].is_unlocked() && !(skipDefaults && flagTable[i].is_default())) {
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1431
        flagTable[i].print_on(out, withComments, printRanges);
e846a51e8966 8227035: JVM::printFlags fails in native OOM situations
stuefe
parents: 54982
diff changeset
  1432
      }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1433
    }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1434
  }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1435
}
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents:
diff changeset
  1436
50289
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1437
void JVMFlag::printError(bool verbose, const char* msg, ...) {
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1438
  if (verbose) {
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1439
    va_list listPointer;
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1440
    va_start(listPointer, msg);
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1441
    jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1442
    va_end(listPointer);
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1443
  }
0195ee80e530 8133564: Runtime - 2nd followup to Validate JVM Command-Line Flag Arguments
gziemski
parents: 50196
diff changeset
  1444
}