/java-1.7.0-openjdk/openjdk/hotspot/src/share/vm/runtime/arguments.cpp
C++ | 3380 lines | 3053 code | 158 blank | 169 comment | 338 complexity | 1ff331024371cf94ab0164bb2a74ac73 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, LGPL-3.0, LGPL-2.0
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
- #include "precompiled.hpp"
- #include "classfile/javaAssertions.hpp"
- #include "compiler/compilerOracle.hpp"
- #include "memory/allocation.inline.hpp"
- #include "memory/cardTableRS.hpp"
- #include "memory/referenceProcessor.hpp"
- #include "memory/universe.inline.hpp"
- #include "oops/oop.inline.hpp"
- #include "prims/jvmtiExport.hpp"
- #include "runtime/arguments.hpp"
- #include "runtime/globals_extension.hpp"
- #include "runtime/java.hpp"
- #include "services/management.hpp"
- #include "utilities/defaultStream.hpp"
- #include "utilities/taskqueue.hpp"
- #ifdef TARGET_OS_FAMILY_linux
- # include "os_linux.inline.hpp"
- #endif
- #ifdef TARGET_OS_FAMILY_solaris
- # include "os_solaris.inline.hpp"
- #endif
- #ifdef TARGET_OS_FAMILY_windows
- # include "os_windows.inline.hpp"
- #endif
- #ifdef TARGET_OS_FAMILY_bsd
- # include "os_bsd.inline.hpp"
- #endif
- #ifndef SERIALGC
- #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
- #endif
- #define DEFAULT_VENDOR_URL_BUG "http://icedtea.classpath.org/bugzilla"
- #define DEFAULT_JAVA_LAUNCHER "generic"
- char** Arguments::_jvm_flags_array = NULL;
- int Arguments::_num_jvm_flags = 0;
- char** Arguments::_jvm_args_array = NULL;
- int Arguments::_num_jvm_args = 0;
- char* Arguments::_java_command = NULL;
- SystemProperty* Arguments::_system_properties = NULL;
- const char* Arguments::_gc_log_filename = NULL;
- bool Arguments::_has_profile = false;
- bool Arguments::_has_alloc_profile = false;
- uintx Arguments::_min_heap_size = 0;
- Arguments::Mode Arguments::_mode = _mixed;
- bool Arguments::_java_compiler = false;
- bool Arguments::_xdebug_mode = false;
- const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
- const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
- int Arguments::_sun_java_launcher_pid = -1;
- bool Arguments::_created_by_gamma_launcher = false;
- // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
- bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
- bool Arguments::_UseOnStackReplacement = UseOnStackReplacement;
- bool Arguments::_BackgroundCompilation = BackgroundCompilation;
- bool Arguments::_ClipInlining = ClipInlining;
- char* Arguments::SharedArchivePath = NULL;
- AgentLibraryList Arguments::_libraryList;
- AgentLibraryList Arguments::_agentList;
- abort_hook_t Arguments::_abort_hook = NULL;
- exit_hook_t Arguments::_exit_hook = NULL;
- vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
- SystemProperty *Arguments::_java_ext_dirs = NULL;
- SystemProperty *Arguments::_java_endorsed_dirs = NULL;
- SystemProperty *Arguments::_sun_boot_library_path = NULL;
- SystemProperty *Arguments::_java_library_path = NULL;
- SystemProperty *Arguments::_java_home = NULL;
- SystemProperty *Arguments::_java_class_path = NULL;
- SystemProperty *Arguments::_sun_boot_class_path = NULL;
- char* Arguments::_meta_index_path = NULL;
- char* Arguments::_meta_index_dir = NULL;
- // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
- static bool match_option(const JavaVMOption *option, const char* name,
- const char** tail) {
- int len = (int)strlen(name);
- if (strncmp(option->optionString, name, len) == 0) {
- *tail = option->optionString + len;
- return true;
- } else {
- return false;
- }
- }
- static void logOption(const char* opt) {
- if (PrintVMOptions) {
- jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
- }
- }
- // Process java launcher properties.
- void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
- // See if sun.java.launcher or sun.java.launcher.pid is defined.
- // Must do this before setting up other system properties,
- // as some of them may depend on launcher type.
- for (int index = 0; index < args->nOptions; index++) {
- const JavaVMOption* option = args->options + index;
- const char* tail;
- if (match_option(option, "-Dsun.java.launcher=", &tail)) {
- process_java_launcher_argument(tail, option->extraInfo);
- continue;
- }
- if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {
- _sun_java_launcher_pid = atoi(tail);
- continue;
- }
- }
- }
- // Initialize system properties key and value.
- void Arguments::init_system_properties() {
- PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name",
- "Java Virtual Machine Specification", false));
- PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false));
- PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false));
- PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true));
- // following are JVMTI agent writeable properties.
- // Properties values are set to NULL and they are
- // os specific they are initialized in os::init_system_properties_values().
- _java_ext_dirs = new SystemProperty("java.ext.dirs", NULL, true);
- _java_endorsed_dirs = new SystemProperty("java.endorsed.dirs", NULL, true);
- _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true);
- _java_library_path = new SystemProperty("java.library.path", NULL, true);
- _java_home = new SystemProperty("java.home", NULL, true);
- _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
- _java_class_path = new SystemProperty("java.class.path", "", true);
- // Add to System Property list.
- PropertyList_add(&_system_properties, _java_ext_dirs);
- PropertyList_add(&_system_properties, _java_endorsed_dirs);
- PropertyList_add(&_system_properties, _sun_boot_library_path);
- PropertyList_add(&_system_properties, _java_library_path);
- PropertyList_add(&_system_properties, _java_home);
- PropertyList_add(&_system_properties, _java_class_path);
- PropertyList_add(&_system_properties, _sun_boot_class_path);
- // Set OS specific system properties values
- os::init_system_properties_values();
- }
- // Update/Initialize System properties after JDK version number is known
- void Arguments::init_version_specific_system_properties() {
- enum { bufsz = 16 };
- char buffer[bufsz];
- const char* spec_vendor = "Sun Microsystems Inc.";
- uint32_t spec_version = 0;
- if (JDK_Version::is_gte_jdk17x_version()) {
- spec_vendor = "Oracle Corporation";
- spec_version = JDK_Version::current().major_version();
- }
- jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
- PropertyList_add(&_system_properties,
- new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
- PropertyList_add(&_system_properties,
- new SystemProperty("java.vm.specification.version", buffer, false));
- PropertyList_add(&_system_properties,
- new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
- }
- /**
- * Provide a slightly more user-friendly way of eliminating -XX flags.
- * When a flag is eliminated, it can be added to this list in order to
- * continue accepting this flag on the command-line, while issuing a warning
- * and ignoring the value. Once the JDK version reaches the 'accept_until'
- * limit, we flatly refuse to admit the existence of the flag. This allows
- * a flag to die correctly over JDK releases using HSX.
- */
- typedef struct {
- const char* name;
- JDK_Version obsoleted_in; // when the flag went away
- JDK_Version accept_until; // which version to start denying the existence
- } ObsoleteFlag;
- static ObsoleteFlag obsolete_jvm_flags[] = {
- { "UseTrainGC", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "UseOversizedCarHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "TraceCarAllocation", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "PrintTrainGCProcessingStats", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "LogOfCarSpaceSize", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "OversizedCarThreshold", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "MinTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "DefaultTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "MaxTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "DelayTickAdjustment", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "ProcessingToTenuringRatio", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "MinTrainLength", JDK_Version::jdk(5), JDK_Version::jdk(7) },
- { "AppendRatio", JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) },
- { "DefaultMaxRAM", JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
- { "DefaultInitialRAMFraction",
- JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
- { "UseDepthFirstScavengeOrder",
- JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) },
- { "HandlePromotionFailure",
- JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
- { "MaxLiveObjectEvacuationRatio",
- JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
- { "ForceSharedSpaces", JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
- { "UseParallelOldGCCompacting",
- JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
- { "UseParallelDensePrefixUpdate",
- JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
- { "UseParallelOldGCDensePrefix",
- JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
- { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) },
- { "UseCompressedStrings", JDK_Version::jdk(7), JDK_Version::jdk(8) },
- #ifdef PRODUCT
- { "DesiredMethodLimit",
- JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },
- #endif // PRODUCT
- { NULL, JDK_Version(0), JDK_Version(0) }
- };
- // Returns true if the flag is obsolete and fits into the range specified
- // for being ignored. In the case that the flag is ignored, the 'version'
- // value is filled in with the version number when the flag became
- // obsolete so that that value can be displayed to the user.
- bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
- int i = 0;
- assert(version != NULL, "Must provide a version buffer");
- while (obsolete_jvm_flags[i].name != NULL) {
- const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
- // <flag>=xxx form
- // [-|+]<flag> form
- if ((strncmp(flag_status.name, s, strlen(flag_status.name)) == 0) ||
- ((s[0] == '+' || s[0] == '-') &&
- (strncmp(flag_status.name, &s[1], strlen(flag_status.name)) == 0))) {
- if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
- *version = flag_status.obsoleted_in;
- return true;
- }
- }
- i++;
- }
- return false;
- }
- // Constructs the system class path (aka boot class path) from the following
- // components, in order:
- //
- // prefix // from -Xbootclasspath/p:...
- // endorsed // the expansion of -Djava.endorsed.dirs=...
- // base // from os::get_system_properties() or -Xbootclasspath=
- // suffix // from -Xbootclasspath/a:...
- //
- // java.endorsed.dirs is a list of directories; any jar or zip files in the
- // directories are added to the sysclasspath just before the base.
- //
- // This could be AllStatic, but it isn't needed after argument processing is
- // complete.
- class SysClassPath: public StackObj {
- public:
- SysClassPath(const char* base);
- ~SysClassPath();
- inline void set_base(const char* base);
- inline void add_prefix(const char* prefix);
- inline void add_suffix_to_prefix(const char* suffix);
- inline void add_suffix(const char* suffix);
- inline void reset_path(const char* base);
- // Expand the jar/zip files in each directory listed by the java.endorsed.dirs
- // property. Must be called after all command-line arguments have been
- // processed (in particular, -Djava.endorsed.dirs=...) and before calling
- // combined_path().
- void expand_endorsed();
- inline const char* get_base() const { return _items[_scp_base]; }
- inline const char* get_prefix() const { return _items[_scp_prefix]; }
- inline const char* get_suffix() const { return _items[_scp_suffix]; }
- inline const char* get_endorsed() const { return _items[_scp_endorsed]; }
- // Combine all the components into a single c-heap-allocated string; caller
- // must free the string if/when no longer needed.
- char* combined_path();
- private:
- // Utility routines.
- static char* add_to_path(const char* path, const char* str, bool prepend);
- static char* add_jars_to_path(char* path, const char* directory);
- inline void reset_item_at(int index);
- // Array indices for the items that make up the sysclasspath. All except the
- // base are allocated in the C heap and freed by this class.
- enum {
- _scp_prefix, // from -Xbootclasspath/p:...
- _scp_endorsed, // the expansion of -Djava.endorsed.dirs=...
- _scp_base, // the default sysclasspath
- _scp_suffix, // from -Xbootclasspath/a:...
- _scp_nitems // the number of items, must be last.
- };
- const char* _items[_scp_nitems];
- DEBUG_ONLY(bool _expansion_done;)
- };
- SysClassPath::SysClassPath(const char* base) {
- memset(_items, 0, sizeof(_items));
- _items[_scp_base] = base;
- DEBUG_ONLY(_expansion_done = false;)
- }
- SysClassPath::~SysClassPath() {
- // Free everything except the base.
- for (int i = 0; i < _scp_nitems; ++i) {
- if (i != _scp_base) reset_item_at(i);
- }
- DEBUG_ONLY(_expansion_done = false;)
- }
- inline void SysClassPath::set_base(const char* base) {
- _items[_scp_base] = base;
- }
- inline void SysClassPath::add_prefix(const char* prefix) {
- _items[_scp_prefix] = add_to_path(_items[_scp_prefix], prefix, true);
- }
- inline void SysClassPath::add_suffix_to_prefix(const char* suffix) {
- _items[_scp_prefix] = add_to_path(_items[_scp_prefix], suffix, false);
- }
- inline void SysClassPath::add_suffix(const char* suffix) {
- _items[_scp_suffix] = add_to_path(_items[_scp_suffix], suffix, false);
- }
- inline void SysClassPath::reset_item_at(int index) {
- assert(index < _scp_nitems && index != _scp_base, "just checking");
- if (_items[index] != NULL) {
- FREE_C_HEAP_ARRAY(char, _items[index]);
- _items[index] = NULL;
- }
- }
- inline void SysClassPath::reset_path(const char* base) {
- // Clear the prefix and suffix.
- reset_item_at(_scp_prefix);
- reset_item_at(_scp_suffix);
- set_base(base);
- }
- //------------------------------------------------------------------------------
- void SysClassPath::expand_endorsed() {
- assert(_items[_scp_endorsed] == NULL, "can only be called once.");
- const char* path = Arguments::get_property("java.endorsed.dirs");
- if (path == NULL) {
- path = Arguments::get_endorsed_dir();
- assert(path != NULL, "no default for java.endorsed.dirs");
- }
- char* expanded_path = NULL;
- const char separator = *os::path_separator();
- const char* const end = path + strlen(path);
- while (path < end) {
- const char* tmp_end = strchr(path, separator);
- if (tmp_end == NULL) {
- expanded_path = add_jars_to_path(expanded_path, path);
- path = end;
- } else {
- char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1);
- memcpy(dirpath, path, tmp_end - path);
- dirpath[tmp_end - path] = '\0';
- expanded_path = add_jars_to_path(expanded_path, dirpath);
- FREE_C_HEAP_ARRAY(char, dirpath);
- path = tmp_end + 1;
- }
- }
- _items[_scp_endorsed] = expanded_path;
- DEBUG_ONLY(_expansion_done = true;)
- }
- // Combine the bootclasspath elements, some of which may be null, into a single
- // c-heap-allocated string.
- char* SysClassPath::combined_path() {
- assert(_items[_scp_base] != NULL, "empty default sysclasspath");
- assert(_expansion_done, "must call expand_endorsed() first.");
- size_t lengths[_scp_nitems];
- size_t total_len = 0;
- const char separator = *os::path_separator();
- // Get the lengths.
- int i;
- for (i = 0; i < _scp_nitems; ++i) {
- if (_items[i] != NULL) {
- lengths[i] = strlen(_items[i]);
- // Include space for the separator char (or a NULL for the last item).
- total_len += lengths[i] + 1;
- }
- }
- assert(total_len > 0, "empty sysclasspath not allowed");
- // Copy the _items to a single string.
- char* cp = NEW_C_HEAP_ARRAY(char, total_len);
- char* cp_tmp = cp;
- for (i = 0; i < _scp_nitems; ++i) {
- if (_items[i] != NULL) {
- memcpy(cp_tmp, _items[i], lengths[i]);
- cp_tmp += lengths[i];
- *cp_tmp++ = separator;
- }
- }
- *--cp_tmp = '\0'; // Replace the extra separator.
- return cp;
- }
- // Note: path must be c-heap-allocated (or NULL); it is freed if non-null.
- char*
- SysClassPath::add_to_path(const char* path, const char* str, bool prepend) {
- char *cp;
- assert(str != NULL, "just checking");
- if (path == NULL) {
- size_t len = strlen(str) + 1;
- cp = NEW_C_HEAP_ARRAY(char, len);
- memcpy(cp, str, len); // copy the trailing null
- } else {
- const char separator = *os::path_separator();
- size_t old_len = strlen(path);
- size_t str_len = strlen(str);
- size_t len = old_len + str_len + 2;
- if (prepend) {
- cp = NEW_C_HEAP_ARRAY(char, len);
- char* cp_tmp = cp;
- memcpy(cp_tmp, str, str_len);
- cp_tmp += str_len;
- *cp_tmp = separator;
- memcpy(++cp_tmp, path, old_len + 1); // copy the trailing null
- FREE_C_HEAP_ARRAY(char, path);
- } else {
- cp = REALLOC_C_HEAP_ARRAY(char, path, len);
- char* cp_tmp = cp + old_len;
- *cp_tmp = separator;
- memcpy(++cp_tmp, str, str_len + 1); // copy the trailing null
- }
- }
- return cp;
- }
- // Scan the directory and append any jar or zip files found to path.
- // Note: path must be c-heap-allocated (or NULL); it is freed if non-null.
- char* SysClassPath::add_jars_to_path(char* path, const char* directory) {
- DIR* dir = os::opendir(directory);
- if (dir == NULL) return path;
- char dir_sep[2] = { '\0', '\0' };
- size_t directory_len = strlen(directory);
- const char fileSep = *os::file_separator();
- if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep;
- /* Scan the directory for jars/zips, appending them to path. */
- struct dirent *entry;
- char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory));
- while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
- const char* name = entry->d_name;
- const char* ext = name + strlen(name) - 4;
- bool isJarOrZip = ext > name &&
- (os::file_name_strcmp(ext, ".jar") == 0 ||
- os::file_name_strcmp(ext, ".zip") == 0);
- if (isJarOrZip) {
- char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name));
- sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
- path = add_to_path(path, jarpath, false);
- FREE_C_HEAP_ARRAY(char, jarpath);
- }
- }
- FREE_C_HEAP_ARRAY(char, dbuf);
- os::closedir(dir);
- return path;
- }
- // Parses a memory size specification string.
- static bool atomull(const char *s, julong* result) {
- julong n = 0;
- int args_read = sscanf(s, os::julong_format_specifier(), &n);
- if (args_read != 1) {
- return false;
- }
- while (*s != '\0' && isdigit(*s)) {
- s++;
- }
- // 4705540: illegal if more characters are found after the first non-digit
- if (strlen(s) > 1) {
- return false;
- }
- switch (*s) {
- case 'T': case 't':
- *result = n * G * K;
- // Check for overflow.
- if (*result/((julong)G * K) != n) return false;
- return true;
- case 'G': case 'g':
- *result = n * G;
- if (*result/G != n) return false;
- return true;
- case 'M': case 'm':
- *result = n * M;
- if (*result/M != n) return false;
- return true;
- case 'K': case 'k':
- *result = n * K;
- if (*result/K != n) return false;
- return true;
- case '\0':
- *result = n;
- return true;
- default:
- return false;
- }
- }
- Arguments::ArgsRange Arguments::check_memory_size(julong size, julong min_size) {
- if (size < min_size) return arg_too_small;
- // Check that size will fit in a size_t (only relevant on 32-bit)
- if (size > max_uintx) return arg_too_big;
- return arg_in_range;
- }
- // Describe an argument out of range error
- void Arguments::describe_range_error(ArgsRange errcode) {
- switch(errcode) {
- case arg_too_big:
- jio_fprintf(defaultStream::error_stream(),
- "The specified size exceeds the maximum "
- "representable size.\n");
- break;
- case arg_too_small:
- case arg_unreadable:
- case arg_in_range:
- // do nothing for now
- break;
- default:
- ShouldNotReachHere();
- }
- }
- static bool set_bool_flag(char* name, bool value, FlagValueOrigin origin) {
- return CommandLineFlags::boolAtPut(name, &value, origin);
- }
- static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
- double v;
- if (sscanf(value, "%lf", &v) != 1) {
- return false;
- }
- if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
- return true;
- }
- return false;
- }
- static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
- julong v;
- intx intx_v;
- bool is_neg = false;
- // Check the sign first since atomull() parses only unsigned values.
- if (*value == '-') {
- if (!CommandLineFlags::intxAt(name, &intx_v)) {
- return false;
- }
- value++;
- is_neg = true;
- }
- if (!atomull(value, &v)) {
- return false;
- }
- intx_v = (intx) v;
- if (is_neg) {
- intx_v = -intx_v;
- }
- if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) {
- return true;
- }
- uintx uintx_v = (uintx) v;
- if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) {
- return true;
- }
- uint64_t uint64_t_v = (uint64_t) v;
- if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
- return true;
- }
- return false;
- }
- static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) {
- if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
- // Contract: CommandLineFlags always returns a pointer that needs freeing.
- FREE_C_HEAP_ARRAY(char, value);
- return true;
- }
- static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) {
- const char* old_value = "";
- if (!CommandLineFlags::ccstrAt(name, &old_value)) return false;
- size_t old_len = old_value != NULL ? strlen(old_value) : 0;
- size_t new_len = strlen(new_value);
- const char* value;
- char* free_this_too = NULL;
- if (old_len == 0) {
- value = new_value;
- } else if (new_len == 0) {
- value = old_value;
- } else {
- char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1);
- // each new setting adds another LINE to the switch:
- sprintf(buf, "%s\n%s", old_value, new_value);
- value = buf;
- free_this_too = buf;
- }
- (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
- // CommandLineFlags always returns a pointer that needs freeing.
- FREE_C_HEAP_ARRAY(char, value);
- if (free_this_too != NULL) {
- // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
- FREE_C_HEAP_ARRAY(char, free_this_too);
- }
- return true;
- }
- bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) {
- // range of acceptable characters spelled out for portability reasons
- #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
- #define BUFLEN 255
- char name[BUFLEN+1];
- char dummy;
- if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
- return set_bool_flag(name, false, origin);
- }
- if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
- return set_bool_flag(name, true, origin);
- }
- char punct;
- if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
- const char* value = strchr(arg, '=') + 1;
- Flag* flag = Flag::find_flag(name, strlen(name));
- if (flag != NULL && flag->is_ccstr()) {
- if (flag->ccstr_accumulates()) {
- return append_to_string_flag(name, value, origin);
- } else {
- if (value[0] == '\0') {
- value = NULL;
- }
- return set_string_flag(name, value, origin);
- }
- }
- }
- if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') {
- const char* value = strchr(arg, '=') + 1;
- // -XX:Foo:=xxx will reset the string flag to the given value.
- if (value[0] == '\0') {
- value = NULL;
- }
- return set_string_flag(name, value, origin);
- }
- #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
- #define SIGNED_NUMBER_RANGE "[-0123456789]"
- #define NUMBER_RANGE "[0123456789]"
- char value[BUFLEN + 1];
- char value2[BUFLEN + 1];
- if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
- // Looks like a floating-point number -- try again with more lenient format string
- if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
- return set_fp_numeric_flag(name, value, origin);
- }
- }
- #define VALUE_RANGE "[-kmgtKMGT0123456789]"
- if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
- return set_numeric_flag(name, value, origin);
- }
- return false;
- }
- void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
- assert(bldarray != NULL, "illegal argument");
- if (arg == NULL) {
- return;
- }
- int index = *count;
- // expand the array and add arg to the last element
- (*count)++;
- if (*bldarray == NULL) {
- *bldarray = NEW_C_HEAP_ARRAY(char*, *count);
- } else {
- *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count);
- }
- (*bldarray)[index] = strdup(arg);
- }
- void Arguments::build_jvm_args(const char* arg) {
- add_string(&_jvm_args_array, &_num_jvm_args, arg);
- }
- void Arguments::build_jvm_flags(const char* arg) {
- add_string(&_jvm_flags_array, &_num_jvm_flags, arg);
- }
- // utility function to return a string that concatenates all
- // strings in a given char** array
- const char* Arguments::build_resource_string(char** args, int count) {
- if (args == NULL || count == 0) {
- return NULL;
- }
- size_t length = strlen(args[0]) + 1; // add 1 for the null terminator
- for (int i = 1; i < count; i++) {
- length += strlen(args[i]) + 1; // add 1 for a space
- }
- char* s = NEW_RESOURCE_ARRAY(char, length);
- strcpy(s, args[0]);
- for (int j = 1; j < count; j++) {
- strcat(s, " ");
- strcat(s, args[j]);
- }
- return (const char*) s;
- }
- void Arguments::print_on(outputStream* st) {
- st->print_cr("VM Arguments:");
- if (num_jvm_flags() > 0) {
- st->print("jvm_flags: "); print_jvm_flags_on(st);
- }
- if (num_jvm_args() > 0) {
- st->print("jvm_args: "); print_jvm_args_on(st);
- }
- st->print_cr("java_command: %s", java_command() ? java_command() : "<unknown>");
- st->print_cr("Launcher Type: %s", _sun_java_launcher);
- }
- void Arguments::print_jvm_flags_on(outputStream* st) {
- if (_num_jvm_flags > 0) {
- for (int i=0; i < _num_jvm_flags; i++) {
- st->print("%s ", _jvm_flags_array[i]);
- }
- st->print_cr("");
- }
- }
- void Arguments::print_jvm_args_on(outputStream* st) {
- if (_num_jvm_args > 0) {
- for (int i=0; i < _num_jvm_args; i++) {
- st->print("%s ", _jvm_args_array[i]);
- }
- st->print_cr("");
- }
- }
- bool Arguments::process_argument(const char* arg,
- jboolean ignore_unrecognized, FlagValueOrigin origin) {
- JDK_Version since = JDK_Version();
- if (parse_argument(arg, origin) || ignore_unrecognized) {
- return true;
- }
- const char * const argname = *arg == '+' || *arg == '-' ? arg + 1 : arg;
- if (is_newly_obsolete(arg, &since)) {
- char version[256];
- since.to_string(version, sizeof(version));
- warning("ignoring option %s; support was removed in %s", argname, version);
- return true;
- }
- // For locked flags, report a custom error message if available.
- // Otherwise, report the standard unrecognized VM option.
- Flag* locked_flag = Flag::find_flag((char*)argname, strlen(argname), true);
- if (locked_flag != NULL) {
- char locked_message_buf[BUFLEN];
- locked_flag->get_locked_message(locked_message_buf, BUFLEN);
- if (strlen(locked_message_buf) == 0) {
- jio_fprintf(defaultStream::error_stream(),
- "Unrecognized VM option '%s'\n", argname);
- } else {
- jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
- }
- }
- // allow for commandline "commenting out" options like -XX:#+Verbose
- return arg[0] == '#';
- }
- bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) {
- FILE* stream = fopen(file_name, "rb");
- if (stream == NULL) {
- if (should_exist) {
- jio_fprintf(defaultStream::error_stream(),
- "Could not open settings file %s\n", file_name);
- return false;
- } else {
- return true;
- }
- }
- char token[1024];
- int pos = 0;
- bool in_white_space = true;
- bool in_comment = false;
- bool in_quote = false;
- char quote_c = 0;
- bool result = true;
- int c = getc(stream);
- while(c != EOF) {
- if (in_white_space) {
- if (in_comment) {
- if (c == '\n') in_comment = false;
- } else {
- if (c == '#') in_comment = true;
- else if (!isspace(c)) {
- in_white_space = false;
- token[pos++] = c;
- }
- }
- } else {
- if (c == '\n' || (!in_quote && isspace(c))) {
- // token ends at newline, or at unquoted whitespace
- // this allows a way to include spaces in string-valued options
- token[pos] = '\0';
- logOption(token);
- result &= process_argument(token, ignore_unrecognized, CONFIG_FILE);
- build_jvm_flags(token);
- pos = 0;
- in_white_space = true;
- in_quote = false;
- } else if (!in_quote && (c == '\'' || c == '"')) {
- in_quote = true;
- quote_c = c;
- } else if (in_quote && (c == quote_c)) {
- in_quote = false;
- } else {
- token[pos++] = c;
- }
- }
- c = getc(stream);
- }
- if (pos > 0) {
- token[pos] = '\0';
- result &= process_argument(token, ignore_unrecognized, CONFIG_FILE);
- build_jvm_flags(token);
- }
- fclose(stream);
- return result;
- }
- //=============================================================================================================
- // Parsing of properties (-D)
- const char* Arguments::get_property(const char* key) {
- return PropertyList_get_value(system_properties(), key);
- }
- bool Arguments::add_property(const char* prop) {
- const char* eq = strchr(prop, '=');
- char* key;
- // ns must be static--its address may be stored in a SystemProperty object.
- const static char ns[1] = {0};
- char* value = (char *)ns;
- size_t key_len = (eq == NULL) ? strlen(prop) : (eq - prop);
- key = AllocateHeap(key_len + 1, "add_property");
- strncpy(key, prop, key_len);
- key[key_len] = '\0';
- if (eq != NULL) {
- size_t value_len = strlen(prop) - key_len - 1;
- value = AllocateHeap(value_len + 1, "add_property");
- strncpy(value, &prop[key_len + 1], value_len + 1);
- }
- if (strcmp(key, "java.compiler") == 0) {
- process_java_compiler_argument(value);
- FreeHeap(key);
- if (eq != NULL) {
- FreeHeap(value);
- }
- return true;
- } else if (strcmp(key, "sun.java.command") == 0) {
- _java_command = value;
- // Record value in Arguments, but let it get passed to Java.
- } else if (strcmp(key, "sun.java.launcher.pid") == 0) {
- // launcher.pid property is private and is processed
- // in process_sun_java_launcher_properties();
- // the sun.java.launcher property is passed on to the java application
- FreeHeap(key);
- if (eq != NULL) {
- FreeHeap(value);
- }
- return true;
- } else if (strcmp(key, "java.vendor.url.bug") == 0) {
- // save it in _java_vendor_url_bug, so JVM fatal error handler can access
- // its value without going through the property list or making a Java call.
- _java_vendor_url_bug = value;
- } else if (strcmp(key, "sun.boot.library.path") == 0) {
- PropertyList_unique_add(&_system_properties, key, value, true);
- return true;
- }
- // Create new property and add at the end of the list
- PropertyList_unique_add(&_system_properties, key, value);
- return true;
- }
- //===========================================================================================================
- // Setting int/mixed/comp mode flags
- void Arguments::set_mode_flags(Mode mode) {
- // Set up default values for all flags.
- // If you add a flag to any of the branches below,
- // add a default value for it here.
- set_java_compiler(false);
- _mode = mode;
- // Ensure Agent_OnLoad has the correct initial values.
- // This may not be the final mode; mode may change later in onload phase.
- PropertyList_unique_add(&_system_properties, "java.vm.info",
- (char*)VM_Version::vm_info_string(), false);
- UseInterpreter = true;
- UseCompiler = true;
- UseLoopCounter = true;
- #ifndef ZERO
- // Turn these off for mixed and comp. Leave them on for Zero.
- if (FLAG_IS_DEFAULT(UseFastAccessorMethods)) {
- UseFastAccessorMethods = (mode == _int);
- }
- if (FLAG_IS_DEFAULT(UseFastEmptyMethods)) {
- UseFastEmptyMethods = (mode == _int);
- }
- #endif
- // Default values may be platform/compiler dependent -
- // use the saved values
- ClipInlining = Arguments::_ClipInlining;
- AlwaysCompileLoopMethods = Arguments::_AlwaysCompileLoopMethods;
- UseOnStackReplacement = Arguments::_UseOnStackReplacement;
- BackgroundCompilation = Arguments::_BackgroundCompilation;
- // Change from defaults based on mode
- switch (mode) {
- default:
- ShouldNotReachHere();
- break;
- case _int:
- UseCompiler = false;
- UseLoopCounter = false;
- AlwaysCompileLoopMethods = false;
- UseOnStackReplacement = false;
- break;
- case _mixed:
- // same as default
- break;
- case _comp:
- UseInterpreter = false;
- BackgroundCompilation = false;
- ClipInlining = false;
- // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
- // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
- // compile a level 4 (C2) and then continue executing it.
- if (TieredCompilation) {
- Tier3InvokeNotifyFreqLog = 0;
- Tier4InvocationThreshold = 0;
- }
- break;
- }
- }
- // Conflict: required to use shared spaces (-Xshare:on), but
- // incompatible command line options were chosen.
- static void no_shared_spaces() {
- if (RequireSharedSpaces) {
- jio_fprintf(defaultStream::error_stream(),
- "Class data sharing is inconsistent with other specified options.\n");
- vm_exit_during_initialization("Unable to use shared archive.", NULL);
- } else {
- FLAG_SET_DEFAULT(UseSharedSpaces, false);
- }
- }
- void Arguments::set_tiered_flags() {
- // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
- if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
- FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
- }
- if (CompilationPolicyChoice < 2) {
- vm_exit_during_initialization(
- "Incompatible compilation policy selected", NULL);
- }
- // Increase the code cache size - tiered compiles a lot more.
- if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
- FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 2);
- }
- }
- #ifndef KERNEL
- static void disable_adaptive_size_policy(const char* collector_name) {
- if (UseAdaptiveSizePolicy) {
- if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
- warning("disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
- collector_name);
- }
- FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false);
- }
- }
- // If the user has chosen ParallelGCThreads > 0, we set UseParNewGC
- // if it's not explictly set or unset. If the user has chosen
- // UseParNewGC and not explicitly set ParallelGCThreads we
- // set it, unless this is a single cpu machine.
- void Arguments::set_parnew_gc_flags() {
- assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
- "control point invariant");
- assert(UseParNewGC, "Error");
- // Turn off AdaptiveSizePolicy for parnew until it is complete.
- disable_adaptive_size_policy("UseParNewGC");
- if (ParallelGCThreads == 0) {
- FLAG_SET_DEFAULT(ParallelGCThreads,
- Abstract_VM_Version::parallel_worker_threads());
- if (ParallelGCThreads == 1) {
- FLAG_SET_DEFAULT(UseParNewGC, false);
- FLAG_SET_DEFAULT(ParallelGCThreads, 0);
- }
- }
- if (UseParNewGC) {
- // CDS doesn't work with ParNew yet
- no_shared_spaces();
- // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively,
- // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration
- // we set them to 1024 and 1024.
- // See CR 6362902.
- if (FLAG_IS_DEFAULT(YoungPLABSize)) {
- FLAG_SET_DEFAULT(YoungPLABSize, (intx)1024);
- }
- if (FLAG_IS_DEFAULT(OldPLABSize)) {
- FLAG_SET_DEFAULT(OldPLABSize, (intx)1024);
- }
- // AlwaysTenure flag should make ParNew promote all at first collection.
- // See CR 6362902.
- if (AlwaysTenure) {
- FLAG_SET_CMDLINE(intx, MaxTenuringThreshold, 0);
- }
- // When using compressed oops, we use local overflow stacks,
- // rather than using a global overflow list chained through
- // the klass word of the object's pre-image.
- if (UseCompressedOops && !ParGCUseLocalOverflow) {
- if (!FLAG_IS_DEFAULT(ParGCUseLocalOverflow)) {
- warning("Forcing +ParGCUseLocalOverflow: needed if using compressed references");
- }
- FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
- }
- assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
- }
- }
- // Adjust some sizes to suit CMS and/or ParNew needs; these work well on
- // sparc/solaris for certain applications, but would gain from
- // further optimization and tuning efforts, and would almost
- // certainly gain from analysis of platform and environment.
- void Arguments::set_cms_and_parnew_gc_flags() {
- assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
- assert(UseConcMarkSweepGC, "CMS is expected to be on here");
- // If we are using CMS, we prefer to UseParNewGC,
- // unless explicitly forbidden.
- if (FLAG_IS_DEFAULT(UseParNewGC)) {
- FLAG_SET_ERGO(bool, UseParNewGC, true);
- }
- // Turn off AdaptiveSizePolicy for CMS until it is complete.
- disable_adaptive_size_policy("UseConcMarkSweepGC");
- // In either case, adjust ParallelGCThreads and/or UseParNewGC
- // as needed.
- if (UseParNewGC) {
- set_parnew_gc_flags();
- }
- // MaxHeapSize is aligned down in collectorPolicy
- size_t max_heap = align_size_down(MaxHeapSize,
- CardTableRS::ct_max_alignment_constraint());
- // Now make adjustments for CMS
- intx tenuring_default = (intx)6;
- size_t young_gen_per_worker = CMSYoungGenPerWorker;
- // Preferred young gen size for "short" pauses:
- // upper bound depends on # of threads and NewRatio.
- const uintx parallel_gc_threads =
- (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
- const size_t preferred_max_new_size_unaligned =
- MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
- size_t preferred_max_new_size =
- align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
- // Unless explicitly requested otherwise, size young gen
- // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
- // If either MaxNewSize or NewRatio is set on the command line,
- // assume the user is trying to set the size of the young gen.
- if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
- // Set MaxNewSize to our calculated preferred_max_new_size unless
- // NewSize was set on the command line and it is larger than
- // preferred_max_new_size.
- if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
- FLAG_SET_ERGO(uintx, MaxNewSize, MAX2((size_t) NewSize, preferred_max_new_size));
- } else {
- FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size);
- }
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
- }
- // Code along this path potentially sets NewSize and OldSize
- assert(max_heap >= InitialHeapSize, "Error");
- assert(max_heap >= NewSize, "Error");
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
- " initial_heap_size: " SIZE_FORMAT
- " max_heap: " SIZE_FORMAT,
- min_heap_size(), InitialHeapSize, max_heap);
- }
- size_t min_new = preferred_max_new_size;
- if (FLAG_IS_CMDLINE(NewSize)) {
- min_new = NewSize;
- }
- if (max_heap > min_new && min_heap_size() > min_new) {
- // Unless explicitly requested otherwise, make young gen
- // at least min_new, and at most preferred_max_new_size.
- if (FLAG_IS_DEFAULT(NewSize)) {
- FLAG_SET_ERGO(uintx, NewSize, MAX2((size_t) NewSize, min_new));
- FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, (size_t) NewSize));
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
- }
- }
- // Unless explicitly requested otherwise, size old gen
- // so it's NewRatio x of NewSize.
- if (FLAG_IS_DEFAULT(OldSize)) {
- if (max_heap > NewSize) {
- FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
- }
- }
- }
- }
- }
- // Unless explicitly requested otherwise, definitely
- // promote all objects surviving "tenuring_default" scavenges.
- if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
- FLAG_IS_DEFAULT(SurvivorRatio)) {
- FLAG_SET_ERGO(intx, MaxTenuringThreshold, tenuring_default);
- }
- // If we decided above (or user explicitly requested)
- // `promote all' (via MaxTenuringThreshold := 0),
- // prefer minuscule survivor spaces so as not to waste
- // space for (non-existent) survivors
- if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
- FLAG_SET_ERGO(intx, SurvivorRatio, MAX2((intx)1024, SurvivorRatio));
- }
- // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not,
- // set CMSParPromoteBlocksToClaim equal to OldPLABSize.
- // This is done in order to make ParNew+CMS configuration to work
- // with YoungPLABSize and OldPLABSize options.
- // See CR 6362902.
- if (!FLAG_IS_DEFAULT(OldPLABSize)) {
- if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) {
- // OldPLABSize is not the default value but CMSParPromoteBlocksToClaim
- // is. In this situtation let CMSParPromoteBlocksToClaim follow
- // the value (either from the command line or ergonomics) of
- // OldPLABSize. Following OldPLABSize is an ergonomics decision.
- FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, OldPLABSize);
- } else {
- // OldPLABSize and CMSParPromoteBlocksToClaim are both set.
- // CMSParPromoteBlocksToClaim is a collector-specific flag, so
- // we'll let it to take precedence.
- jio_fprintf(defaultStream::error_stream(),
- "Both OldPLABSize and CMSParPromoteBlocksToClaim"
- " options are specified for the CMS collector."
- " CMSParPromoteBlocksToClaim will take precedence.\n");
- }
- }
- if (!FLAG_IS_DEFAULT(ResizeOldPLAB) && !ResizeOldPLAB) {
- // OldPLAB sizing manually turned off: Use a larger default setting,
- // unless it was manually specified. This is because a too-low value
- // will slow down scavenges.
- if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) {
- FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, 50); // default value before 6631166
- }
- }
- // Overwrite OldPLABSize which is the variable we will internally use everywhere.
- FLAG_SET_ERGO(uintx, OldPLABSize, CMSParPromoteBlocksToClaim);
- // If either of the static initialization defaults have changed, note this
- // modification.
- if (!FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
- CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
- }
- if (PrintGCDetails && Verbose) {
- tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
- MarkStackSize / K, MarkStackSizeMax / K);
- tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
- }
- }
- #endif // KERNEL
- void set_object_alignment() {
- // Object alignment.
- assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
- MinObjAlignmentInBytes = ObjectAlignmentInBytes;
- assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small");
- MinObjAlignment = MinObjAlignmentInBytes / HeapWordSize;
- assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect");
- MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1;
- LogMinObjAlignmentInBytes = exact_log2(ObjectAlignmentInBytes);
- LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize;
- // Oop encoding heap max
- OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
- #ifndef KERNEL
- // Set CMS global values
- CompactibleFreeListSpace::set_cms_values();
- #endif // KERNEL
- }
- bool verify_object_alignment() {
- // Object alignment.
- if (!is_power_of_2(ObjectAlignmentInBytes)) {
- jio_fprintf(defaultStream::error_stream(),
- "error: ObjectAlignmentInBytes=%d must be power of 2\n",
- (int)ObjectAlignmentInBytes);
- return false;
- }
- if ((int)ObjectAlignmentInBytes < BytesPerLong) {
- jio_fprintf(defaultStream::error_stream(),
- "error: ObjectAlignmentInBytes=%d must be greater or equal %d\n",
- (int)ObjectAlignmentInBytes, BytesPerLong);
- return false;
- }
- // It does not make sense to have big object alignment
- // since a space lost due to alignment will be greater
- // then a saved space from compressed oops.
- if ((int)ObjectAlignmentInBytes > 256) {
- jio_fprintf(defaultStream::error_stream(),
- "error: ObjectAlignmentInBytes=%d must not be greater then 256\n",
- (int)ObjectAlignmentInBytes);
- return false;
- }
- // In case page size is very small.
- if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
- jio_fprintf(defaultStream::error_stream(),
- "error: ObjectAlignmentInBytes=%d must be less then page size %d\n",
- (int)ObjectAlignmentInBytes, os::vm_page_size());
- return false;
- }
- return true;
- }
- inline uintx max_heap_for_compressed_oops() {
- // Avoid sign flip.
- if (OopEncodingHeapMax < MaxPermSize + os::vm_page_size()) {
- return 0;
- }
- LP64_ONLY(return OopEncodingHeapMax - MaxPermSize - os::vm_page_size());
- NOT_LP64(ShouldNotReachHere(); return 0);
- }
- bool Arguments::should_auto_select_low_pause_collector() {
- if (UseAutoGCSelectPolicy &&
- !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
- (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
- if (PrintGCDetails) {
- // Cannot use gclog_or_tty yet.
- tty->print_cr("Automatic selection of the low pause collector"
- " based on pause goal of %d (ms)", MaxGCPauseMillis);
- }
- return true;
- }
- return false;
- }
- void Arguments::set_ergonomics_flags() {
- // Parallel GC is not compatible with sharing. If one specifies
- // that they want sharing explicitly, do not set ergonomics flags.
- if (DumpSharedSpaces || RequireSharedSpaces) {
- return;
- }
- if (os::is_server_class_machine()) {
- // If no other collector is requested explicitly,
- // let the VM select the collector based on
- // machine class and automatic selection policy.
- if (!UseSerialGC &&
- !UseConcMarkSweepGC &&
- !UseG1GC &&
- !UseParNewGC &&
- !DumpSharedSpaces &&
- FLAG_IS_DEFAULT(UseParallelGC)) {
- if (should_auto_select_low_pause_collector()) {
- FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
- } else {
- FLAG_SET_ERGO(bool, UseParallelGC, true);
- }
- no_s…
Large files files are truncated, but you can click here to view the full file