hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp
changeset 38273 2634194d7555
child 39117 59fa99a45873
equal deleted inserted replaced
38267:29feb145a316 38273:2634194d7555
       
     1 /*
       
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 #include "precompiled.hpp"
       
    26 #include "runtime/commandLineFlagWriteableList.hpp"
       
    27 #include "runtime/os.hpp"
       
    28 #if INCLUDE_ALL_GCS
       
    29 #include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
       
    30 #include "gc/g1/g1_globals.hpp"
       
    31 #include "gc/g1/heapRegionBounds.inline.hpp"
       
    32 #include "gc/shared/plab.hpp"
       
    33 #endif // INCLUDE_ALL_GCS
       
    34 #ifdef COMPILER1
       
    35 #include "c1/c1_globals.hpp"
       
    36 #endif // COMPILER1
       
    37 #ifdef COMPILER2
       
    38 #include "opto/c2_globals.hpp"
       
    39 #endif // COMPILER2
       
    40 #if INCLUDE_JVMCI
       
    41 #include "jvmci/jvmci_globals.hpp"
       
    42 #endif
       
    43 
       
    44 bool CommandLineFlagWriteable::is_writeable(void) {
       
    45   return _writeable;
       
    46 }
       
    47 
       
    48 void CommandLineFlagWriteable::mark_once(void) {
       
    49   if (_type == Once) {
       
    50     _writeable = false;
       
    51   }
       
    52 }
       
    53 
       
    54 void CommandLineFlagWriteable::mark_startup(void) {
       
    55   if (_type == CommandLineFlagWriteable::CommandLineOnly) {
       
    56     _writeable = false;
       
    57   }
       
    58 }
       
    59 
       
    60 // No control emitting
       
    61 void emit_writeable_no(...)                         { /* NOP */ }
       
    62 
       
    63 // No control emitting if type argument is NOT provided
       
    64 void emit_writeable_bool(const char* /*name*/)      { /* NOP */ }
       
    65 void emit_writeable_ccstr(const char* /*name*/)     { /* NOP */ }
       
    66 void emit_writeable_ccstrlist(const char* /*name*/) { /* NOP */ }
       
    67 void emit_writeable_int(const char* /*name*/)       { /* NOP */ }
       
    68 void emit_writeable_intx(const char* /*name*/)      { /* NOP */ }
       
    69 void emit_writeable_uint(const char* /*name*/)      { /* NOP */ }
       
    70 void emit_writeable_uintx(const char* /*name*/)     { /* NOP */ }
       
    71 void emit_writeable_uint64_t(const char* /*name*/)  { /* NOP */ }
       
    72 void emit_writeable_size_t(const char* /*name*/)    { /* NOP */ }
       
    73 void emit_writeable_double(const char* /*name*/)    { /* NOP */ }
       
    74 
       
    75 // CommandLineFlagWriteable emitting code functions if range arguments are provided
       
    76 void emit_writeable_bool(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    77   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    78 }
       
    79 void emit_writeable_int(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    80   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    81 }
       
    82 void emit_writeable_intx(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    83   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    84 }
       
    85 void emit_writeable_uint(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    86   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    87 }
       
    88 void emit_writeable_uintx(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    89   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    90 }
       
    91 void emit_writeable_uint64_t(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    92   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    93 }
       
    94 void emit_writeable_size_t(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    95   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    96 }
       
    97 void emit_writeable_double(const char* name, CommandLineFlagWriteable::WriteableType type) {
       
    98   CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
       
    99 }
       
   100 
       
   101 // Generate code to call emit_writeable_xxx function
       
   102 #define EMIT_WRITEABLE_PRODUCT_FLAG(type, name, value, doc)      ); emit_writeable_##type(#name
       
   103 #define EMIT_WRITEABLE_COMMERCIAL_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
       
   104 #define EMIT_WRITEABLE_DIAGNOSTIC_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
       
   105 #define EMIT_WRITEABLE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name
       
   106 #define EMIT_WRITEABLE_MANAGEABLE_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
       
   107 #define EMIT_WRITEABLE_PRODUCT_RW_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
       
   108 #define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc)          ); emit_writeable_##type(#name
       
   109 #define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc)    ); emit_writeable_##type(#name
       
   110 #define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc)        ); emit_writeable_##type(#name
       
   111 #define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
       
   112 #define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name
       
   113 
       
   114 // Generate type argument to pass into emit_writeable_xxx functions
       
   115 #define EMIT_WRITEABLE(a)                                      , CommandLineFlagWriteable::a
       
   116 
       
   117 #define INITIAL_WRITEABLES_SIZE 2
       
   118 GrowableArray<CommandLineFlagWriteable*>* CommandLineFlagWriteableList::_controls = NULL;
       
   119 
       
   120 void CommandLineFlagWriteableList::init(void) {
       
   121 
       
   122   _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagWriteable*>(INITIAL_WRITEABLES_SIZE, true);
       
   123 
       
   124   emit_writeable_no(NULL RUNTIME_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
       
   125                                    EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
       
   126                                    EMIT_WRITEABLE_PRODUCT_FLAG,
       
   127                                    EMIT_WRITEABLE_PD_PRODUCT_FLAG,
       
   128                                    EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
       
   129                                    EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
       
   130                                    EMIT_WRITEABLE_NOTPRODUCT_FLAG,
       
   131                                    EMIT_WRITEABLE_MANAGEABLE_FLAG,
       
   132                                    EMIT_WRITEABLE_PRODUCT_RW_FLAG,
       
   133                                    EMIT_WRITEABLE_LP64_PRODUCT_FLAG,
       
   134                                    IGNORE_RANGE,
       
   135                                    IGNORE_CONSTRAINT,
       
   136                                    EMIT_WRITEABLE));
       
   137 
       
   138   EMIT_WRITEABLES_FOR_GLOBALS_EXT
       
   139 
       
   140   emit_writeable_no(NULL ARCH_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
       
   141                                 EMIT_WRITEABLE_PRODUCT_FLAG,
       
   142                                 EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
       
   143                                 EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
       
   144                                 EMIT_WRITEABLE_NOTPRODUCT_FLAG,
       
   145                                 IGNORE_RANGE,
       
   146                                 IGNORE_CONSTRAINT,
       
   147                                 EMIT_WRITEABLE));
       
   148 
       
   149 #if INCLUDE_JVMCI
       
   150   emit_writeable_no(NULL JVMCI_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
       
   151                                  EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
       
   152                                  EMIT_WRITEABLE_PRODUCT_FLAG,
       
   153                                  EMIT_WRITEABLE_PD_PRODUCT_FLAG,
       
   154                                  EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
       
   155                                  EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
       
   156                                  EMIT_WRITEABLE_NOTPRODUCT_FLAG,
       
   157                                  IGNORE_RANGE,
       
   158                                  IGNORE_CONSTRAINT,
       
   159                                  EMIT_WRITEABLE));
       
   160 #endif // INCLUDE_JVMCI
       
   161 
       
   162 #ifdef COMPILER1
       
   163   emit_writeable_no(NULL C1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
       
   164                               EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
       
   165                               EMIT_WRITEABLE_PRODUCT_FLAG,
       
   166                               EMIT_WRITEABLE_PD_PRODUCT_FLAG,
       
   167                               EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
       
   168                               EMIT_WRITEABLE_NOTPRODUCT_FLAG,
       
   169                               IGNORE_RANGE,
       
   170                               IGNORE_CONSTRAINT,
       
   171                               EMIT_WRITEABLE));
       
   172 #endif // COMPILER1
       
   173 
       
   174 #ifdef COMPILER2
       
   175   emit_writeable_no(NULL C2_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
       
   176                               EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
       
   177                               EMIT_WRITEABLE_PRODUCT_FLAG,
       
   178                               EMIT_WRITEABLE_PD_PRODUCT_FLAG,
       
   179                               EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
       
   180                               EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
       
   181                               EMIT_WRITEABLE_NOTPRODUCT_FLAG,
       
   182                               IGNORE_RANGE,
       
   183                               IGNORE_CONSTRAINT,
       
   184                               EMIT_WRITEABLE));
       
   185 #endif // COMPILER2
       
   186 
       
   187 #if INCLUDE_ALL_GCS
       
   188   emit_writeable_no(NULL G1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
       
   189                               EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
       
   190                               EMIT_WRITEABLE_PRODUCT_FLAG,
       
   191                               EMIT_WRITEABLE_PD_PRODUCT_FLAG,
       
   192                               EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
       
   193                               EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
       
   194                               EMIT_WRITEABLE_NOTPRODUCT_FLAG,
       
   195                               EMIT_WRITEABLE_MANAGEABLE_FLAG,
       
   196                               EMIT_WRITEABLE_PRODUCT_RW_FLAG,
       
   197                               IGNORE_RANGE,
       
   198                               IGNORE_CONSTRAINT,
       
   199                               EMIT_WRITEABLE));
       
   200 #endif // INCLUDE_ALL_GCS
       
   201 }
       
   202 
       
   203 CommandLineFlagWriteable* CommandLineFlagWriteableList::find(const char* name) {
       
   204   CommandLineFlagWriteable* found = NULL;
       
   205   for (int i=0; i<length(); i++) {
       
   206     CommandLineFlagWriteable* writeable = at(i);
       
   207     if (strcmp(writeable->name(), name) == 0) {
       
   208       found = writeable;
       
   209       break;
       
   210     }
       
   211   }
       
   212   return found;
       
   213 }
       
   214 
       
   215 void CommandLineFlagWriteableList::mark_startup(void) {
       
   216   for (int i=0; i<length(); i++) {
       
   217     CommandLineFlagWriteable* writeable = at(i);
       
   218     writeable->mark_startup();
       
   219   }
       
   220 }