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/flags/jvmFlagWriteableList.hpp" 27 #include "runtime/os.hpp" 28 #ifdef COMPILER1 29 #include "c1/c1_globals.hpp" 30 #endif // COMPILER1 31 #ifdef COMPILER2 32 #include "opto/c2_globals.hpp" 33 #endif // COMPILER2 34 #if INCLUDE_JVMCI 35 #include "jvmci/jvmci_globals.hpp" 36 #endif 37 38 bool JVMFlagWriteable::is_writeable(void) { 39 return _writeable; 40 } 41 42 void JVMFlagWriteable::mark_once(void) { 43 if (_type == Once) { 44 _writeable = false; 45 } 46 } 47 48 void JVMFlagWriteable::mark_startup(void) { 49 if (_type == JVMFlagWriteable::CommandLineOnly) { 50 _writeable = false; 51 } 52 } 53 54 // No control emitting 55 void emit_writeable_no(...) { /* NOP */ } 56 57 // No control emitting if type argument is NOT provided 58 void emit_writeable_bool(const char* /*name*/) { /* NOP */ } 59 void emit_writeable_ccstr(const char* /*name*/) { /* NOP */ } 60 void emit_writeable_ccstrlist(const char* /*name*/) { /* NOP */ } 61 void emit_writeable_int(const char* /*name*/) { /* NOP */ } 62 void emit_writeable_intx(const char* /*name*/) { /* NOP */ } 63 void emit_writeable_uint(const char* /*name*/) { /* NOP */ } 64 void emit_writeable_uintx(const char* /*name*/) { /* NOP */ } 65 void emit_writeable_uint64_t(const char* /*name*/) { /* NOP */ } 66 void emit_writeable_size_t(const char* /*name*/) { /* NOP */ } 67 void emit_writeable_double(const char* /*name*/) { /* NOP */ } 68 69 // JVMFlagWriteable emitting code functions if range arguments are provided 70 void emit_writeable_bool(const char* name, JVMFlagWriteable::WriteableType type) { 71 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 72 } 73 void emit_writeable_int(const char* name, JVMFlagWriteable::WriteableType type) { 74 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 75 } 76 void emit_writeable_intx(const char* name, JVMFlagWriteable::WriteableType type) { 77 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 78 } 79 void emit_writeable_uint(const char* name, JVMFlagWriteable::WriteableType type) { 80 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 81 } 82 void emit_writeable_uintx(const char* name, JVMFlagWriteable::WriteableType type) { 83 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 84 } 85 void emit_writeable_uint64_t(const char* name, JVMFlagWriteable::WriteableType type) { 86 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 87 } 88 void emit_writeable_size_t(const char* name, JVMFlagWriteable::WriteableType type) { 89 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 90 } 91 void emit_writeable_double(const char* name, JVMFlagWriteable::WriteableType type) { 92 JVMFlagWriteableList::add(new JVMFlagWriteable(name, type)); 93 } 94 95 // Generate code to call emit_writeable_xxx function 96 #define EMIT_WRITEABLE_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 97 #define EMIT_WRITEABLE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 98 #define EMIT_WRITEABLE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 99 #define EMIT_WRITEABLE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 100 #define EMIT_WRITEABLE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 101 #define EMIT_WRITEABLE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 102 #define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc) ); emit_writeable_##type(#name 103 #define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 104 #define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_writeable_##type(#name 105 #define EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_writeable_##type(#name 106 #define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 107 #define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name 108 109 // Generate type argument to pass into emit_writeable_xxx functions 110 #define EMIT_WRITEABLE(a) , JVMFlagWriteable::a 111 112 #define INITIAL_WRITEABLES_SIZE 2 113 GrowableArray<JVMFlagWriteable*>* JVMFlagWriteableList::_controls = NULL; 114 115 void JVMFlagWriteableList::init(void) { 116 117 _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagWriteable*>(INITIAL_WRITEABLES_SIZE, true); 118 119 emit_writeable_no(NULL VM_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, 120 EMIT_WRITEABLE_PD_DEVELOPER_FLAG, 121 EMIT_WRITEABLE_PRODUCT_FLAG, 122 EMIT_WRITEABLE_PD_PRODUCT_FLAG, 123 EMIT_WRITEABLE_DIAGNOSTIC_FLAG, 124 EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, 125 EMIT_WRITEABLE_EXPERIMENTAL_FLAG, 126 EMIT_WRITEABLE_NOTPRODUCT_FLAG, 127 EMIT_WRITEABLE_MANAGEABLE_FLAG, 128 EMIT_WRITEABLE_PRODUCT_RW_FLAG, 129 EMIT_WRITEABLE_LP64_PRODUCT_FLAG, 130 IGNORE_RANGE, 131 IGNORE_CONSTRAINT, 132 EMIT_WRITEABLE)); 133 134 EMIT_WRITEABLES_FOR_GLOBALS_EXT 135 136 emit_writeable_no(NULL ARCH_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, 137 EMIT_WRITEABLE_PRODUCT_FLAG, 138 EMIT_WRITEABLE_DIAGNOSTIC_FLAG, 139 EMIT_WRITEABLE_EXPERIMENTAL_FLAG, 140 EMIT_WRITEABLE_NOTPRODUCT_FLAG, 141 IGNORE_RANGE, 142 IGNORE_CONSTRAINT, 143 EMIT_WRITEABLE)); 144 145 #if INCLUDE_JVMCI 146 emit_writeable_no(NULL JVMCI_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, 147 EMIT_WRITEABLE_PD_DEVELOPER_FLAG, 148 EMIT_WRITEABLE_PRODUCT_FLAG, 149 EMIT_WRITEABLE_PD_PRODUCT_FLAG, 150 EMIT_WRITEABLE_DIAGNOSTIC_FLAG, 151 EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, 152 EMIT_WRITEABLE_EXPERIMENTAL_FLAG, 153 EMIT_WRITEABLE_NOTPRODUCT_FLAG, 154 IGNORE_RANGE, 155 IGNORE_CONSTRAINT, 156 EMIT_WRITEABLE)); 157 #endif // INCLUDE_JVMCI 158 159 #ifdef COMPILER1 160 emit_writeable_no(NULL C1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, 161 EMIT_WRITEABLE_PD_DEVELOPER_FLAG, 162 EMIT_WRITEABLE_PRODUCT_FLAG, 163 EMIT_WRITEABLE_PD_PRODUCT_FLAG, 164 EMIT_WRITEABLE_DIAGNOSTIC_FLAG, 165 EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, 166 EMIT_WRITEABLE_NOTPRODUCT_FLAG, 167 IGNORE_RANGE, 168 IGNORE_CONSTRAINT, 169 EMIT_WRITEABLE)); 170 #endif // COMPILER1 171 172 #ifdef COMPILER2 173 emit_writeable_no(NULL C2_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, 174 EMIT_WRITEABLE_PD_DEVELOPER_FLAG, 175 EMIT_WRITEABLE_PRODUCT_FLAG, 176 EMIT_WRITEABLE_PD_PRODUCT_FLAG, 177 EMIT_WRITEABLE_DIAGNOSTIC_FLAG, 178 EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, 179 EMIT_WRITEABLE_EXPERIMENTAL_FLAG, 180 EMIT_WRITEABLE_NOTPRODUCT_FLAG, 181 IGNORE_RANGE, 182 IGNORE_CONSTRAINT, 183 EMIT_WRITEABLE)); 184 #endif // COMPILER2 185 } 186 187 JVMFlagWriteable* JVMFlagWriteableList::find(const char* name) { 188 JVMFlagWriteable* found = NULL; 189 for (int i=0; i<length(); i++) { 190 JVMFlagWriteable* writeable = at(i); 191 if (strcmp(writeable->name(), name) == 0) { 192 found = writeable; 193 break; 194 } 195 } 196 return found; 197 } 198 199 void JVMFlagWriteableList::mark_startup(void) { 200 for (int i=0; i<length(); i++) { 201 JVMFlagWriteable* writeable = at(i); 202 writeable->mark_startup(); 203 } 204 }