2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2015-01-05 12:07:37 -05:00
|
|
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* 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.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2014-08-12 17:29:00 -07:00
|
|
|
#include "classfile/classLoader.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/javaAssertions.hpp"
|
2014-05-07 14:16:45 -05:00
|
|
|
#include "classfile/stringTable.hpp"
|
2012-11-12 15:58:11 -05:00
|
|
|
#include "classfile/symbolTable.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "compiler/compilerOracle.hpp"
|
|
|
|
#include "memory/allocation.inline.hpp"
|
|
|
|
#include "memory/cardTableRS.hpp"
|
2013-09-11 16:25:02 +02:00
|
|
|
#include "memory/genCollectedHeap.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/referenceProcessor.hpp"
|
|
|
|
#include "memory/universe.inline.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "prims/jvmtiExport.hpp"
|
|
|
|
#include "runtime/arguments.hpp"
|
2014-09-05 12:36:37 -07:00
|
|
|
#include "runtime/arguments_ext.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/globals_extension.hpp"
|
|
|
|
#include "runtime/java.hpp"
|
2014-06-26 16:05:15 +02:00
|
|
|
#include "runtime/os.hpp"
|
2014-07-04 11:46:01 +02:00
|
|
|
#include "runtime/vm_version.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "services/management.hpp"
|
2012-06-28 17:03:16 -04:00
|
|
|
#include "services/memTracker.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/defaultStream.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2014-08-12 17:29:00 -07:00
|
|
|
#include "utilities/stringUtils.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/taskqueue.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
|
2013-09-11 16:25:02 +02:00
|
|
|
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
|
|
|
|
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-04-07 20:26:41 -07:00
|
|
|
// Note: This is a special bug reporting site for the JVM
|
2014-10-31 09:37:17 -07:00
|
|
|
#define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
|
2007-12-01 00:00:00 +00:00
|
|
|
#define DEFAULT_JAVA_LAUNCHER "generic"
|
|
|
|
|
2013-07-29 11:54:18 +04:00
|
|
|
#define UNSUPPORTED_GC_OPTION(gc) \
|
|
|
|
do { \
|
|
|
|
if (gc) { \
|
|
|
|
if (FLAG_IS_CMDLINE(gc)) { \
|
|
|
|
warning(#gc " is not supported in this VM. Using Serial GC."); \
|
|
|
|
} \
|
|
|
|
FLAG_SET_DEFAULT(gc, false); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
2015-03-03 18:01:27 +01:00
|
|
|
char** Arguments::_jvm_flags_array = NULL;
|
|
|
|
int Arguments::_num_jvm_flags = 0;
|
|
|
|
char** Arguments::_jvm_args_array = NULL;
|
|
|
|
int Arguments::_num_jvm_args = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
char* Arguments::_java_command = NULL;
|
|
|
|
SystemProperty* Arguments::_system_properties = NULL;
|
|
|
|
const char* Arguments::_gc_log_filename = NULL;
|
|
|
|
bool Arguments::_has_profile = false;
|
2013-09-11 16:25:02 +02:00
|
|
|
size_t Arguments::_conservative_max_heap_alignment = 0;
|
2015-03-03 18:01:27 +01:00
|
|
|
size_t Arguments::_min_heap_size = 0;
|
2014-09-16 16:02:32 +02:00
|
|
|
uintx Arguments::_min_heap_free_ratio = 0;
|
|
|
|
uintx Arguments::_max_heap_free_ratio = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
2014-01-30 14:12:22 -08:00
|
|
|
bool Arguments::_sun_java_launcher_is_altjvm = false;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// 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::_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;
|
|
|
|
|
2014-12-03 14:21:14 +00:00
|
|
|
char* Arguments::_ext_dirs = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-12-11 02:43:50 +01:00
|
|
|
// Check if head of 'option' matches 'name', and sets 'tail' to the remaining
|
|
|
|
// part of the option string.
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 02:43:50 +01:00
|
|
|
// Check if 'option' matches 'name'. No "tail" is allowed.
|
|
|
|
static bool match_option(const JavaVMOption *option, const char* name) {
|
|
|
|
const char* tail = NULL;
|
|
|
|
bool result = match_option(option, name, &tail);
|
|
|
|
if (tail != NULL && *tail == '\0') {
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return true if any of the strings in null-terminated array 'names' matches.
|
|
|
|
// If tail_allowed is true, then the tail must begin with a colon; otherwise,
|
|
|
|
// the option must match exactly.
|
|
|
|
static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
|
|
|
|
bool tail_allowed) {
|
|
|
|
for (/* empty */; *names != NULL; ++names) {
|
|
|
|
if (match_option(option, *names, tail)) {
|
|
|
|
if (**tail == '\0' || tail_allowed && **tail == ':') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
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) {
|
2014-01-30 14:12:22 -08:00
|
|
|
// See if sun.java.launcher, sun.java.launcher.is_altjvm or
|
|
|
|
// sun.java.launcher.pid is defined.
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2014-01-30 14:12:22 -08:00
|
|
|
if (match_option(option, "-Dsun.java.launcher.is_altjvm=", &tail)) {
|
|
|
|
if (strcmp(tail, "true") == 0) {
|
|
|
|
_sun_java_launcher_is_altjvm = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
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));
|
|
|
|
|
2014-01-23 14:47:23 +01:00
|
|
|
// Following are JVMTI agent writable properties.
|
2007-12-01 00:00:00 +00:00
|
|
|
// Properties values are set to NULL and they are
|
|
|
|
// os specific they are initialized in os::init_system_properties_values().
|
|
|
|
_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, _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();
|
|
|
|
}
|
|
|
|
|
2010-09-30 12:05:08 -04:00
|
|
|
|
|
|
|
// Update/Initialize System properties after JDK version number is known
|
|
|
|
void Arguments::init_version_specific_system_properties() {
|
2010-11-05 09:32:08 -04:00
|
|
|
enum { bufsz = 16 };
|
|
|
|
char buffer[bufsz];
|
|
|
|
const char* spec_vendor = "Sun Microsystems Inc.";
|
|
|
|
uint32_t spec_version = 0;
|
|
|
|
|
2014-06-11 09:58:23 -04:00
|
|
|
spec_vendor = "Oracle Corporation";
|
|
|
|
spec_version = JDK_Version::current().major_version();
|
2010-11-05 09:32:08 -04:00
|
|
|
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));
|
2010-09-30 12:05:08 -04:00
|
|
|
}
|
|
|
|
|
2008-07-28 14:07:44 -04:00
|
|
|
/**
|
|
|
|
* 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.
|
2015-03-18 17:45:47 -04:00
|
|
|
* But now that HSX is no longer supported only options with a future
|
|
|
|
* accept_until value need to be listed, and the list can be pruned
|
|
|
|
* on each major release.
|
2008-07-28 14:07:44 -04:00
|
|
|
*/
|
|
|
|
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[] = {
|
2014-01-24 15:26:56 +04:00
|
|
|
{ "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-03-19 11:37:58 -07:00
|
|
|
{ "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-04-03 09:28:28 +00:00
|
|
|
{ "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-05-13 11:25:17 +02:00
|
|
|
{ "BackEdgeThreshold", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-05-15 17:38:50 -04:00
|
|
|
{ "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-08-07 12:18:58 -07:00
|
|
|
{ "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-10-24 14:25:46 +02:00
|
|
|
{ "NmethodSweepFraction", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "NmethodSweepCheckInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "CodeCacheMinimumFreeSpace", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2014-08-12 10:48:55 -04:00
|
|
|
#ifndef ZERO
|
|
|
|
{ "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
#endif // ZERO
|
2014-11-13 19:12:28 +03:00
|
|
|
{ "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2015-03-04 16:35:58 -05:00
|
|
|
{ "AdaptiveSizePausePolicy", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
|
|
|
{ "ParallelGCRetainPLAB", JDK_Version::jdk(9), JDK_Version::jdk(10) },
|
2008-07-28 14:07:44 -04:00
|
|
|
{ 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) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int i = 0;
|
2008-07-28 14:07:44 -04:00
|
|
|
assert(version != NULL, "Must provide a version buffer");
|
|
|
|
while (obsolete_jvm_flags[i].name != NULL) {
|
|
|
|
const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
|
2007-12-01 00:00:00 +00:00
|
|
|
// <flag>=xxx form
|
|
|
|
// [-|+]<flag> form
|
2014-11-14 13:09:53 -05:00
|
|
|
size_t len = strlen(flag_status.name);
|
|
|
|
if (((strncmp(flag_status.name, s, len) == 0) &&
|
|
|
|
(strlen(s) == len)) ||
|
2007-12-01 00:00:00 +00:00
|
|
|
((s[0] == '+' || s[0] == '-') &&
|
2014-11-14 13:09:53 -05:00
|
|
|
(strncmp(flag_status.name, &s[1], len) == 0) &&
|
|
|
|
(strlen(&s[1]) == len))) {
|
2008-07-28 14:07:44 -04:00
|
|
|
if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
|
|
|
|
*version = flag_status.obsoleted_in;
|
|
|
|
return true;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructs the system class path (aka boot class path) from the following
|
|
|
|
// components, in order:
|
|
|
|
//
|
|
|
|
// prefix // from -Xbootclasspath/p:...
|
|
|
|
// base // from os::get_system_properties() or -Xbootclasspath=
|
|
|
|
// suffix // from -Xbootclasspath/a:...
|
|
|
|
//
|
|
|
|
// 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);
|
2009-01-21 11:14:19 -05:00
|
|
|
inline void add_suffix_to_prefix(const char* suffix);
|
2007-12-01 00:00:00 +00:00
|
|
|
inline void add_suffix(const char* suffix);
|
|
|
|
inline void reset_path(const char* base);
|
|
|
|
|
|
|
|
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]; }
|
|
|
|
|
|
|
|
// 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_base, // the default sysclasspath
|
|
|
|
_scp_suffix, // from -Xbootclasspath/a:...
|
|
|
|
_scp_nitems // the number of items, must be last.
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* _items[_scp_nitems];
|
|
|
|
};
|
|
|
|
|
|
|
|
SysClassPath::SysClassPath(const char* base) {
|
|
|
|
memset(_items, 0, sizeof(_items));
|
|
|
|
_items[_scp_base] = base;
|
|
|
|
}
|
|
|
|
|
|
|
|
SysClassPath::~SysClassPath() {
|
|
|
|
// Free everything except the base.
|
|
|
|
for (int i = 0; i < _scp_nitems; ++i) {
|
|
|
|
if (i != _scp_base) reset_item_at(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-01-21 11:14:19 -05:00
|
|
|
inline void SysClassPath::add_suffix_to_prefix(const char* suffix) {
|
|
|
|
_items[_scp_prefix] = add_to_path(_items[_scp_prefix], suffix, false);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
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) {
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, _items[index]);
|
2007-12-01 00:00:00 +00:00
|
|
|
_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
|
|
|
|
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.
|
2012-06-28 17:03:16 -04:00
|
|
|
char* cp = NEW_C_HEAP_ARRAY(char, total_len, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
2012-06-28 17:03:16 -04:00
|
|
|
cp = NEW_C_HEAP_ARRAY(char, len, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
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) {
|
2012-06-28 17:03:16 -04:00
|
|
|
cp = NEW_C_HEAP_ARRAY(char, len, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
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
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, path);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2012-06-28 17:03:16 -04:00
|
|
|
cp = REALLOC_C_HEAP_ARRAY(char, path, len, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
2012-06-28 17:03:16 -04:00
|
|
|
char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
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) {
|
2012-06-28 17:03:16 -04:00
|
|
|
char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
|
|
|
|
path = add_to_path(path, jarpath, false);
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, jarpath);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, dbuf);
|
2007-12-01 00:00:00 +00:00
|
|
|
os::closedir(dir);
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parses a memory size specification string.
|
2008-12-15 13:58:57 -08:00
|
|
|
static bool atomull(const char *s, julong* result) {
|
|
|
|
julong n = 0;
|
2014-05-15 20:16:14 -07:00
|
|
|
int args_read = 0;
|
|
|
|
bool is_hex = false;
|
|
|
|
// Skip leading 0[xX] for hexadecimal
|
|
|
|
if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
|
|
|
|
s += 2;
|
|
|
|
is_hex = true;
|
|
|
|
args_read = sscanf(s, JULONG_FORMAT_X, &n);
|
|
|
|
} else {
|
|
|
|
args_read = sscanf(s, JULONG_FORMAT, &n);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if (args_read != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-05-15 20:16:14 -07:00
|
|
|
while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
2008-12-15 13:58:57 -08:00
|
|
|
// Check for overflow.
|
|
|
|
if (*result/((julong)G * K) != n) return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
case 'G': case 'g':
|
|
|
|
*result = n * G;
|
2008-12-15 13:58:57 -08:00
|
|
|
if (*result/G != n) return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
case 'M': case 'm':
|
|
|
|
*result = n * M;
|
2008-12-15 13:58:57 -08:00
|
|
|
if (*result/M != n) return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
case 'K': case 'k':
|
|
|
|
*result = n * K;
|
2008-12-15 13:58:57 -08:00
|
|
|
if (*result/K != n) return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
case '\0':
|
|
|
|
*result = n;
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-15 13:58:57 -08:00
|
|
|
Arguments::ArgsRange Arguments::check_memory_size(julong size, julong min_size) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (size < min_size) return arg_too_small;
|
|
|
|
// Check that size will fit in a size_t (only relevant on 32-bit)
|
2008-12-15 13:58:57 -08:00
|
|
|
if (size > max_uintx) return arg_too_big;
|
2007-12-01 00:00:00 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return CommandLineFlags::boolAtPut(name, &value, origin);
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
double v;
|
|
|
|
if (sscanf(value, "%lf", &v) != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
|
2008-12-15 13:58:57 -08:00
|
|
|
julong v;
|
2007-12-01 00:00:00 +00:00
|
|
|
intx intx_v;
|
|
|
|
bool is_neg = false;
|
2008-12-15 13:58:57 -08:00
|
|
|
// Check the sign first since atomull() parses only unsigned values.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (*value == '-') {
|
|
|
|
if (!CommandLineFlags::intxAt(name, &intx_v)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
value++;
|
|
|
|
is_neg = true;
|
|
|
|
}
|
2008-12-15 13:58:57 -08:00
|
|
|
if (!atomull(value, &v)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-10-28 16:25:51 -04:00
|
|
|
uint64_t uint64_t_v = (uint64_t) v;
|
|
|
|
if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-11 14:03:06 +02:00
|
|
|
size_t size_t_v = (size_t) v;
|
|
|
|
if (!is_neg && CommandLineFlags::size_tAtPut(name, &size_t_v, origin)) {
|
|
|
|
return true;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
|
|
|
|
// Contract: CommandLineFlags always returns a pointer that needs freeing.
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, value);
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
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 {
|
2012-06-28 17:03:16 -04:00
|
|
|
char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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.
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, value);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (free_this_too != NULL) {
|
|
|
|
// CommandLineFlags made its own copy, so I must delete my own temp. buffer.
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(char, free_this_too);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-15 20:16:14 -07:00
|
|
|
#define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-02 22:35:15 +02:00
|
|
|
int new_count = *count + 1;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// expand the array and add arg to the last element
|
|
|
|
if (*bldarray == NULL) {
|
2013-05-02 22:35:15 +02:00
|
|
|
*bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2013-05-02 22:35:15 +02:00
|
|
|
*bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-08-11 10:18:09 -07:00
|
|
|
(*bldarray)[*count] = os::strdup_check_oom(arg);
|
2013-05-02 22:35:15 +02:00
|
|
|
*count = new_count;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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>");
|
2012-10-18 13:09:47 -04:00
|
|
|
if (_java_class_path != NULL) {
|
|
|
|
char* path = _java_class_path->value();
|
|
|
|
st->print_cr("java_class_path (initial): %s", strlen(path) == 0 ? "<not set>" : path );
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
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]);
|
|
|
|
}
|
2014-05-09 16:50:54 -04:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
2014-05-09 16:50:54 -04:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-28 14:07:44 -04:00
|
|
|
bool Arguments::process_argument(const char* arg,
|
2013-09-26 12:07:53 -07:00
|
|
|
jboolean ignore_unrecognized, Flag::Flags origin) {
|
2008-07-28 14:07:44 -04:00
|
|
|
|
|
|
|
JDK_Version since = JDK_Version();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-04-07 16:52:15 -07:00
|
|
|
if (parse_argument(arg, origin) || ignore_unrecognized) {
|
|
|
|
return true;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2011-04-07 16:52:15 -07:00
|
|
|
|
2013-02-01 14:14:54 -05:00
|
|
|
bool has_plus_minus = (*arg == '+' || *arg == '-');
|
|
|
|
const char* const argname = has_plus_minus ? arg + 1 : arg;
|
2011-04-07 16:52:15 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-20 16:46:39 -04:00
|
|
|
// For locked flags, report a custom error message if available.
|
|
|
|
// Otherwise, report the standard unrecognized VM option.
|
|
|
|
|
2013-02-01 14:14:54 -05:00
|
|
|
size_t arg_len;
|
|
|
|
const char* equal_sign = strchr(argname, '=');
|
|
|
|
if (equal_sign == NULL) {
|
|
|
|
arg_len = strlen(argname);
|
|
|
|
} else {
|
|
|
|
arg_len = equal_sign - argname;
|
|
|
|
}
|
|
|
|
|
2014-01-16 10:51:16 -08:00
|
|
|
Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
|
2013-02-01 14:14:54 -05:00
|
|
|
if (found_flag != NULL) {
|
2012-03-20 16:46:39 -04:00
|
|
|
char locked_message_buf[BUFLEN];
|
2013-02-01 14:14:54 -05:00
|
|
|
found_flag->get_locked_message(locked_message_buf, BUFLEN);
|
2012-03-20 16:46:39 -04:00
|
|
|
if (strlen(locked_message_buf) == 0) {
|
2013-02-01 14:14:54 -05:00
|
|
|
if (found_flag->is_bool() && !has_plus_minus) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Missing +/- setting for VM option '%s'\n", argname);
|
|
|
|
} else if (!found_flag->is_bool() && has_plus_minus) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Unexpected +/- setting in VM option '%s'\n", argname);
|
|
|
|
} else {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Improperly specified VM option '%s'\n", argname);
|
|
|
|
}
|
2012-03-20 16:46:39 -04:00
|
|
|
} else {
|
|
|
|
jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
|
|
|
|
}
|
2012-04-20 14:55:45 +01:00
|
|
|
} else {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Unrecognized VM option '%s'\n", argname);
|
2013-06-28 20:18:04 -07:00
|
|
|
Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
|
|
|
|
if (fuzzy_matched != NULL) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2014-11-14 13:09:53 -05:00
|
|
|
"Did you mean '%s%s%s'? ",
|
2013-06-28 20:18:04 -07:00
|
|
|
(fuzzy_matched->is_bool()) ? "(+/-)" : "",
|
2013-09-26 12:07:53 -07:00
|
|
|
fuzzy_matched->_name,
|
2013-06-28 20:18:04 -07:00
|
|
|
(fuzzy_matched->is_bool()) ? "" : "=<value>");
|
2014-11-14 13:09:53 -05:00
|
|
|
if (is_newly_obsolete(fuzzy_matched->_name, &since)) {
|
|
|
|
char version[256];
|
|
|
|
since.to_string(version, sizeof(version));
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Warning: support for %s was removed in %s\n",
|
|
|
|
fuzzy_matched->_name,
|
|
|
|
version);
|
2013-06-28 20:18:04 -07:00
|
|
|
}
|
2012-03-20 16:46:39 -04:00
|
|
|
}
|
2014-12-17 18:09:24 +01:00
|
|
|
}
|
2012-03-20 16:46:39 -04:00
|
|
|
|
2011-04-07 16:52:15 -07:00
|
|
|
// allow for commandline "commenting out" options like -XX:#+Verbose
|
|
|
|
return arg[0] == '#';
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2012-06-08 12:49:12 -04:00
|
|
|
while(c != EOF && pos < (int)(sizeof(token)-1)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
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);
|
2013-09-26 12:07:53 -07:00
|
|
|
result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
|
2007-12-01 00:00:00 +00:00
|
|
|
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';
|
2013-09-26 12:07:53 -07:00
|
|
|
result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
|
2007-12-01 00:00:00 +00:00
|
|
|
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);
|
2012-06-28 17:03:16 -04:00
|
|
|
key = AllocateHeap(key_len + 1, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
strncpy(key, prop, key_len);
|
|
|
|
key[key_len] = '\0';
|
|
|
|
|
|
|
|
if (eq != NULL) {
|
|
|
|
size_t value_len = strlen(prop) - key_len - 1;
|
2012-06-28 17:03:16 -04:00
|
|
|
value = AllocateHeap(value_len + 1, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
2009-04-01 16:38:01 -04:00
|
|
|
} else if (strcmp(key, "sun.java.command") == 0) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_java_command = value;
|
|
|
|
|
2011-01-12 15:44:16 +00:00
|
|
|
// Record value in Arguments, but let it get passed to Java.
|
2014-01-30 14:12:22 -08:00
|
|
|
} else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0 ||
|
|
|
|
strcmp(key, "sun.java.launcher.pid") == 0) {
|
|
|
|
// sun.java.launcher.is_altjvm and sun.java.launcher.pid property are
|
|
|
|
// private and are processed in process_sun_java_launcher_properties();
|
2007-12-01 00:00:00 +00:00
|
|
|
// the sun.java.launcher property is passed on to the java application
|
|
|
|
FreeHeap(key);
|
|
|
|
if (eq != NULL) {
|
|
|
|
FreeHeap(value);
|
|
|
|
}
|
|
|
|
return true;
|
2009-04-01 16:38:01 -04:00
|
|
|
} else if (strcmp(key, "java.vendor.url.bug") == 0) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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;
|
2009-04-01 16:38:01 -04:00
|
|
|
} else if (strcmp(key, "sun.boot.library.path") == 0) {
|
|
|
|
PropertyList_unique_add(&_system_properties, key, value, true);
|
|
|
|
return true;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// 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",
|
2011-05-04 19:16:49 -04:00
|
|
|
(char*)VM_Version::vm_info_string(), false);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
UseInterpreter = true;
|
|
|
|
UseCompiler = true;
|
|
|
|
UseLoopCounter = true;
|
|
|
|
|
|
|
|
// 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;
|
2011-12-13 17:10:52 -08:00
|
|
|
// 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;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-19 11:04:23 -04:00
|
|
|
#if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
|
2007-12-01 00:00:00 +00:00
|
|
|
// Conflict: required to use shared spaces (-Xshare:on), but
|
|
|
|
// incompatible command line options were chosen.
|
|
|
|
|
2014-08-12 17:29:00 -07:00
|
|
|
static void no_shared_spaces(const char* message) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (RequireSharedSpaces) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Class data sharing is inconsistent with other specified options.\n");
|
2014-08-12 17:29:00 -07:00
|
|
|
vm_exit_during_initialization("Unable to use shared archive.", message);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
FLAG_SET_DEFAULT(UseSharedSpaces, false);
|
|
|
|
}
|
|
|
|
}
|
2013-09-19 11:04:23 -04:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-02-06 18:16:55 +01:00
|
|
|
// Returns threshold scaled with the value of scale.
|
|
|
|
// If scale < 0.0, threshold is returned without scaling.
|
2015-01-21 10:51:35 +01:00
|
|
|
intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
|
2015-02-06 18:16:55 +01:00
|
|
|
if (scale == 1.0 || scale < 0.0) {
|
2015-01-21 10:51:35 +01:00
|
|
|
return threshold;
|
|
|
|
} else {
|
|
|
|
return (intx)(threshold * scale);
|
|
|
|
}
|
2014-10-15 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
2015-02-06 18:16:55 +01:00
|
|
|
// Returns freq_log scaled with the value of scale.
|
|
|
|
// Returned values are in the range of [0, InvocationCounter::number_of_count_bits + 1].
|
|
|
|
// If scale < 0.0, freq_log is returned without scaling.
|
2015-01-21 10:51:35 +01:00
|
|
|
intx Arguments::scaled_freq_log(intx freq_log, double scale) {
|
2015-02-06 18:16:55 +01:00
|
|
|
// Check if scaling is necessary or if negative value was specified.
|
2015-01-21 10:51:35 +01:00
|
|
|
if (scale == 1.0 || scale < 0.0) {
|
|
|
|
return freq_log;
|
|
|
|
}
|
2015-02-06 18:16:55 +01:00
|
|
|
// Check values to avoid calculating log2 of 0.
|
|
|
|
if (scale == 0.0 || freq_log == 0) {
|
|
|
|
return 0;
|
2015-01-21 10:51:35 +01:00
|
|
|
}
|
|
|
|
// Determine the maximum notification frequency value currently supported.
|
|
|
|
// The largest mask value that the interpreter/C1 can handle is
|
|
|
|
// of length InvocationCounter::number_of_count_bits. Mask values are always
|
|
|
|
// one bit shorter then the value of the notification frequency. Set
|
|
|
|
// max_freq_bits accordingly.
|
|
|
|
intx max_freq_bits = InvocationCounter::number_of_count_bits + 1;
|
2015-02-06 18:16:55 +01:00
|
|
|
intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale);
|
2014-10-15 14:00:41 +02:00
|
|
|
if (scaled_freq == 0) {
|
2015-02-06 18:16:55 +01:00
|
|
|
// Return 0 right away to avoid calculating log2 of 0.
|
2014-10-15 14:00:41 +02:00
|
|
|
return 0;
|
2015-02-06 18:16:55 +01:00
|
|
|
} else if (scaled_freq > nth_bit(max_freq_bits)) {
|
2015-01-21 10:51:35 +01:00
|
|
|
return max_freq_bits;
|
2014-10-15 14:00:41 +02:00
|
|
|
} else {
|
|
|
|
return log2_intptr(scaled_freq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-03 17:51:07 -07:00
|
|
|
void Arguments::set_tiered_flags() {
|
2011-03-04 15:14:16 -08:00
|
|
|
// With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
|
2010-09-03 17:51:07 -07:00
|
|
|
if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
|
2011-03-04 15:14:16 -08:00
|
|
|
FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
if (CompilationPolicyChoice < 2) {
|
|
|
|
vm_exit_during_initialization(
|
|
|
|
"Incompatible compilation policy selected", NULL);
|
|
|
|
}
|
2010-11-02 16:02:46 -07:00
|
|
|
// Increase the code cache size - tiered compiles a lot more.
|
2010-09-03 17:51:07 -07:00
|
|
|
if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
|
2014-12-11 13:11:53 -08:00
|
|
|
FLAG_SET_ERGO(uintx, ReservedCodeCacheSize,
|
|
|
|
MIN2(CODE_CACHE_DEFAULT_LIMIT, ReservedCodeCacheSize * 5));
|
2014-09-17 08:00:07 +02:00
|
|
|
}
|
|
|
|
// Enable SegmentedCodeCache if TieredCompilation is enabled and ReservedCodeCacheSize >= 240M
|
|
|
|
if (FLAG_IS_DEFAULT(SegmentedCodeCache) && ReservedCodeCacheSize >= 240*M) {
|
|
|
|
FLAG_SET_ERGO(bool, SegmentedCodeCache, true);
|
|
|
|
|
2014-10-02 12:58:37 +02:00
|
|
|
if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
|
2014-10-02 12:55:40 -07:00
|
|
|
// Multiply sizes by 5 but fix NonNMethodCodeHeapSize (distribute among non-profiled and profiled code heap)
|
2014-10-02 12:58:37 +02:00
|
|
|
if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) {
|
2014-10-02 12:55:40 -07:00
|
|
|
FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, ProfiledCodeHeapSize * 5 + NonNMethodCodeHeapSize * 2);
|
2014-10-02 12:58:37 +02:00
|
|
|
}
|
|
|
|
if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) {
|
2014-10-02 12:55:40 -07:00
|
|
|
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, NonProfiledCodeHeapSize * 5 + NonNMethodCodeHeapSize * 2);
|
2014-10-02 12:58:37 +02:00
|
|
|
}
|
|
|
|
// Check consistency of code heap sizes
|
2014-10-02 12:55:40 -07:00
|
|
|
if ((NonNMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) {
|
2014-10-02 12:58:37 +02:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2014-10-02 12:55:40 -07:00
|
|
|
"Invalid code heap sizes: NonNMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n",
|
|
|
|
NonNMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K,
|
|
|
|
(NonNMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K);
|
2014-10-02 12:58:37 +02:00
|
|
|
vm_exit(1);
|
|
|
|
}
|
2014-09-17 08:00:07 +02:00
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
2013-05-08 15:08:01 -07:00
|
|
|
if (!UseInterpreter) { // -Xcomp
|
|
|
|
Tier3InvokeNotifyFreqLog = 0;
|
|
|
|
Tier4InvocationThreshold = 0;
|
|
|
|
}
|
2014-10-15 14:00:41 +02:00
|
|
|
|
2015-01-21 10:51:35 +01:00
|
|
|
if (CompileThresholdScaling < 0) {
|
|
|
|
vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL);
|
|
|
|
}
|
|
|
|
|
2015-02-06 18:16:55 +01:00
|
|
|
// Scale tiered compilation thresholds.
|
|
|
|
// CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves compilation thresholds unchanged.
|
|
|
|
if (!FLAG_IS_DEFAULT(CompileThresholdScaling) && CompileThresholdScaling > 0.0) {
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, Tier0InvokeNotifyFreqLog, scaled_freq_log(Tier0InvokeNotifyFreqLog));
|
|
|
|
FLAG_SET_ERGO(intx, Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog));
|
2014-10-15 14:00:41 +02:00
|
|
|
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, Tier3InvocationThreshold, scaled_compile_threshold(Tier3InvocationThreshold));
|
|
|
|
FLAG_SET_ERGO(intx, Tier3MinInvocationThreshold, scaled_compile_threshold(Tier3MinInvocationThreshold));
|
|
|
|
FLAG_SET_ERGO(intx, Tier3CompileThreshold, scaled_compile_threshold(Tier3CompileThreshold));
|
|
|
|
FLAG_SET_ERGO(intx, Tier3BackEdgeThreshold, scaled_compile_threshold(Tier3BackEdgeThreshold));
|
2014-10-15 14:00:41 +02:00
|
|
|
|
|
|
|
// Tier2{Invocation,MinInvocation,Compile,Backedge}Threshold should be scaled here
|
|
|
|
// once these thresholds become supported.
|
|
|
|
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, Tier2InvokeNotifyFreqLog, scaled_freq_log(Tier2InvokeNotifyFreqLog));
|
|
|
|
FLAG_SET_ERGO(intx, Tier2BackedgeNotifyFreqLog, scaled_freq_log(Tier2BackedgeNotifyFreqLog));
|
2014-10-15 14:00:41 +02:00
|
|
|
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, Tier3InvokeNotifyFreqLog, scaled_freq_log(Tier3InvokeNotifyFreqLog));
|
|
|
|
FLAG_SET_ERGO(intx, Tier3BackedgeNotifyFreqLog, scaled_freq_log(Tier3BackedgeNotifyFreqLog));
|
2014-10-15 14:00:41 +02:00
|
|
|
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, Tier23InlineeNotifyFreqLog, scaled_freq_log(Tier23InlineeNotifyFreqLog));
|
2014-10-15 14:00:41 +02:00
|
|
|
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, Tier4InvocationThreshold, scaled_compile_threshold(Tier4InvocationThreshold));
|
|
|
|
FLAG_SET_ERGO(intx, Tier4MinInvocationThreshold, scaled_compile_threshold(Tier4MinInvocationThreshold));
|
|
|
|
FLAG_SET_ERGO(intx, Tier4CompileThreshold, scaled_compile_threshold(Tier4CompileThreshold));
|
|
|
|
FLAG_SET_ERGO(intx, Tier4BackEdgeThreshold, scaled_compile_threshold(Tier4BackEdgeThreshold));
|
2014-10-15 14:00:41 +02:00
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
|
2014-05-08 12:49:21 +02:00
|
|
|
/**
|
|
|
|
* Returns the minimum number of compiler threads needed to run the JVM. The following
|
|
|
|
* configurations are possible.
|
|
|
|
*
|
|
|
|
* 1) The JVM is build using an interpreter only. As a result, the minimum number of
|
|
|
|
* compiler threads is 0.
|
|
|
|
* 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As
|
|
|
|
* a result, either C1 or C2 is used, so the minimum number of compiler threads is 1.
|
|
|
|
* 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However,
|
|
|
|
* the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only
|
|
|
|
* C1 can be used, so the minimum number of compiler threads is 1.
|
|
|
|
* 4) The JVM is build using the compilers and tiered compilation is enabled. The option
|
|
|
|
* 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,
|
|
|
|
* the minimum number of compiler threads is 2.
|
|
|
|
*/
|
|
|
|
int Arguments::get_min_number_of_compiler_threads() {
|
|
|
|
#if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK)
|
|
|
|
return 0; // case 1
|
|
|
|
#else
|
|
|
|
if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) {
|
|
|
|
return 1; // case 2 or case 3
|
|
|
|
}
|
|
|
|
return 2; // case 4 (tiered)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2012-01-25 21:14:11 -08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void Arguments::set_parnew_gc_flags() {
|
2009-10-28 16:25:51 -04:00
|
|
|
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
|
2008-06-05 15:57:56 -07:00
|
|
|
"control point invariant");
|
2014-11-27 21:02:13 +01:00
|
|
|
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
|
|
|
|
assert(UseParNewGC, "ParNew should always be used with CMS");
|
2008-02-22 17:17:14 -08:00
|
|
|
|
2012-12-30 08:47:52 +01:00
|
|
|
if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
|
|
|
|
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
|
|
|
|
assert(ParallelGCThreads > 0, "We should always have at least one thread by default");
|
|
|
|
} else if (ParallelGCThreads == 0) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n");
|
|
|
|
vm_exit(1);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-12-30 08:47:52 +01:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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");
|
2009-04-02 15:57:41 -07:00
|
|
|
}
|
2012-12-30 08:47:52 +01:00
|
|
|
FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-12-30 08:47:52 +01:00
|
|
|
assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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() {
|
2009-10-28 16:25:51 -04:00
|
|
|
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
|
2008-02-22 17:17:14 -08:00
|
|
|
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
|
2014-11-27 21:02:13 +01:00
|
|
|
assert(UseParNewGC, "ParNew should always be used with CMS");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-10-10 14:35:58 -04:00
|
|
|
// Turn off AdaptiveSizePolicy by default for cms until it is complete.
|
2012-01-25 21:14:11 -08:00
|
|
|
disable_adaptive_size_policy("UseConcMarkSweepGC");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-11-27 21:02:13 +01:00
|
|
|
set_parnew_gc_flags();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-03-16 10:37:08 -07:00
|
|
|
size_t max_heap = align_size_down(MaxHeapSize,
|
|
|
|
CardTableRS::ct_max_alignment_constraint());
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Now make adjustments for CMS
|
2011-03-16 10:37:08 -07:00
|
|
|
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.
|
2007-12-01 00:00:00 +00:00
|
|
|
const uintx parallel_gc_threads =
|
|
|
|
(ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
|
|
|
|
const size_t preferred_max_new_size_unaligned =
|
2011-03-16 10:37:08 -07:00
|
|
|
MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
|
|
|
|
size_t preferred_max_new_size =
|
2007-12-01 00:00:00 +00:00
|
|
|
align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
|
|
|
|
|
|
|
|
// Unless explicitly requested otherwise, size young gen
|
2011-03-16 10:37:08 -07:00
|
|
|
// for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
|
2009-08-02 18:44:36 -07:00
|
|
|
|
|
|
|
// 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.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2009-10-28 16:25:51 -04:00
|
|
|
if (PrintGCDetails && Verbose) {
|
2008-03-02 16:10:12 -08:00
|
|
|
// Too early to use gclog_or_tty
|
2011-03-16 10:37:08 -07:00
|
|
|
tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
|
2009-08-02 18:44:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Code along this path potentially sets NewSize and OldSize
|
2009-10-28 16:25:51 -04:00
|
|
|
if (PrintGCDetails && Verbose) {
|
2008-03-02 16:10:12 -08:00
|
|
|
// 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,
|
2009-10-28 16:25:51 -04:00
|
|
|
min_heap_size(), InitialHeapSize, max_heap);
|
2008-03-02 16:10:12 -08:00
|
|
|
}
|
2011-03-16 10:37:08 -07:00
|
|
|
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) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Unless explicitly requested otherwise, make young gen
|
|
|
|
// at least min_new, and at most preferred_max_new_size.
|
|
|
|
if (FLAG_IS_DEFAULT(NewSize)) {
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
|
|
|
|
FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
|
2009-10-28 16:25:51 -04:00
|
|
|
if (PrintGCDetails && Verbose) {
|
2008-03-02 16:10:12 -08:00
|
|
|
// Too early to use gclog_or_tty
|
2011-03-16 10:37:08 -07:00
|
|
|
tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
|
2008-03-02 16:10:12 -08:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// Unless explicitly requested otherwise, size old gen
|
2011-03-16 10:37:08 -07:00
|
|
|
// so it's NewRatio x of NewSize.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (FLAG_IS_DEFAULT(OldSize)) {
|
|
|
|
if (max_heap > NewSize) {
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
|
2009-10-28 16:25:51 -04:00
|
|
|
if (PrintGCDetails && Verbose) {
|
2008-03-02 16:10:12 -08:00
|
|
|
// Too early to use gclog_or_tty
|
2011-03-16 10:37:08 -07:00
|
|
|
tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
|
2008-03-02 16:10:12 -08:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Unless explicitly requested otherwise, definitely
|
|
|
|
// promote all objects surviving "tenuring_default" scavenges.
|
|
|
|
if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
|
|
|
|
FLAG_IS_DEFAULT(SurvivorRatio)) {
|
2012-10-03 20:31:41 +02:00
|
|
|
FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// 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) {
|
2013-02-07 15:51:25 +01:00
|
|
|
FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-12-17 18:09:24 +01:00
|
|
|
|
|
|
|
// OldPLABSize is interpreted in CMS as not the size of the PLAB in words,
|
|
|
|
// but rather the number of free blocks of a given size that are used when
|
|
|
|
// replenishing the local per-worker free list caches.
|
|
|
|
if (FLAG_IS_DEFAULT(OldPLABSize)) {
|
|
|
|
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.
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
|
2009-12-23 09:23:54 -08:00
|
|
|
} else {
|
2014-12-17 18:09:24 +01:00
|
|
|
FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
|
2009-12-23 09:23:54 -08:00
|
|
|
}
|
|
|
|
}
|
2014-12-17 18:09:24 +01:00
|
|
|
|
2009-12-23 09:23:54 -08:00
|
|
|
// If either of the static initialization defaults have changed, note this
|
|
|
|
// modification.
|
2014-12-17 18:09:24 +01:00
|
|
|
if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
|
2009-12-23 09:23:54 -08:00
|
|
|
CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
|
|
|
|
}
|
2010-02-24 07:00:33 -08:00
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
|
2014-05-09 16:50:54 -04:00
|
|
|
(unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
|
|
|
|
tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
|
2010-02-24 07:00:33 -08:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-05-27 18:01:56 -07:00
|
|
|
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;
|
|
|
|
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2010-05-27 18:01:56 -07:00
|
|
|
// Set CMS global values
|
|
|
|
CompactibleFreeListSpace::set_cms_values();
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2010-05-27 18:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool verify_object_alignment() {
|
|
|
|
// Object alignment.
|
|
|
|
if (!is_power_of_2(ObjectAlignmentInBytes)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2010-10-05 08:57:20 -07:00
|
|
|
"error: ObjectAlignmentInBytes=%d must be power of 2\n",
|
|
|
|
(int)ObjectAlignmentInBytes);
|
2010-05-27 18:01:56 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ((int)ObjectAlignmentInBytes < BytesPerLong) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2010-10-05 08:57:20 -07:00
|
|
|
"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(),
|
2013-01-08 13:38:11 -05:00
|
|
|
"error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
|
2010-10-05 08:57:20 -07:00
|
|
|
(int)ObjectAlignmentInBytes);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// In case page size is very small.
|
|
|
|
if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-01-08 13:38:11 -05:00
|
|
|
"error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
|
2010-10-05 08:57:20 -07:00
|
|
|
(int)ObjectAlignmentInBytes, os::vm_page_size());
|
2010-05-27 18:01:56 -07:00
|
|
|
return false;
|
|
|
|
}
|
2014-08-01 15:40:12 -07:00
|
|
|
if(SurvivorAlignmentInBytes == 0) {
|
|
|
|
SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
|
|
|
|
} else {
|
|
|
|
if (!is_power_of_2(SurvivorAlignmentInBytes)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"error: SurvivorAlignmentInBytes=%d must be power of 2\n",
|
|
|
|
(int)SurvivorAlignmentInBytes);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (SurvivorAlignmentInBytes < ObjectAlignmentInBytes) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"error: SurvivorAlignmentInBytes=%d must be greater than ObjectAlignmentInBytes=%d \n",
|
|
|
|
(int)SurvivorAlignmentInBytes, (int)ObjectAlignmentInBytes);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2010-05-27 18:01:56 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-26 09:31:43 +02:00
|
|
|
size_t Arguments::max_heap_for_compressed_oops() {
|
2010-11-12 09:51:43 -08:00
|
|
|
// Avoid sign flip.
|
2013-08-15 20:04:10 -04:00
|
|
|
assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
|
2013-09-11 16:25:02 +02:00
|
|
|
// We need to fit both the NULL page and the heap into the memory budget, while
|
|
|
|
// keeping alignment constraints of the heap. To guarantee the latter, as the
|
|
|
|
// NULL page is located before the heap, we pad the NULL page to the conservative
|
|
|
|
// maximum alignment that the GC may ever impose upon the heap.
|
|
|
|
size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
|
2013-10-21 18:56:20 +02:00
|
|
|
_conservative_max_heap_alignment);
|
2013-09-11 16:25:02 +02:00
|
|
|
|
|
|
|
LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
|
2009-10-28 16:25:51 -04:00
|
|
|
NOT_LP64(ShouldNotReachHere(); return 0);
|
2008-04-29 19:31:29 -04:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
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"
|
2014-05-09 16:50:54 -04:00
|
|
|
" based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-12 08:33:57 +01:00
|
|
|
void Arguments::set_use_compressed_oops() {
|
|
|
|
#ifndef ZERO
|
|
|
|
#ifdef _LP64
|
|
|
|
// MaxHeapSize is not set up properly at this point, but
|
|
|
|
// the only value that can override MaxHeapSize if we are
|
|
|
|
// to use UseCompressedOops is InitialHeapSize.
|
|
|
|
size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
|
|
|
|
|
|
|
|
if (max_heap_size <= max_heap_for_compressed_oops()) {
|
|
|
|
#if !defined(COMPILER1) || defined(TIERED)
|
|
|
|
if (FLAG_IS_DEFAULT(UseCompressedOops)) {
|
|
|
|
FLAG_SET_ERGO(bool, UseCompressedOops, true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
|
|
|
|
warning("Max heap size too large for Compressed Oops");
|
|
|
|
FLAG_SET_DEFAULT(UseCompressedOops, false);
|
2013-08-12 17:37:02 +02:00
|
|
|
FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
|
2013-03-12 08:33:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // _LP64
|
|
|
|
#endif // ZERO
|
|
|
|
}
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
|
|
|
|
// NOTE: set_use_compressed_klass_ptrs() must be called after calling
|
|
|
|
// set_use_compressed_oops().
|
|
|
|
void Arguments::set_use_compressed_klass_ptrs() {
|
|
|
|
#ifndef ZERO
|
|
|
|
#ifdef _LP64
|
2013-08-12 17:37:02 +02:00
|
|
|
// UseCompressedOops must be on for UseCompressedClassPointers to be on.
|
2013-08-15 20:04:10 -04:00
|
|
|
if (!UseCompressedOops) {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
warning("UseCompressedClassPointers requires UseCompressedOops");
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
2013-08-12 17:37:02 +02:00
|
|
|
FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
|
2013-08-15 20:04:10 -04:00
|
|
|
} else {
|
2013-08-12 17:37:02 +02:00
|
|
|
// Turn on UseCompressedClassPointers too
|
|
|
|
if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
|
|
|
|
FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
|
|
|
|
}
|
|
|
|
// Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
|
|
|
|
warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
|
|
|
|
FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // _LP64
|
|
|
|
#endif // !ZERO
|
|
|
|
}
|
|
|
|
|
2013-09-11 16:25:02 +02:00
|
|
|
void Arguments::set_conservative_max_heap_alignment() {
|
|
|
|
// The conservative maximum required alignment for the heap is the maximum of
|
|
|
|
// the alignments imposed by several sources: any requirements from the heap
|
|
|
|
// itself, the collector policy and the maximum page size we may run the VM
|
|
|
|
// with.
|
|
|
|
size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
|
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
if (UseParallelGC) {
|
|
|
|
heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
|
|
|
|
} else if (UseG1GC) {
|
|
|
|
heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
2014-07-21 09:59:54 +02:00
|
|
|
_conservative_max_heap_alignment = MAX4(heap_alignment,
|
|
|
|
(size_t)os::vm_allocation_granularity(),
|
|
|
|
os::max_page_size(),
|
|
|
|
CollectorPolicy::compute_heap_alignment());
|
2013-09-11 16:25:02 +02:00
|
|
|
}
|
|
|
|
|
2014-09-04 16:53:27 -07:00
|
|
|
void Arguments::select_gc_ergonomically() {
|
2012-02-15 16:29:40 -08:00
|
|
|
if (os::is_server_class_machine()) {
|
2014-09-04 16:53:27 -07:00
|
|
|
if (should_auto_select_low_pause_collector()) {
|
|
|
|
FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
|
|
|
|
} else {
|
|
|
|
FLAG_SET_ERGO(bool, UseParallelGC, true);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-09-04 16:53:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments::select_gc() {
|
|
|
|
if (!gc_selected()) {
|
2015-03-02 11:08:09 +01:00
|
|
|
select_gc_ergonomically();
|
2014-09-04 16:53:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments::set_ergonomics_flags() {
|
|
|
|
select_gc();
|
|
|
|
|
2013-09-19 11:04:23 -04:00
|
|
|
#ifdef COMPILER2
|
|
|
|
// Shared spaces work fine with other GCs but causes bytecode rewriting
|
|
|
|
// to be disabled, which hurts interpreter performance and decreases
|
|
|
|
// server performance. When -server is specified, keep the default off
|
|
|
|
// unless it is asked for. Future work: either add bytecode rewriting
|
|
|
|
// at link time, or rewrite bytecodes in non-shared methods.
|
|
|
|
if (!DumpSharedSpaces && !RequireSharedSpaces &&
|
|
|
|
(FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
|
2014-08-12 17:29:00 -07:00
|
|
|
no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
|
2013-09-19 11:04:23 -04:00
|
|
|
}
|
|
|
|
#endif
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
|
2013-09-11 16:25:02 +02:00
|
|
|
set_conservative_max_heap_alignment();
|
|
|
|
|
2009-10-13 12:04:21 -07:00
|
|
|
#ifndef ZERO
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#ifdef _LP64
|
2013-03-12 08:33:57 +01:00
|
|
|
set_use_compressed_oops();
|
2013-08-15 20:04:10 -04:00
|
|
|
|
|
|
|
// set_use_compressed_klass_ptrs() must be called after calling
|
|
|
|
// set_use_compressed_oops().
|
|
|
|
set_use_compressed_klass_ptrs();
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
// Also checks that certain machines are slower with compressed oops
|
|
|
|
// in vm_version initialization code.
|
|
|
|
#endif // _LP64
|
2009-10-13 12:04:21 -07:00
|
|
|
#endif // !ZERO
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments::set_parallel_gc_flags() {
|
2008-06-05 15:57:56 -07:00
|
|
|
assert(UseParallelGC || UseParallelOldGC, "Error");
|
2012-02-02 16:05:17 -08:00
|
|
|
// Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
|
|
|
|
if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
|
|
|
|
FLAG_SET_DEFAULT(UseParallelOldGC, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-02-02 16:05:17 -08:00
|
|
|
FLAG_SET_DEFAULT(UseParallelGC, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// If no heap maximum was requested explicitly, use some reasonable fraction
|
|
|
|
// of the physical memory, up to a maximum of 1GB.
|
2013-01-09 09:48:58 +01:00
|
|
|
FLAG_SET_DEFAULT(ParallelGCThreads,
|
|
|
|
Abstract_VM_Version::parallel_worker_threads());
|
|
|
|
if (ParallelGCThreads == 0) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
|
|
|
|
vm_exit(1);
|
|
|
|
}
|
2008-02-22 17:17:14 -08:00
|
|
|
|
2014-01-29 23:17:05 +01:00
|
|
|
if (UseAdaptiveSizePolicy) {
|
|
|
|
// We don't want to limit adaptive heap sizing's freedom to adjust the heap
|
|
|
|
// unless the user actually sets these flags.
|
|
|
|
if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
|
|
|
|
FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
|
2014-09-16 16:02:32 +02:00
|
|
|
_min_heap_free_ratio = MinHeapFreeRatio;
|
2014-01-29 23:17:05 +01:00
|
|
|
}
|
|
|
|
if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
|
|
|
|
FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
|
2014-09-16 16:02:32 +02:00
|
|
|
_max_heap_free_ratio = MaxHeapFreeRatio;
|
2014-01-29 23:17:05 +01:00
|
|
|
}
|
|
|
|
}
|
2013-01-09 09:48:58 +01:00
|
|
|
|
|
|
|
// If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
|
|
|
|
// SurvivorRatio has been set, reset their default values to SurvivorRatio +
|
|
|
|
// 2. By doing this we make SurvivorRatio also work for Parallel Scavenger.
|
|
|
|
// See CR 6362902 for details.
|
|
|
|
if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
|
|
|
|
if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
|
|
|
|
FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-01-09 09:48:58 +01:00
|
|
|
if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
|
|
|
|
FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-01-09 09:48:58 +01:00
|
|
|
if (UseParallelOldGC) {
|
|
|
|
// Par compact uses lower default values since they are treated as
|
|
|
|
// minimums. These are different defaults because of the different
|
|
|
|
// interpretation and are not ergonomically set.
|
|
|
|
if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
|
|
|
|
FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
void Arguments::set_g1_gc_flags() {
|
|
|
|
assert(UseG1GC, "Error");
|
|
|
|
#ifdef COMPILER1
|
|
|
|
FastTLABRefill = false;
|
|
|
|
#endif
|
2014-10-02 11:22:02 +02:00
|
|
|
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
|
2008-06-05 15:57:56 -07:00
|
|
|
if (ParallelGCThreads == 0) {
|
2014-10-02 11:22:02 +02:00
|
|
|
assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0.");
|
|
|
|
vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
2009-04-30 15:07:53 -07:00
|
|
|
|
2014-09-27 15:11:41 +02:00
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
if (G1ConcRefinementThreads == 0) {
|
|
|
|
FLAG_SET_DEFAULT(G1ConcRefinementThreads, ParallelGCThreads);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-01 09:28:13 -07:00
|
|
|
// MarkStackSize will be set (if it hasn't been set by the user)
|
|
|
|
// when concurrent marking is initialized.
|
|
|
|
// Its value will be based upon the number of parallel marking threads.
|
|
|
|
// But we do set the maximum mark stack size here.
|
|
|
|
if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
|
|
|
|
FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
|
2010-02-24 07:00:33 -08:00
|
|
|
}
|
2010-03-30 15:36:55 -04:00
|
|
|
|
|
|
|
if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
|
|
|
|
// In G1, we want the default GC overhead goal to be higher than
|
|
|
|
// say in PS. So we set it here to 10%. Otherwise the heap might
|
|
|
|
// be expanded more aggressively than we would like it to. In
|
|
|
|
// fact, even 10% seems to not be high enough in some cases
|
|
|
|
// (especially small GC stress tests that the main thing they do
|
|
|
|
// is allocation). We might consider increase it further.
|
|
|
|
FLAG_SET_DEFAULT(GCTimeRatio, 9);
|
|
|
|
}
|
2012-10-01 09:28:13 -07:00
|
|
|
|
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
|
2014-05-09 16:50:54 -04:00
|
|
|
(unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
|
|
|
|
tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
|
2012-10-01 09:28:13 -07:00
|
|
|
}
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
|
|
|
|
2014-09-04 16:53:27 -07:00
|
|
|
#if !INCLUDE_ALL_GCS
|
|
|
|
#ifdef ASSERT
|
|
|
|
static bool verify_serial_gc_flags() {
|
|
|
|
return (UseSerialGC &&
|
2014-10-31 09:10:51 +01:00
|
|
|
!(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
|
2014-09-04 16:53:27 -07:00
|
|
|
UseParallelGC || UseParallelOldGC));
|
|
|
|
}
|
|
|
|
#endif // ASSERT
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
|
|
|
|
void Arguments::set_gc_specific_flags() {
|
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
// Set per-collector flags
|
|
|
|
if (UseParallelGC || UseParallelOldGC) {
|
|
|
|
set_parallel_gc_flags();
|
2014-11-27 21:02:13 +01:00
|
|
|
} else if (UseConcMarkSweepGC) {
|
2014-09-04 16:53:27 -07:00
|
|
|
set_cms_and_parnew_gc_flags();
|
|
|
|
} else if (UseG1GC) {
|
|
|
|
set_g1_gc_flags();
|
|
|
|
}
|
|
|
|
check_deprecated_gc_flags();
|
|
|
|
if (AssumeMP && !UseSerialGC) {
|
|
|
|
if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
|
|
|
|
warning("If the number of processors is expected to increase from one, then"
|
|
|
|
" you should configure the number of parallel GC threads appropriately"
|
|
|
|
" using -XX:ParallelGCThreads=N");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (MinHeapFreeRatio == 100) {
|
|
|
|
// Keeping the heap 100% free is hard ;-) so limit it to 99%.
|
|
|
|
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
|
|
|
|
}
|
|
|
|
#else // INCLUDE_ALL_GCS
|
|
|
|
assert(verify_serial_gc_flags(), "SerialGC unset");
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
}
|
|
|
|
|
2013-03-27 19:21:18 +01:00
|
|
|
julong Arguments::limit_by_allocatable_memory(julong limit) {
|
|
|
|
julong max_allocatable;
|
|
|
|
julong result = limit;
|
|
|
|
if (os::has_allocatable_memory_limit(&max_allocatable)) {
|
|
|
|
result = MIN2(result, max_allocatable / MaxVirtMemFraction);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-02-19 02:58:13 +00:00
|
|
|
// Use static initialization to get the default before parsing
|
2015-03-03 18:01:27 +01:00
|
|
|
static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
|
2014-02-19 02:58:13 +00:00
|
|
|
|
2009-10-28 16:25:51 -04:00
|
|
|
void Arguments::set_heap_size() {
|
|
|
|
if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
|
|
|
|
// Deprecated flag
|
|
|
|
FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
|
|
|
|
}
|
|
|
|
|
|
|
|
const julong phys_mem =
|
|
|
|
FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
|
|
|
|
: (julong)MaxRAM;
|
|
|
|
|
|
|
|
// If the maximum heap size has not been set with -Xmx,
|
|
|
|
// then set it as fraction of the size of physical memory,
|
|
|
|
// respecting the maximum and minimum sizes of the heap.
|
2008-06-05 15:57:56 -07:00
|
|
|
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
|
2009-10-28 16:25:51 -04:00
|
|
|
julong reasonable_max = phys_mem / MaxRAMFraction;
|
|
|
|
|
|
|
|
if (phys_mem <= MaxHeapSize * MinRAMFraction) {
|
|
|
|
// Small physical memory, so use a minimum fraction of it for the heap
|
|
|
|
reasonable_max = phys_mem / MinRAMFraction;
|
|
|
|
} else {
|
|
|
|
// Not-small physical memory, so require a heap at least
|
|
|
|
// as large as MaxHeapSize
|
|
|
|
reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
|
|
|
|
}
|
|
|
|
if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
|
|
|
|
// Limit the heap size to ErgoHeapSizeLimit
|
|
|
|
reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
|
|
|
|
}
|
|
|
|
if (UseCompressedOops) {
|
|
|
|
// Limit the heap size to the maximum possible when using compressed oops
|
2010-11-12 09:51:43 -08:00
|
|
|
julong max_coop_heap = (julong)max_heap_for_compressed_oops();
|
2014-02-19 02:58:13 +00:00
|
|
|
|
|
|
|
// HeapBaseMinAddress can be greater than default but not less than.
|
|
|
|
if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) {
|
|
|
|
if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) {
|
2014-03-04 09:57:16 -05:00
|
|
|
// matches compressed oops printing flags
|
|
|
|
if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
|
2014-02-19 02:58:13 +00:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2015-03-03 18:01:27 +01:00
|
|
|
"HeapBaseMinAddress must be at least " SIZE_FORMAT
|
|
|
|
" (" SIZE_FORMAT "G) which is greater than value given "
|
|
|
|
SIZE_FORMAT "\n",
|
2014-02-19 02:58:13 +00:00
|
|
|
DefaultHeapBaseMinAddress,
|
|
|
|
DefaultHeapBaseMinAddress/G,
|
|
|
|
HeapBaseMinAddress);
|
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, HeapBaseMinAddress, DefaultHeapBaseMinAddress);
|
2014-02-19 02:58:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-12 09:51:43 -08:00
|
|
|
if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
|
|
|
|
// Heap should be above HeapBaseMinAddress to get zero based compressed oops
|
|
|
|
// but it should be not less than default MaxHeapSize.
|
|
|
|
max_coop_heap -= HeapBaseMinAddress;
|
|
|
|
}
|
|
|
|
reasonable_max = MIN2(reasonable_max, max_coop_heap);
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
2013-03-27 19:21:18 +01:00
|
|
|
reasonable_max = limit_by_allocatable_memory(reasonable_max);
|
2009-10-28 16:25:51 -04:00
|
|
|
|
|
|
|
if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
|
|
|
|
// An initial heap size was specified on the command line,
|
|
|
|
// so be sure that the maximum size is consistent. Done
|
2013-03-27 19:21:18 +01:00
|
|
|
// after call to limit_by_allocatable_memory because that
|
2009-10-28 16:25:51 -04:00
|
|
|
// method might reduce the allocation size.
|
|
|
|
reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
|
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
// Cannot use gclog_or_tty yet.
|
2014-05-09 16:50:54 -04:00
|
|
|
tty->print_cr(" Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
|
2009-10-28 16:25:51 -04:00
|
|
|
}
|
|
|
|
|
2013-05-06 17:19:42 +02:00
|
|
|
// If the minimum or initial heap_size have not been set or requested to be set
|
|
|
|
// ergonomically, set them accordingly.
|
|
|
|
if (InitialHeapSize == 0 || min_heap_size() == 0) {
|
2009-11-20 16:22:38 -05:00
|
|
|
julong reasonable_minimum = (julong)(OldSize + NewSize);
|
|
|
|
|
|
|
|
reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
|
|
|
|
|
2013-03-27 19:21:18 +01:00
|
|
|
reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
|
2009-11-20 16:22:38 -05:00
|
|
|
|
2013-05-06 17:19:42 +02:00
|
|
|
if (InitialHeapSize == 0) {
|
|
|
|
julong reasonable_initial = phys_mem / InitialRAMFraction;
|
2009-10-28 16:25:51 -04:00
|
|
|
|
2013-05-06 17:19:42 +02:00
|
|
|
reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
|
|
|
|
reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
|
2009-10-28 16:25:51 -04:00
|
|
|
|
2013-05-06 17:19:42 +02:00
|
|
|
reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
|
2009-10-28 16:25:51 -04:00
|
|
|
|
2013-05-06 17:19:42 +02:00
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
// Cannot use gclog_or_tty yet.
|
2015-03-03 18:01:27 +01:00
|
|
|
tty->print_cr(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
|
2013-05-06 17:19:42 +02:00
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
|
2013-05-06 17:19:42 +02:00
|
|
|
}
|
|
|
|
// If the minimum heap size has not been set (via -Xms),
|
|
|
|
// synchronize with InitialHeapSize to avoid errors with the default value.
|
|
|
|
if (min_heap_size() == 0) {
|
2015-03-03 18:01:27 +01:00
|
|
|
set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
|
2013-05-06 17:19:42 +02:00
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
// Cannot use gclog_or_tty yet.
|
|
|
|
tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
|
|
|
|
}
|
2009-10-28 16:25:51 -04:00
|
|
|
}
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 15:18:37 -07:00
|
|
|
// This must be called after ergonomics.
|
2007-12-01 00:00:00 +00:00
|
|
|
void Arguments::set_bytecode_flags() {
|
|
|
|
if (!RewriteBytecodes) {
|
|
|
|
FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Aggressive optimization flags -XX:+AggressiveOpts
|
|
|
|
void Arguments::set_aggressive_opts_flags() {
|
2007-12-05 09:01:00 -08:00
|
|
|
#ifdef COMPILER2
|
2013-05-08 15:08:01 -07:00
|
|
|
if (AggressiveUnboxing) {
|
|
|
|
if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
|
|
|
|
FLAG_SET_DEFAULT(EliminateAutoBox, true);
|
|
|
|
} else if (!EliminateAutoBox) {
|
|
|
|
// warning("AggressiveUnboxing is disabled because EliminateAutoBox is disabled");
|
|
|
|
AggressiveUnboxing = false;
|
|
|
|
}
|
|
|
|
if (FLAG_IS_DEFAULT(DoEscapeAnalysis)) {
|
|
|
|
FLAG_SET_DEFAULT(DoEscapeAnalysis, true);
|
|
|
|
} else if (!DoEscapeAnalysis) {
|
|
|
|
// warning("AggressiveUnboxing is disabled because DoEscapeAnalysis is disabled");
|
|
|
|
AggressiveUnboxing = false;
|
|
|
|
}
|
|
|
|
}
|
2007-12-05 09:01:00 -08:00
|
|
|
if (AggressiveOpts || !FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
|
|
|
|
if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
|
|
|
|
FLAG_SET_DEFAULT(EliminateAutoBox, true);
|
|
|
|
}
|
|
|
|
if (FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
|
|
|
|
FLAG_SET_DEFAULT(AutoBoxCacheMax, 20000);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Feed the cache size setting into the JDK
|
|
|
|
char buffer[1024];
|
2008-12-24 19:13:53 -08:00
|
|
|
sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
|
2007-12-05 09:01:00 -08:00
|
|
|
add_property(buffer);
|
|
|
|
}
|
2008-10-28 18:02:09 -07:00
|
|
|
if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) {
|
|
|
|
FLAG_SET_DEFAULT(BiasedLockingStartupDelay, 500);
|
|
|
|
}
|
2007-12-05 09:01:00 -08:00
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (AggressiveOpts) {
|
2008-03-19 09:58:01 -04:00
|
|
|
// Sample flag setting code
|
|
|
|
// if (FLAG_IS_DEFAULT(EliminateZeroing)) {
|
|
|
|
// FLAG_SET_DEFAULT(EliminateZeroing, true);
|
|
|
|
// }
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================================================
|
|
|
|
// Parsing of java.compiler property
|
|
|
|
|
|
|
|
void Arguments::process_java_compiler_argument(char* arg) {
|
|
|
|
// For backwards compatibility, Djava.compiler=NONE or ""
|
|
|
|
// causes us to switch to -Xint mode UNLESS -Xdebug
|
|
|
|
// is also specified.
|
|
|
|
if (strlen(arg) == 0 || strcasecmp(arg, "NONE") == 0) {
|
|
|
|
set_java_compiler(true); // "-Djava.compiler[=...]" most recently seen.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
|
2014-08-11 10:18:09 -07:00
|
|
|
_sun_java_launcher = os::strdup_check_oom(launcher);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Arguments::created_by_java_launcher() {
|
|
|
|
assert(_sun_java_launcher != NULL, "property must have value");
|
|
|
|
return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
|
|
|
|
}
|
|
|
|
|
2014-01-30 14:12:22 -08:00
|
|
|
bool Arguments::sun_java_launcher_is_altjvm() {
|
|
|
|
return _sun_java_launcher_is_altjvm;
|
2011-02-28 14:19:52 +01:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
//===========================================================================================================
|
|
|
|
// Parsing of main arguments
|
|
|
|
|
2010-01-29 14:51:38 -08:00
|
|
|
bool Arguments::verify_interval(uintx val, uintx min,
|
|
|
|
uintx max, const char* name) {
|
|
|
|
// Returns true iff value is in the inclusive interval [min..max]
|
|
|
|
// false, otherwise.
|
|
|
|
if (val >= min && val <= max) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT
|
|
|
|
" and " UINTX_FORMAT "\n",
|
|
|
|
name, val, min, max);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-19 14:23:59 -04:00
|
|
|
bool Arguments::verify_min_value(intx val, intx min, const char* name) {
|
2011-03-11 16:35:18 +01:00
|
|
|
// Returns true if given value is at least specified min threshold
|
2010-08-19 14:23:59 -04:00
|
|
|
// false, otherwise.
|
|
|
|
if (val >= min ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2011-03-11 16:35:18 +01:00
|
|
|
"%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
|
2010-08-19 14:23:59 -04:00
|
|
|
name, val, min);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool Arguments::verify_percentage(uintx value, const char* name) {
|
2014-01-29 23:17:05 +01:00
|
|
|
if (is_percentage(value)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
|
|
|
|
name, value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-06-10 15:08:36 -07:00
|
|
|
// check if do gclog rotation
|
|
|
|
// +UseGCLogFileRotation is a must,
|
|
|
|
// no gc log rotation when log file not supplied or
|
2014-03-28 21:04:37 -07:00
|
|
|
// NumberOfGCLogFiles is 0
|
2011-06-10 15:08:36 -07:00
|
|
|
void check_gclog_consistency() {
|
|
|
|
if (UseGCLogFileRotation) {
|
2014-03-28 21:04:37 -07:00
|
|
|
if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
|
2011-06-10 15:08:36 -07:00
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
2014-03-28 21:04:37 -07:00
|
|
|
"To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
|
|
|
|
"where num_of_file > 0\n"
|
2011-06-10 15:08:36 -07:00
|
|
|
"GC log rotation is turned off\n");
|
|
|
|
UseGCLogFileRotation = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-28 21:04:37 -07:00
|
|
|
if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K);
|
2014-03-28 21:04:37 -07:00
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"GCLogFileSize changed to minimum 8K\n");
|
2011-06-10 15:08:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-16 15:35:04 -07:00
|
|
|
// This function is called for -Xloggc:<filename>, it can be used
|
|
|
|
// to check if a given file name(or string) conforms to the following
|
|
|
|
// specification:
|
|
|
|
// A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
|
|
|
|
// %p and %t only allowed once. We only limit usage of filename not path
|
|
|
|
bool is_filename_valid(const char *file_name) {
|
|
|
|
const char* p = file_name;
|
|
|
|
char file_sep = os::file_separator()[0];
|
|
|
|
const char* cp;
|
|
|
|
// skip prefix path
|
|
|
|
for (cp = file_name; *cp != '\0'; cp++) {
|
|
|
|
if (*cp == '/' || *cp == file_sep) {
|
|
|
|
p = cp + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int count_p = 0;
|
|
|
|
int count_t = 0;
|
|
|
|
while (*p != '\0') {
|
|
|
|
if ((*p >= '0' && *p <= '9') ||
|
|
|
|
(*p >= 'A' && *p <= 'Z') ||
|
|
|
|
(*p >= 'a' && *p <= 'z') ||
|
|
|
|
*p == '-' ||
|
|
|
|
*p == '_' ||
|
|
|
|
*p == '.') {
|
|
|
|
p++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (*p == '%') {
|
|
|
|
if(*(p + 1) == 'p') {
|
|
|
|
p += 2;
|
|
|
|
count_p ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (*(p + 1) == 't') {
|
|
|
|
p += 2;
|
|
|
|
count_t ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return count_p < 2 && count_t < 2;
|
|
|
|
}
|
|
|
|
|
2014-01-29 23:17:05 +01:00
|
|
|
bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) {
|
|
|
|
if (!is_percentage(min_heap_free_ratio)) {
|
|
|
|
err_msg.print("MinHeapFreeRatio must have a value between 0 and 100");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (min_heap_free_ratio > MaxHeapFreeRatio) {
|
|
|
|
err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
|
|
|
|
"equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio,
|
|
|
|
MaxHeapFreeRatio);
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-16 16:02:32 +02:00
|
|
|
// This does not set the flag itself, but stores the value in a safe place for later usage.
|
|
|
|
_min_heap_free_ratio = min_heap_free_ratio;
|
2014-01-29 23:17:05 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
|
|
|
|
if (!is_percentage(max_heap_free_ratio)) {
|
|
|
|
err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (max_heap_free_ratio < MinHeapFreeRatio) {
|
|
|
|
err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
|
|
|
|
"equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
|
|
|
|
MinHeapFreeRatio);
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-16 16:02:32 +02:00
|
|
|
// This does not set the flag itself, but stores the value in a safe place for later usage.
|
|
|
|
_max_heap_free_ratio = max_heap_free_ratio;
|
2014-01-29 23:17:05 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-02-22 17:17:14 -08:00
|
|
|
// Check consistency of GC selection
|
2015-03-02 11:08:09 +01:00
|
|
|
bool Arguments::check_gc_consistency() {
|
2011-06-10 15:08:36 -07:00
|
|
|
check_gclog_consistency();
|
2008-02-22 17:17:14 -08:00
|
|
|
// Ensure that the user has not selected conflicting sets
|
2014-11-27 21:02:13 +01:00
|
|
|
// of collectors.
|
2008-02-22 17:17:14 -08:00
|
|
|
uint i = 0;
|
|
|
|
if (UseSerialGC) i++;
|
2014-11-27 21:02:13 +01:00
|
|
|
if (UseConcMarkSweepGC) i++;
|
2008-02-22 17:17:14 -08:00
|
|
|
if (UseParallelGC || UseParallelOldGC) i++;
|
2009-07-14 15:40:39 -07:00
|
|
|
if (UseG1GC) i++;
|
2008-02-22 17:17:14 -08:00
|
|
|
if (i > 1) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Conflicting collector combinations in option list; "
|
|
|
|
"please refer to the release notes for the combinations "
|
|
|
|
"allowed\n");
|
2014-11-27 21:02:13 +01:00
|
|
|
return false;
|
2008-02-22 17:17:14 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 11:10:17 +01:00
|
|
|
if (UseConcMarkSweepGC && !UseParNewGC) {
|
2014-11-27 21:02:13 +01:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"It is not possible to combine the DefNew young collector with the CMS collector.\n");
|
|
|
|
return false;
|
2013-01-04 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (UseParNewGC && !UseConcMarkSweepGC) {
|
|
|
|
// !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
|
|
|
|
// set up UseSerialGC properly, so that can't be used in the check here.
|
2014-11-27 21:02:13 +01:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"It is not possible to combine the ParNew young collector with the Serial old collector.\n");
|
|
|
|
return false;
|
2013-01-04 11:10:17 +01:00
|
|
|
}
|
2014-11-27 21:02:13 +01:00
|
|
|
|
|
|
|
return true;
|
2013-01-04 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2013-03-07 10:44:04 -08:00
|
|
|
void Arguments::check_deprecated_gc_flags() {
|
2014-11-27 21:02:13 +01:00
|
|
|
if (FLAG_IS_CMDLINE(UseParNewGC)) {
|
|
|
|
warning("The UseParNewGC flag is deprecated and will likely be removed in a future release");
|
|
|
|
}
|
2013-03-07 10:44:04 -08:00
|
|
|
if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
|
|
|
|
warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
|
|
|
|
"and will likely be removed in future release");
|
|
|
|
}
|
2013-08-01 07:03:07 +02:00
|
|
|
if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
|
|
|
|
warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
|
|
|
|
"Use MaxRAMFraction instead.");
|
|
|
|
}
|
2013-03-07 10:44:04 -08:00
|
|
|
}
|
|
|
|
|
2010-08-19 14:23:59 -04:00
|
|
|
// Check stack pages settings
|
|
|
|
bool Arguments::check_stack_pages()
|
|
|
|
{
|
|
|
|
bool status = true;
|
|
|
|
status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
|
|
|
|
status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
|
2010-10-07 08:06:06 -07:00
|
|
|
// greater stack shadow pages can't generate instruction to bang stack
|
|
|
|
status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages");
|
2010-08-19 14:23:59 -04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Check the consistency of vm_init_args
|
|
|
|
bool Arguments::check_vm_args_consistency() {
|
|
|
|
// Method for adding checks for flag consistency.
|
|
|
|
// The intent is to warn the user of all possible conflicts,
|
|
|
|
// before returning an error.
|
|
|
|
// Note: Needs platform-dependent factoring.
|
|
|
|
bool status = true;
|
|
|
|
|
|
|
|
if (TLABRefillWasteFraction == 0) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"TLABRefillWasteFraction should be a denominator, "
|
|
|
|
"not " SIZE_FORMAT "\n",
|
|
|
|
TLABRefillWasteFraction);
|
|
|
|
status = false;
|
|
|
|
}
|
|
|
|
|
2013-05-15 11:05:09 +02:00
|
|
|
status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
|
2007-12-01 00:00:00 +00:00
|
|
|
"AdaptiveSizePolicyWeight");
|
2008-02-22 17:17:14 -08:00
|
|
|
status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-11-12 15:58:11 -05:00
|
|
|
// Divide by bucket size to prevent a large size from causing rollover when
|
|
|
|
// calculating amount of memory needed to be allocated for the String table.
|
2013-04-17 08:20:02 -04:00
|
|
|
status = status && verify_interval(StringTableSize, minimumStringTableSize,
|
2012-11-12 15:58:11 -05:00
|
|
|
(max_uintx / StringTable::bucket_size()), "StringTable size");
|
|
|
|
|
2013-10-08 09:33:51 +01:00
|
|
|
status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
|
|
|
|
(max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
|
|
|
|
|
2014-01-29 23:17:05 +01:00
|
|
|
{
|
|
|
|
// Using "else if" below to avoid printing two error messages if min > max.
|
|
|
|
// This will also prevent us from reporting both min>100 and max>100 at the
|
|
|
|
// same time, but that is less annoying than printing two identical errors IMHO.
|
2014-05-09 16:50:54 -04:00
|
|
|
FormatBuffer<80> err_msg("%s","");
|
2014-01-29 23:17:05 +01:00
|
|
|
if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
|
|
|
|
status = false;
|
|
|
|
} else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
|
|
|
|
status = false;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 19:08:04 -08:00
|
|
|
// Min/MaxMetaspaceFreeRatio
|
|
|
|
status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
|
|
|
|
status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
|
|
|
|
|
|
|
|
if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or "
|
|
|
|
"equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n",
|
|
|
|
FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "",
|
|
|
|
MinMetaspaceFreeRatio,
|
|
|
|
FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "",
|
|
|
|
MaxMetaspaceFreeRatio);
|
|
|
|
status = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trying to keep 100% free is not practical
|
|
|
|
MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
|
|
|
|
MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
|
|
|
|
}
|
|
|
|
|
2008-12-11 12:05:21 -08:00
|
|
|
if (UseParallelOldGC && ParallelOldGCSplitALot) {
|
|
|
|
// Settings to encourage splitting.
|
|
|
|
if (!FLAG_IS_CMDLINE(NewRatio)) {
|
2013-02-07 15:51:25 +01:00
|
|
|
FLAG_SET_CMDLINE(uintx, NewRatio, 2);
|
2008-12-11 12:05:21 -08:00
|
|
|
}
|
|
|
|
if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
|
|
|
|
FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 02:11:34 +02:00
|
|
|
if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) {
|
|
|
|
FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false);
|
|
|
|
}
|
|
|
|
|
2008-02-22 17:17:14 -08:00
|
|
|
status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
|
|
|
|
status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
|
2007-12-01 00:00:00 +00:00
|
|
|
if (GCTimeLimit == 100) {
|
|
|
|
// Turn off gc-overhead-limit-exceeded checks
|
|
|
|
FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
|
|
|
|
}
|
|
|
|
|
2015-03-02 11:08:09 +01:00
|
|
|
status = status && check_gc_consistency();
|
2010-08-19 14:23:59 -04:00
|
|
|
status = status && check_stack_pages();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-10-31 09:10:51 +01:00
|
|
|
status = status && verify_percentage(CMSIncrementalSafetyFactor,
|
|
|
|
"CMSIncrementalSafetyFactor");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// CMS space iteration, which FLSVerifyAllHeapreferences entails,
|
|
|
|
// insists that we hold the requisite locks so that the iteration is
|
|
|
|
// MT-safe. For the verification at start-up and shut-down, we don't
|
|
|
|
// yet have a good way of acquiring and releasing these locks,
|
|
|
|
// which are not visible at the CollectedHeap level. We want to
|
|
|
|
// be able to acquire these locks and then do the iteration rather
|
|
|
|
// than just disable the lock verification. This will be fixed under
|
|
|
|
// bug 4788986.
|
|
|
|
if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
|
2013-04-05 10:20:04 -07:00
|
|
|
if (VerifyDuringStartup) {
|
2007-12-01 00:00:00 +00:00
|
|
|
warning("Heap verification at start-up disabled "
|
|
|
|
"(due to current incompatibility with FLSVerifyAllHeapReferences)");
|
2013-04-05 10:20:04 -07:00
|
|
|
VerifyDuringStartup = false; // Disable verification at start-up
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-04-05 10:20:04 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (VerifyBeforeExit) {
|
|
|
|
warning("Heap verification at shutdown disabled "
|
|
|
|
"(due to current incompatibility with FLSVerifyAllHeapReferences)");
|
|
|
|
VerifyBeforeExit = false; // Disable verification at shutdown
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: only executed in non-PRODUCT mode
|
|
|
|
if (!UseAsyncConcMarkSweepGC &&
|
|
|
|
(ExplicitGCInvokesConcurrent ||
|
|
|
|
ExplicitGCInvokesConcurrentAndUnloadsClasses)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2012-08-23 10:21:12 +02:00
|
|
|
"error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts"
|
2007-12-01 00:00:00 +00:00
|
|
|
" with -UseAsyncConcMarkSweepGC");
|
|
|
|
status = false;
|
|
|
|
}
|
|
|
|
|
2011-03-11 16:35:18 +01:00
|
|
|
status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk");
|
|
|
|
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2010-02-23 23:14:34 -05:00
|
|
|
if (UseG1GC) {
|
2013-11-01 17:09:38 +01:00
|
|
|
status = status && verify_percentage(G1NewSizePercent, "G1NewSizePercent");
|
|
|
|
status = status && verify_percentage(G1MaxNewSizePercent, "G1MaxNewSizePercent");
|
|
|
|
status = status && verify_interval(G1NewSizePercent, 0, G1MaxNewSizePercent, "G1NewSizePercent");
|
|
|
|
|
2015-01-29 00:08:38 -05:00
|
|
|
status = status && verify_percentage(G1ConfidencePercent, "G1ConfidencePercent");
|
2010-02-23 23:14:34 -05:00
|
|
|
status = status && verify_percentage(InitiatingHeapOccupancyPercent,
|
|
|
|
"InitiatingHeapOccupancyPercent");
|
2011-01-25 10:56:22 -08:00
|
|
|
status = status && verify_min_value(G1RefProcDrainInterval, 1,
|
|
|
|
"G1RefProcDrainInterval");
|
|
|
|
status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1,
|
|
|
|
"G1ConcMarkStepDurationMillis");
|
2013-05-09 11:16:39 -07:00
|
|
|
status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte,
|
|
|
|
"G1ConcRSHotCardLimit");
|
|
|
|
status = status && verify_interval(G1ConcRSLogCacheSize, 0, 31,
|
|
|
|
"G1ConcRSLogCacheSize");
|
2014-03-18 19:07:22 +01:00
|
|
|
status = status && verify_interval(StringDeduplicationAgeThreshold, 1, markOopDesc::max_age,
|
|
|
|
"StringDeduplicationAgeThreshold");
|
2010-02-23 23:14:34 -05:00
|
|
|
}
|
2013-05-15 11:05:09 +02:00
|
|
|
if (UseConcMarkSweepGC) {
|
|
|
|
status = status && verify_min_value(CMSOldPLABNumRefills, 1, "CMSOldPLABNumRefills");
|
|
|
|
status = status && verify_min_value(CMSOldPLABToleranceFactor, 1, "CMSOldPLABToleranceFactor");
|
|
|
|
status = status && verify_min_value(CMSOldPLABMax, 1, "CMSOldPLABMax");
|
|
|
|
status = status && verify_interval(CMSOldPLABMin, 1, CMSOldPLABMax, "CMSOldPLABMin");
|
|
|
|
|
|
|
|
status = status && verify_min_value(CMSYoungGenPerWorker, 1, "CMSYoungGenPerWorker");
|
|
|
|
|
|
|
|
status = status && verify_min_value(CMSSamplingGrain, 1, "CMSSamplingGrain");
|
|
|
|
status = status && verify_interval(CMS_SweepWeight, 0, 100, "CMS_SweepWeight");
|
|
|
|
status = status && verify_interval(CMS_FLSWeight, 0, 100, "CMS_FLSWeight");
|
|
|
|
|
|
|
|
status = status && verify_interval(FLSCoalescePolicy, 0, 4, "FLSCoalescePolicy");
|
|
|
|
|
|
|
|
status = status && verify_min_value(CMSRescanMultiple, 1, "CMSRescanMultiple");
|
|
|
|
status = status && verify_min_value(CMSConcMarkMultiple, 1, "CMSConcMarkMultiple");
|
|
|
|
|
|
|
|
status = status && verify_interval(CMSPrecleanIter, 0, 9, "CMSPrecleanIter");
|
|
|
|
status = status && verify_min_value(CMSPrecleanDenominator, 1, "CMSPrecleanDenominator");
|
|
|
|
status = status && verify_interval(CMSPrecleanNumerator, 0, CMSPrecleanDenominator - 1, "CMSPrecleanNumerator");
|
|
|
|
|
|
|
|
status = status && verify_percentage(CMSBootstrapOccupancy, "CMSBootstrapOccupancy");
|
|
|
|
|
|
|
|
status = status && verify_min_value(CMSPrecleanThreshold, 100, "CMSPrecleanThreshold");
|
|
|
|
|
|
|
|
status = status && verify_percentage(CMSScheduleRemarkEdenPenetration, "CMSScheduleRemarkEdenPenetration");
|
|
|
|
status = status && verify_min_value(CMSScheduleRemarkSamplingRatio, 1, "CMSScheduleRemarkSamplingRatio");
|
|
|
|
status = status && verify_min_value(CMSBitMapYieldQuantum, 1, "CMSBitMapYieldQuantum");
|
|
|
|
status = status && verify_percentage(CMSTriggerRatio, "CMSTriggerRatio");
|
|
|
|
status = status && verify_percentage(CMSIsTooFullPercentage, "CMSIsTooFullPercentage");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UseParallelGC || UseParallelOldGC) {
|
|
|
|
status = status && verify_interval(ParallelOldDeadWoodLimiterMean, 0, 100, "ParallelOldDeadWoodLimiterMean");
|
|
|
|
status = status && verify_interval(ParallelOldDeadWoodLimiterStdDev, 0, 100, "ParallelOldDeadWoodLimiterStdDev");
|
|
|
|
|
|
|
|
status = status && verify_percentage(YoungGenerationSizeIncrement, "YoungGenerationSizeIncrement");
|
|
|
|
status = status && verify_percentage(TenuredGenerationSizeIncrement, "TenuredGenerationSizeIncrement");
|
|
|
|
|
|
|
|
status = status && verify_min_value(YoungGenerationSizeSupplementDecay, 1, "YoungGenerationSizeSupplementDecay");
|
|
|
|
status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay");
|
|
|
|
|
|
|
|
status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk");
|
|
|
|
|
|
|
|
status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval");
|
|
|
|
}
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2010-02-23 23:14:34 -05:00
|
|
|
|
2010-01-29 14:51:38 -08:00
|
|
|
status = status && verify_interval(RefDiscoveryPolicy,
|
|
|
|
ReferenceProcessor::DiscoveryPolicyMin,
|
|
|
|
ReferenceProcessor::DiscoveryPolicyMax,
|
|
|
|
"RefDiscoveryPolicy");
|
|
|
|
|
|
|
|
// Limit the lower bound of this flag to 1 as it is used in a division
|
|
|
|
// expression.
|
|
|
|
status = status && verify_interval(TLABWasteTargetPercent,
|
|
|
|
1, 100, "TLABWasteTargetPercent");
|
|
|
|
|
2010-05-27 18:01:56 -07:00
|
|
|
status = status && verify_object_alignment();
|
|
|
|
|
2013-08-12 17:37:02 +02:00
|
|
|
status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G,
|
|
|
|
"CompressedClassSpaceSize");
|
2012-09-07 16:42:25 -04:00
|
|
|
|
2012-10-01 09:28:13 -07:00
|
|
|
status = status && verify_interval(MarkStackSizeMax,
|
|
|
|
1, (max_jint - 1), "MarkStackSizeMax");
|
2013-05-15 11:05:09 +02:00
|
|
|
status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
|
|
|
|
|
|
|
|
status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
|
|
|
|
|
2015-03-03 18:01:27 +01:00
|
|
|
status = status && verify_min_value(HeapSizePerGCThread, (size_t) os::vm_page_size(), "HeapSizePerGCThread");
|
2013-05-15 11:05:09 +02:00
|
|
|
|
|
|
|
status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
|
|
|
|
|
|
|
|
status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
|
|
|
|
status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
|
|
|
|
|
|
|
|
status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
|
2012-10-01 09:28:13 -07:00
|
|
|
|
2013-05-15 11:05:09 +02:00
|
|
|
status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
|
|
|
|
status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
|
|
|
|
status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
|
|
|
|
status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction");
|
|
|
|
|
|
|
|
status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
|
|
|
|
status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
|
|
|
|
|
|
|
|
status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
|
|
|
|
status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
|
|
|
|
status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
|
|
|
|
|
|
|
|
status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
|
|
|
|
status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
|
|
|
|
|
2014-03-26 12:49:34 +01:00
|
|
|
status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold");
|
|
|
|
status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold");
|
2013-05-15 11:05:09 +02:00
|
|
|
status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
|
|
|
|
status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
|
2012-10-01 09:28:13 -07:00
|
|
|
|
2013-05-15 11:05:09 +02:00
|
|
|
status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
|
2014-05-20 09:35:05 +02:00
|
|
|
#ifdef COMPILER1
|
|
|
|
status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize");
|
|
|
|
#endif
|
2015-01-05 12:07:37 -05:00
|
|
|
status = status && verify_min_value(HeapSearchSteps, 1, "HeapSearchSteps");
|
2012-09-19 15:48:02 -07:00
|
|
|
|
2012-10-10 14:35:58 -04:00
|
|
|
if (PrintNMTStatistics) {
|
|
|
|
#if INCLUDE_NMT
|
2014-08-07 12:18:58 -07:00
|
|
|
if (MemTracker::tracking_level() == NMT_off) {
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // INCLUDE_NMT
|
|
|
|
warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
|
|
|
|
PrintNMTStatistics = false;
|
|
|
|
#if INCLUDE_NMT
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-17 16:37:26 -04:00
|
|
|
}
|
|
|
|
|
2013-05-08 19:28:54 -04:00
|
|
|
// Need to limit the extent of the padding to reasonable size.
|
|
|
|
// 8K is well beyond the reasonable HW cache line size, even with the
|
|
|
|
// aggressive prefetching, while still leaving the room for segregating
|
|
|
|
// among the distinct pages.
|
|
|
|
if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-08-26 17:42:03 +04:00
|
|
|
"ContendedPaddingWidth=" INTX_FORMAT " must be in between %d and %d\n",
|
2013-05-08 19:28:54 -04:00
|
|
|
ContendedPaddingWidth, 0, 8192);
|
|
|
|
status = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to enforce the padding not to break the existing field alignments.
|
|
|
|
// It is sufficient to check against the largest type size.
|
|
|
|
if ((ContendedPaddingWidth % BytesPerLong) != 0) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-08-26 17:42:03 +04:00
|
|
|
"ContendedPaddingWidth=" INTX_FORMAT " must be a multiple of %d\n",
|
2013-05-08 19:28:54 -04:00
|
|
|
ContendedPaddingWidth, BytesPerLong);
|
|
|
|
status = false;
|
|
|
|
}
|
|
|
|
|
2013-07-02 07:51:31 +02:00
|
|
|
// Check lower bounds of the code cache
|
|
|
|
// Template Interpreter code is approximately 3X larger in debug builds.
|
2014-10-24 14:25:46 +02:00
|
|
|
uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
|
2013-07-02 07:51:31 +02:00
|
|
|
if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
|
2013-05-31 06:41:50 +02:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-07-02 07:51:31 +02:00
|
|
|
"Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
|
|
|
|
os::vm_page_size()/K);
|
|
|
|
status = false;
|
|
|
|
} else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
|
2013-05-31 06:41:50 +02:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-07-02 07:51:31 +02:00
|
|
|
"Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
|
2013-05-31 06:41:50 +02:00
|
|
|
ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
|
|
|
|
status = false;
|
2013-07-02 07:51:31 +02:00
|
|
|
} else if (ReservedCodeCacheSize < min_code_cache_size) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
|
|
|
|
min_code_cache_size/K);
|
|
|
|
status = false;
|
2014-12-11 13:11:53 -08:00
|
|
|
} else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {
|
|
|
|
// Code cache size larger than CODE_CACHE_SIZE_LIMIT is not supported.
|
2013-07-09 11:48:05 +02:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
|
2014-12-11 13:11:53 -08:00
|
|
|
CODE_CACHE_SIZE_LIMIT/M);
|
2013-07-09 11:48:05 +02:00
|
|
|
status = false;
|
2014-09-30 15:44:43 +02:00
|
|
|
} else if (NonNMethodCodeHeapSize < min_code_cache_size){
|
2014-09-17 08:00:07 +02:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2014-09-30 15:44:43 +02:00
|
|
|
"Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K,
|
2014-09-17 08:00:07 +02:00
|
|
|
min_code_cache_size/K);
|
|
|
|
status = false;
|
2014-09-30 15:44:43 +02:00
|
|
|
} else if ((!FLAG_IS_DEFAULT(NonNMethodCodeHeapSize) || !FLAG_IS_DEFAULT(ProfiledCodeHeapSize) || !FLAG_IS_DEFAULT(NonProfiledCodeHeapSize))
|
|
|
|
&& (NonNMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) {
|
2014-09-17 08:00:07 +02:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2014-09-30 15:44:43 +02:00
|
|
|
"Invalid code heap sizes: NonNMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n",
|
|
|
|
NonNMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K,
|
|
|
|
(NonNMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K);
|
2014-09-17 08:00:07 +02:00
|
|
|
status = false;
|
2013-05-31 06:41:50 +02:00
|
|
|
}
|
2013-09-27 10:50:55 +02:00
|
|
|
|
|
|
|
status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
|
2014-03-07 07:42:40 +01:00
|
|
|
status &= verify_interval(CodeCacheMinBlockLength, 1, 100, "CodeCacheMinBlockLength");
|
|
|
|
status &= verify_interval(CodeCacheSegmentSize, 1, 1024, "CodeCacheSegmentSize");
|
2014-10-24 14:25:46 +02:00
|
|
|
status &= verify_interval(StartAggressiveSweepingAt, 0, 100, "StartAggressiveSweepingAt");
|
|
|
|
|
2013-09-27 10:50:55 +02:00
|
|
|
|
2014-05-08 12:49:21 +02:00
|
|
|
int min_number_of_compiler_threads = get_min_number_of_compiler_threads();
|
|
|
|
// The default CICompilerCount's value is CI_COMPILER_COUNT.
|
|
|
|
assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number");
|
|
|
|
// Check the minimum number of compiler threads
|
|
|
|
status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount");
|
2014-02-25 13:52:37 +01:00
|
|
|
|
2014-04-14 08:24:28 +02:00
|
|
|
if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
|
|
|
|
warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore,
|
|
|
|
const char* option_type) {
|
|
|
|
if (ignore) return false;
|
|
|
|
|
|
|
|
const char* spacer = " ";
|
|
|
|
if (option_type == NULL) {
|
|
|
|
option_type = ++spacer; // Set both to the empty string.
|
|
|
|
}
|
|
|
|
|
|
|
|
if (os::obsolete_option(option)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Obsolete %s%soption: %s\n", option_type, spacer,
|
|
|
|
option->optionString);
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Unrecognized %s%soption: %s\n", option_type, spacer,
|
|
|
|
option->optionString);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* user_assertion_options[] = {
|
|
|
|
"-da", "-ea", "-disableassertions", "-enableassertions", 0
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char* system_assertion_options[] = {
|
|
|
|
"-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
|
|
|
|
};
|
|
|
|
|
2010-02-24 07:00:33 -08:00
|
|
|
bool Arguments::parse_uintx(const char* value,
|
|
|
|
uintx* uintx_arg,
|
|
|
|
uintx min_size) {
|
|
|
|
|
|
|
|
// Check the sign first since atomull() parses only unsigned values.
|
|
|
|
bool value_is_positive = !(*value == '-');
|
|
|
|
|
|
|
|
if (value_is_positive) {
|
|
|
|
julong n;
|
|
|
|
bool good_return = atomull(value, &n);
|
|
|
|
if (good_return) {
|
|
|
|
bool above_minimum = n >= min_size;
|
|
|
|
bool value_is_too_large = n > max_uintx;
|
|
|
|
|
|
|
|
if (above_minimum && !value_is_too_large) {
|
|
|
|
*uintx_arg = n;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
|
2008-12-15 13:58:57 -08:00
|
|
|
julong* long_arg,
|
|
|
|
julong min_size) {
|
|
|
|
if (!atomull(s, long_arg)) return arg_unreadable;
|
2007-12-01 00:00:00 +00:00
|
|
|
return check_memory_size(*long_arg, min_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse JavaVMInitArgs structure
|
|
|
|
|
|
|
|
jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) {
|
|
|
|
// For components of the system classpath.
|
|
|
|
SysClassPath scp(Arguments::get_sysclasspath());
|
|
|
|
bool scp_assembly_required = false;
|
|
|
|
|
|
|
|
// Save default settings for some mode flags
|
|
|
|
Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
|
|
|
|
Arguments::_UseOnStackReplacement = UseOnStackReplacement;
|
|
|
|
Arguments::_ClipInlining = ClipInlining;
|
|
|
|
Arguments::_BackgroundCompilation = BackgroundCompilation;
|
|
|
|
|
2011-05-04 00:21:22 -07:00
|
|
|
// Setup flags for mixed which is the default
|
|
|
|
set_mode_flags(_mixed);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Parse JAVA_TOOL_OPTIONS environment variable (if present)
|
|
|
|
jint result = parse_java_tool_options_environment_variable(&scp, &scp_assembly_required);
|
|
|
|
if (result != JNI_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse JavaVMInitArgs structure passed in
|
2013-09-26 12:07:53 -07:00
|
|
|
result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, Flag::COMMAND_LINE);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (result != JNI_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
|
|
|
|
result = parse_java_options_environment_variable(&scp, &scp_assembly_required);
|
|
|
|
if (result != JNI_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do final processing now that all arguments have been parsed
|
|
|
|
result = finalize_vm_init_args(&scp, scp_assembly_required);
|
|
|
|
if (result != JNI_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-28 18:24:04 -04:00
|
|
|
// Checks if name in command-line argument -agent{lib,path}:name[=options]
|
|
|
|
// represents a valid HPROF of JDWP agent. is_path==true denotes that we
|
|
|
|
// are dealing with -agentpath (case where name is a path), otherwise with
|
|
|
|
// -agentlib
|
|
|
|
bool valid_hprof_or_jdwp_agent(char *name, bool is_path) {
|
|
|
|
char *_name;
|
|
|
|
const char *_hprof = "hprof", *_jdwp = "jdwp";
|
|
|
|
size_t _len_hprof, _len_jdwp, _len_prefix;
|
|
|
|
|
|
|
|
if (is_path) {
|
|
|
|
if ((_name = strrchr(name, (int) *os::file_separator())) == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_name++; // skip past last path separator
|
|
|
|
_len_prefix = strlen(JNI_LIB_PREFIX);
|
|
|
|
|
|
|
|
if (strncmp(_name, JNI_LIB_PREFIX, _len_prefix) != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_name += _len_prefix;
|
|
|
|
_len_hprof = strlen(_hprof);
|
|
|
|
_len_jdwp = strlen(_jdwp);
|
|
|
|
|
|
|
|
if (strncmp(_name, _hprof, _len_hprof) == 0) {
|
|
|
|
_name += _len_hprof;
|
|
|
|
}
|
|
|
|
else if (strncmp(_name, _jdwp, _len_jdwp) == 0) {
|
|
|
|
_name += _len_jdwp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(_name, JNI_LIB_SUFFIX) != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(name, _hprof) == 0 || strcmp(name, _jdwp) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
|
|
|
SysClassPath* scp_p,
|
|
|
|
bool* scp_assembly_required_p,
|
2013-09-26 12:07:53 -07:00
|
|
|
Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Remaining part of option string
|
|
|
|
const char* tail;
|
|
|
|
|
|
|
|
// iterate over arguments
|
|
|
|
for (int index = 0; index < args->nOptions; index++) {
|
|
|
|
bool is_absolute_path = false; // for -agentpath vs -agentlib
|
|
|
|
|
|
|
|
const JavaVMOption* option = args->options + index;
|
|
|
|
|
|
|
|
if (!match_option(option, "-Djava.class.path", &tail) &&
|
|
|
|
!match_option(option, "-Dsun.java.command", &tail) &&
|
|
|
|
!match_option(option, "-Dsun.java.launcher", &tail)) {
|
|
|
|
|
|
|
|
// add all jvm options to the jvm_args string. This string
|
|
|
|
// is used later to set the java.vm.args PerfData string constant.
|
|
|
|
// the -Djava.class.path and the -Dsun.java.command options are
|
|
|
|
// omitted from jvm_args string as each have their own PerfData
|
|
|
|
// string constant object.
|
|
|
|
build_jvm_args(option->optionString);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -verbose:[class/gc/jni]
|
|
|
|
if (match_option(option, "-verbose", &tail)) {
|
|
|
|
if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
|
|
|
|
FLAG_SET_CMDLINE(bool, TraceClassLoading, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, TraceClassUnloading, true);
|
|
|
|
} else if (!strcmp(tail, ":gc")) {
|
|
|
|
FLAG_SET_CMDLINE(bool, PrintGC, true);
|
|
|
|
} else if (!strcmp(tail, ":jni")) {
|
|
|
|
FLAG_SET_CMDLINE(bool, PrintJNIResolving, true);
|
|
|
|
}
|
|
|
|
// -da / -ea / -disableassertions / -enableassertions
|
|
|
|
// These accept an optional class/package name separated by a colon, e.g.,
|
|
|
|
// -da:java.lang.Thread.
|
|
|
|
} else if (match_option(option, user_assertion_options, &tail, true)) {
|
|
|
|
bool enable = option->optionString[1] == 'e'; // char after '-' is 'e'
|
|
|
|
if (*tail == '\0') {
|
|
|
|
JavaAssertions::setUserClassDefault(enable);
|
|
|
|
} else {
|
|
|
|
assert(*tail == ':', "bogus match by match_option()");
|
|
|
|
JavaAssertions::addOption(tail + 1, enable);
|
|
|
|
}
|
|
|
|
// -dsa / -esa / -disablesystemassertions / -enablesystemassertions
|
|
|
|
} else if (match_option(option, system_assertion_options, &tail, false)) {
|
|
|
|
bool enable = option->optionString[1] == 'e'; // char after '-' is 'e'
|
|
|
|
JavaAssertions::setSystemClassDefault(enable);
|
|
|
|
// -bootclasspath:
|
|
|
|
} else if (match_option(option, "-Xbootclasspath:", &tail)) {
|
|
|
|
scp_p->reset_path(tail);
|
|
|
|
*scp_assembly_required_p = true;
|
|
|
|
// -bootclasspath/a:
|
|
|
|
} else if (match_option(option, "-Xbootclasspath/a:", &tail)) {
|
|
|
|
scp_p->add_suffix(tail);
|
|
|
|
*scp_assembly_required_p = true;
|
|
|
|
// -bootclasspath/p:
|
|
|
|
} else if (match_option(option, "-Xbootclasspath/p:", &tail)) {
|
|
|
|
scp_p->add_prefix(tail);
|
|
|
|
*scp_assembly_required_p = true;
|
|
|
|
// -Xrun
|
|
|
|
} else if (match_option(option, "-Xrun", &tail)) {
|
2009-01-21 11:14:19 -05:00
|
|
|
if (tail != NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
const char* pos = strchr(tail, ':');
|
|
|
|
size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
|
2012-06-28 17:03:16 -04:00
|
|
|
char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len);
|
2007-12-01 00:00:00 +00:00
|
|
|
name[len] = '\0';
|
|
|
|
|
|
|
|
char *options = NULL;
|
|
|
|
if(pos != NULL) {
|
|
|
|
size_t len2 = strlen(pos+1) + 1; // options start after ':'. Final zero must be copied.
|
2012-06-28 17:03:16 -04:00
|
|
|
options = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len2, mtInternal), pos+1, len2);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-10-10 14:35:58 -04:00
|
|
|
#if !INCLUDE_JVMTI
|
2007-12-01 00:00:00 +00:00
|
|
|
if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) {
|
2013-03-06 13:38:17 -05:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Profiling and debugging agents are not supported in this VM\n");
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // !INCLUDE_JVMTI
|
2013-03-06 13:38:17 -05:00
|
|
|
add_init_library(name, options);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// -agentlib and -agentpath
|
|
|
|
} else if (match_option(option, "-agentlib:", &tail) ||
|
|
|
|
(is_absolute_path = match_option(option, "-agentpath:", &tail))) {
|
|
|
|
if(tail != NULL) {
|
|
|
|
const char* pos = strchr(tail, '=');
|
|
|
|
size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
|
2012-06-28 17:03:16 -04:00
|
|
|
char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len);
|
2007-12-01 00:00:00 +00:00
|
|
|
name[len] = '\0';
|
|
|
|
|
|
|
|
char *options = NULL;
|
|
|
|
if(pos != NULL) {
|
2012-06-28 17:03:16 -04:00
|
|
|
options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-10-10 14:35:58 -04:00
|
|
|
#if !INCLUDE_JVMTI
|
2013-04-28 18:24:04 -04:00
|
|
|
if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) {
|
2013-03-06 13:38:17 -05:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Profiling and debugging agents are not supported in this VM\n");
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // !INCLUDE_JVMTI
|
2007-12-01 00:00:00 +00:00
|
|
|
add_init_agent(name, options, is_absolute_path);
|
|
|
|
}
|
|
|
|
// -javaagent
|
|
|
|
} else if (match_option(option, "-javaagent:", &tail)) {
|
2012-10-10 14:35:58 -04:00
|
|
|
#if !INCLUDE_JVMTI
|
2013-03-06 13:38:17 -05:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Instrumentation agents are not supported in this VM\n");
|
|
|
|
return JNI_ERR;
|
2012-10-10 14:35:58 -04:00
|
|
|
#else
|
2007-12-01 00:00:00 +00:00
|
|
|
if(tail != NULL) {
|
2012-06-28 17:03:16 -04:00
|
|
|
char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
|
2007-12-01 00:00:00 +00:00
|
|
|
add_init_agent("instrument", options, false);
|
|
|
|
}
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // !INCLUDE_JVMTI
|
2007-12-01 00:00:00 +00:00
|
|
|
// -Xnoclassgc
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xnoclassgc")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, ClassUnloading, false);
|
|
|
|
// -Xconcgc
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xconcgc")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
|
|
|
|
// -Xnoconcgc
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xnoconcgc")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
|
|
|
|
// -Xbatch
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xbatch")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
|
|
|
|
// -Xmn for compatibility with other JVM vendors
|
|
|
|
} else if (match_option(option, "-Xmn", &tail)) {
|
2013-10-04 22:08:37 +02:00
|
|
|
julong long_initial_young_size = 0;
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-10-04 22:08:37 +02:00
|
|
|
"Invalid initial young generation size: %s\n", option->optionString);
|
2007-12-01 00:00:00 +00:00
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size);
|
|
|
|
FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
// -Xms
|
|
|
|
} else if (match_option(option, "-Xms", &tail)) {
|
2008-12-15 13:58:57 -08:00
|
|
|
julong long_initial_heap_size = 0;
|
2013-05-06 17:19:42 +02:00
|
|
|
// an initial heap size of 0 means automatically determine
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid initial heap size: %s\n", option->optionString);
|
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
set_min_heap_size((size_t)long_initial_heap_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Currently the minimum size and the initial heap sizes are the same.
|
2013-10-21 18:56:20 +02:00
|
|
|
// Can be overridden with -XX:InitialHeapSize.
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
// -Xmx
|
2013-05-06 17:19:42 +02:00
|
|
|
} else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
|
2008-12-15 13:58:57 -08:00
|
|
|
julong long_max_heap_size = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid maximum heap size: %s\n", option->optionString);
|
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Xmaxf
|
|
|
|
} else if (match_option(option, "-Xmaxf", &tail)) {
|
2013-10-14 14:21:34 +02:00
|
|
|
char* err;
|
|
|
|
int maxf = (int)(strtod(tail, &err) * 100);
|
2014-01-29 23:17:05 +01:00
|
|
|
if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) {
|
2007-12-01 00:00:00 +00:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Bad max heap free percentage size: %s\n",
|
|
|
|
option->optionString);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
} else {
|
|
|
|
FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf);
|
|
|
|
}
|
|
|
|
// Xminf
|
|
|
|
} else if (match_option(option, "-Xminf", &tail)) {
|
2013-10-14 14:21:34 +02:00
|
|
|
char* err;
|
|
|
|
int minf = (int)(strtod(tail, &err) * 100);
|
2014-01-29 23:17:05 +01:00
|
|
|
if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) {
|
2007-12-01 00:00:00 +00:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Bad min heap free percentage size: %s\n",
|
|
|
|
option->optionString);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
} else {
|
|
|
|
FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf);
|
|
|
|
}
|
|
|
|
// -Xss
|
|
|
|
} else if (match_option(option, "-Xss", &tail)) {
|
2008-12-15 13:58:57 -08:00
|
|
|
julong long_ThreadStackSize = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid thread stack size: %s\n", option->optionString);
|
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
// Internally track ThreadStackSize in units of 1024 bytes.
|
|
|
|
FLAG_SET_CMDLINE(intx, ThreadStackSize,
|
|
|
|
round_to((int)long_ThreadStackSize, K) / K);
|
|
|
|
// -Xoss
|
|
|
|
} else if (match_option(option, "-Xoss", &tail)) {
|
|
|
|
// HotSpot does not have separate native and Java stacks, ignore silently for compatibility
|
2013-07-02 07:51:31 +02:00
|
|
|
} else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) {
|
|
|
|
julong long_CodeCacheExpansionSize = 0;
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size());
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid argument: %s. Must be at least %luK.\n", option->optionString,
|
|
|
|
os::vm_page_size()/K);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize);
|
2011-01-03 14:09:11 -05:00
|
|
|
} else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
|
|
|
|
match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) {
|
2008-12-15 13:58:57 -08:00
|
|
|
julong long_ReservedCodeCacheSize = 0;
|
2013-07-02 07:51:31 +02:00
|
|
|
|
2013-05-31 06:41:50 +02:00
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2013-05-31 06:41:50 +02:00
|
|
|
"Invalid maximum code cache size: %s.\n", option->optionString);
|
2007-12-01 00:00:00 +00:00
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize);
|
2014-09-30 15:44:43 +02:00
|
|
|
// -XX:NonNMethodCodeHeapSize=
|
|
|
|
} else if (match_option(option, "-XX:NonNMethodCodeHeapSize=", &tail)) {
|
|
|
|
julong long_NonNMethodCodeHeapSize = 0;
|
2014-09-17 08:00:07 +02:00
|
|
|
|
2014-09-30 15:44:43 +02:00
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_NonNMethodCodeHeapSize, 1);
|
2014-09-17 08:00:07 +02:00
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2014-09-30 15:44:43 +02:00
|
|
|
"Invalid maximum non-nmethod code heap size: %s.\n", option->optionString);
|
2014-09-17 08:00:07 +02:00
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2014-09-30 15:44:43 +02:00
|
|
|
FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize);
|
2014-09-17 08:00:07 +02:00
|
|
|
// -XX:ProfiledCodeHeapSize=
|
|
|
|
} else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) {
|
|
|
|
julong long_ProfiledCodeHeapSize = 0;
|
|
|
|
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid maximum profiled code heap size: %s.\n", option->optionString);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize);
|
|
|
|
// -XX:NonProfiledCodeHeapSizee=
|
|
|
|
} else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) {
|
|
|
|
julong long_NonProfiledCodeHeapSize = 0;
|
|
|
|
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid maximum non-profiled code heap size: %s.\n", option->optionString);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize);
|
2013-05-16 15:46:49 +02:00
|
|
|
//-XX:IncreaseFirstTierCompileThresholdAt=
|
2014-09-17 08:00:07 +02:00
|
|
|
} else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) {
|
2013-05-16 15:46:49 +02:00
|
|
|
uintx uint_IncreaseFirstTierCompileThresholdAt = 0;
|
|
|
|
if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n",
|
|
|
|
option->optionString);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
|
2007-12-01 00:00:00 +00:00
|
|
|
// -green
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-green")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Green threads support not available\n");
|
|
|
|
return JNI_EINVAL;
|
|
|
|
// -native
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-native")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// HotSpot always uses native threads, ignore silently for compatibility
|
|
|
|
// -Xsqnopause
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xsqnopause")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// EVM option, ignore silently for compatibility
|
|
|
|
// -Xrs
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xrs")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Classic/EVM option, new functionality
|
|
|
|
FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true);
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xusealtsigs")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// change default internal VM signals used - lower case for back compat
|
|
|
|
FLAG_SET_CMDLINE(bool, UseAltSigs, true);
|
|
|
|
// -Xoptimize
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xoptimize")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// EVM option, ignore silently for compatibility
|
|
|
|
// -Xprof
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xprof")) {
|
2012-10-10 14:35:58 -04:00
|
|
|
#if INCLUDE_FPROF
|
2007-12-01 00:00:00 +00:00
|
|
|
_has_profile = true;
|
2012-10-10 14:35:58 -04:00
|
|
|
#else // INCLUDE_FPROF
|
2013-03-06 13:38:17 -05:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Flat profiling is not supported in this VM.\n");
|
|
|
|
return JNI_ERR;
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // INCLUDE_FPROF
|
2007-12-01 00:00:00 +00:00
|
|
|
// -Xconcurrentio
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xconcurrentio")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
|
|
|
|
FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1);
|
|
|
|
FLAG_SET_CMDLINE(bool, UseTLAB, false);
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// -Xinternalversion
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xinternalversion")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
jio_fprintf(defaultStream::output_stream(), "%s\n",
|
|
|
|
VM_Version::internal_vm_info_string());
|
|
|
|
vm_exit(0);
|
|
|
|
#ifndef PRODUCT
|
|
|
|
// -Xprintflags
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xprintflags")) {
|
2012-01-09 10:27:24 +01:00
|
|
|
CommandLineFlags::printFlags(tty, false);
|
2007-12-01 00:00:00 +00:00
|
|
|
vm_exit(0);
|
|
|
|
#endif
|
|
|
|
// -D
|
|
|
|
} else if (match_option(option, "-D", &tail)) {
|
2014-12-17 12:29:27 -08:00
|
|
|
const char* value;
|
|
|
|
if (match_option(option, "-Djava.endorsed.dirs=", &value) &&
|
|
|
|
*value!= '\0' && strcmp(value, "\"\"") != 0) {
|
2014-12-03 14:21:14 +00:00
|
|
|
// abort if -Djava.endorsed.dirs is set
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
2014-12-17 12:29:27 -08:00
|
|
|
"-Djava.endorsed.dirs=%s is not supported. Endorsed standards and standalone APIs\n"
|
|
|
|
"in modular form will be supported via the concept of upgradeable modules.\n", value);
|
2014-12-03 14:21:14 +00:00
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2014-12-17 12:29:27 -08:00
|
|
|
if (match_option(option, "-Djava.ext.dirs=", &value) &&
|
|
|
|
*value != '\0' && strcmp(value, "\"\"") != 0) {
|
2014-12-03 14:21:14 +00:00
|
|
|
// abort if -Djava.ext.dirs is set
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
2014-12-17 12:29:27 -08:00
|
|
|
"-Djava.ext.dirs=%s is not supported. Use -classpath instead.\n", value);
|
2014-12-03 14:21:14 +00:00
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!add_property(tail)) {
|
|
|
|
return JNI_ENOMEM;
|
|
|
|
}
|
|
|
|
// Out of the box management support
|
|
|
|
if (match_option(option, "-Dcom.sun.management", &tail)) {
|
2013-02-05 13:32:34 -05:00
|
|
|
#if INCLUDE_MANAGEMENT
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, ManagementServer, true);
|
2013-02-05 13:32:34 -05:00
|
|
|
#else
|
2013-03-06 13:38:17 -05:00
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"-Dcom.sun.management is not supported in this VM.\n");
|
|
|
|
return JNI_ERR;
|
2013-02-05 13:32:34 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// -Xint
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xint")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
set_mode_flags(_int);
|
|
|
|
// -Xmixed
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xmixed")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
set_mode_flags(_mixed);
|
|
|
|
// -Xcomp
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xcomp")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// for testing the compiler; turn off all flags that inhibit compilation
|
|
|
|
set_mode_flags(_comp);
|
|
|
|
// -Xshare:dump
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xshare:dump")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
|
|
|
|
set_mode_flags(_int); // Prevent compilation, which creates objects
|
|
|
|
// -Xshare:on
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xshare:on")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
|
|
|
|
// -Xshare:auto
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xshare:auto")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
|
|
|
|
// -Xshare:off
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xshare:off")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, UseSharedSpaces, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
|
|
|
|
// -Xverify
|
|
|
|
} else if (match_option(option, "-Xverify", &tail)) {
|
|
|
|
if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) {
|
|
|
|
FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
|
|
|
|
} else if (strcmp(tail, ":remote") == 0) {
|
|
|
|
FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
|
|
|
|
} else if (strcmp(tail, ":none") == 0) {
|
|
|
|
FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false);
|
|
|
|
} else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
// -Xdebug
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xdebug")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// note this flag has been used, then ignore
|
|
|
|
set_xdebug_mode(true);
|
|
|
|
// -Xnoagent
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xnoagent")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// For compatibility with classic. HotSpot refuses to load the old style agent.dll.
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-Xboundthreads")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Bind user level threads to kernel threads (Solaris only)
|
|
|
|
FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
|
|
|
|
} else if (match_option(option, "-Xloggc:", &tail)) {
|
|
|
|
// Redirect GC output to the file. -Xloggc:<filename>
|
|
|
|
// ostream_init_log(), when called will use this filename
|
|
|
|
// to initialize a fileStream.
|
2014-08-11 10:18:09 -07:00
|
|
|
_gc_log_filename = os::strdup_check_oom(tail);
|
2013-09-16 15:35:04 -07:00
|
|
|
if (!is_filename_valid(_gc_log_filename)) {
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"Invalid file name for use with -Xloggc: Filename can only contain the "
|
|
|
|
"characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
|
|
|
|
"Note %%p or %%t can only be used once\n", _gc_log_filename);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, PrintGC, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
|
|
|
|
|
|
|
|
// JNI hooks
|
|
|
|
} else if (match_option(option, "-Xcheck", &tail)) {
|
|
|
|
if (!strcmp(tail, ":jni")) {
|
2012-10-10 14:35:58 -04:00
|
|
|
#if !INCLUDE_JNI_CHECK
|
|
|
|
warning("JNI CHECKING is not supported in this VM");
|
|
|
|
#else
|
2007-12-01 00:00:00 +00:00
|
|
|
CheckJNICalls = true;
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // INCLUDE_JNI_CHECK
|
2007-12-01 00:00:00 +00:00
|
|
|
} else if (is_bad_option(option, args->ignoreUnrecognized,
|
|
|
|
"check")) {
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "vfprintf")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "exit")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "abort")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
|
|
|
|
// -XX:+AggressiveHeap
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+AggressiveHeap")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// This option inspects the machine and attempts to set various
|
|
|
|
// parameters to be optimal for long-running, memory allocation
|
|
|
|
// intensive jobs. It is intended for machines with large
|
|
|
|
// amounts of cpu and memory.
|
|
|
|
|
|
|
|
// initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
|
|
|
|
// VM, but we may not be able to represent the total physical memory
|
|
|
|
// available (like having 8gb of memory on a box but using a 32bit VM).
|
|
|
|
// Thus, we need to make sure we're using a julong for intermediate
|
|
|
|
// calculations.
|
|
|
|
julong initHeapSize;
|
|
|
|
julong total_memory = os::physical_memory();
|
|
|
|
|
|
|
|
if (total_memory < (julong)256*M) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
|
|
|
|
vm_exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The heap size is half of available memory, or (at most)
|
|
|
|
// all of possible memory less 160mb (leaving room for the OS
|
|
|
|
// when using ISM). This is the maximum; because adaptive sizing
|
|
|
|
// is turned on below, the actual space used may be smaller.
|
|
|
|
|
|
|
|
initHeapSize = MIN2(total_memory / (julong)2,
|
|
|
|
total_memory - (julong)160*M);
|
|
|
|
|
2013-03-27 19:21:18 +01:00
|
|
|
initHeapSize = limit_by_allocatable_memory(initHeapSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize);
|
|
|
|
FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Currently the minimum size and the initial heap sizes are the same.
|
2009-10-28 16:25:51 -04:00
|
|
|
set_min_heap_size(initHeapSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
if (FLAG_IS_DEFAULT(NewSize)) {
|
|
|
|
// Make the young generation 3/8ths of the total heap.
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, NewSize,
|
2007-12-01 00:00:00 +00:00
|
|
|
((julong)MaxHeapSize / (julong)8) * (julong)3);
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 16:33:40 -04:00
|
|
|
#ifndef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_DEFAULT(UseLargePages, true);
|
2012-10-25 16:33:40 -04:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Increase some data structure sizes for efficiency
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, TLABSize, 256*K);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// See the OldPLABSize comment below, but replace 'after promotion'
|
|
|
|
// with 'after copying'. YoungPLABSize is the size of the survivor
|
|
|
|
// space per-gc-thread buffers. The default is 4kw.
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256*K); // Note: this is in words
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// OldPLABSize is the size of the buffers in the old gen that
|
|
|
|
// UseParallelGC uses to promote live data that doesn't fit in the
|
|
|
|
// survivor spaces. At any given time, there's one for each gc thread.
|
|
|
|
// The default size is 1kw. These buffers are rarely used, since the
|
|
|
|
// survivor spaces are usually big enough. For specjbb, however, there
|
|
|
|
// are occasions when there's lots of live data in the young gen
|
|
|
|
// and we end up promoting some of it. We don't have a definite
|
|
|
|
// explanation for why bumping OldPLABSize helps, but the theory
|
|
|
|
// is that a bigger PLAB results in retaining something like the
|
|
|
|
// original allocation order after promotion, which improves mutator
|
|
|
|
// locality. A minor effect may be that larger PLABs reduce the
|
|
|
|
// number of PLAB allocation events during gc. The value of 8kw
|
|
|
|
// was arrived at by experimenting with specjbb.
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, OldPLABSize, 8*K); // Note: this is in words
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Enable parallel GC and adaptive generation sizing
|
|
|
|
FLAG_SET_CMDLINE(bool, UseParallelGC, true);
|
2008-02-22 17:17:14 -08:00
|
|
|
FLAG_SET_DEFAULT(ParallelGCThreads,
|
|
|
|
Abstract_VM_Version::parallel_worker_threads());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Encourage steady state memory management
|
|
|
|
FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100);
|
|
|
|
|
|
|
|
// This appears to improve mutator locality
|
|
|
|
FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
|
|
|
|
|
|
|
|
// Get around early Solaris scheduling bug
|
|
|
|
// (affinity vs other jobs on system)
|
|
|
|
// but disallow DR and offlining (5008695).
|
|
|
|
FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true);
|
|
|
|
|
2014-03-26 12:49:34 +01:00
|
|
|
// Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
|
|
|
|
// and the last option wins.
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+NeverTenure")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, NeverTenure, true);
|
2014-03-26 12:49:34 +01:00
|
|
|
FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
|
|
|
|
FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1);
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+AlwaysTenure")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, NeverTenure, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
|
2014-03-26 12:49:34 +01:00
|
|
|
FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0);
|
|
|
|
} else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) {
|
|
|
|
uintx max_tenuring_thresh = 0;
|
|
|
|
if(!parse_uintx(tail, &max_tenuring_thresh, 0)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid MaxTenuringThreshold: %s\n", option->optionString);
|
|
|
|
}
|
|
|
|
FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh);
|
|
|
|
|
|
|
|
if (MaxTenuringThreshold == 0) {
|
|
|
|
FLAG_SET_CMDLINE(bool, NeverTenure, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
|
|
|
|
} else {
|
|
|
|
FLAG_SET_CMDLINE(bool, NeverTenure, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
|
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true);
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
|
|
|
|
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
|
2011-10-13 09:35:42 -07:00
|
|
|
#if defined(DTRACE_ENABLED)
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
|
2011-10-13 09:35:42 -07:00
|
|
|
#else // defined(DTRACE_ENABLED)
|
2007-12-01 00:00:00 +00:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
2011-10-13 09:35:42 -07:00
|
|
|
"ExtendedDTraceProbes flag is not applicable for this configuration\n");
|
2007-12-01 00:00:00 +00:00
|
|
|
return JNI_EINVAL;
|
2011-10-13 09:35:42 -07:00
|
|
|
#endif // defined(DTRACE_ENABLED)
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+FullGCALot")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_CMDLINE(bool, FullGCALot, true);
|
|
|
|
// disable scavenge before parallel mark-compact
|
|
|
|
FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
|
|
|
|
#endif
|
2010-02-24 07:00:33 -08:00
|
|
|
} else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) ||
|
|
|
|
match_option(option, "-XX:G1MarkStackSize=", &tail)) {
|
|
|
|
julong stack_size = 0;
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &stack_size, 1);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid mark stack size: %s\n", option->optionString);
|
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2014-12-17 18:09:24 +01:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Please use -XX:MarkStackSize in place of "
|
|
|
|
"-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n");
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MarkStackSize, stack_size);
|
2010-02-24 07:00:33 -08:00
|
|
|
} else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
|
|
|
|
julong max_stack_size = 0;
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid maximum mark stack size: %s\n",
|
|
|
|
option->optionString);
|
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2014-12-17 18:09:24 +01:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Please use -XX:MarkStackSizeMax in place of "
|
|
|
|
"-XX:CMSMarkStackSizeMax in the future\n");
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MarkStackSizeMax, max_stack_size);
|
2010-02-24 07:00:33 -08:00
|
|
|
} else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
|
|
|
|
match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
|
|
|
|
uintx conc_threads = 0;
|
|
|
|
if (!parse_uintx(tail, &conc_threads, 1)) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid concurrent threads: %s\n", option->optionString);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2014-12-17 18:09:24 +01:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Please use -XX:ConcGCThreads in place of "
|
|
|
|
"-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n");
|
2010-02-24 07:00:33 -08:00
|
|
|
FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
|
2012-07-03 01:41:29 -04:00
|
|
|
} else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
|
|
|
|
julong max_direct_memory_size = 0;
|
|
|
|
ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
|
|
|
|
if (errcode != arg_in_range) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Invalid maximum direct memory size: %s\n",
|
|
|
|
option->optionString);
|
|
|
|
describe_range_error(errcode);
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2015-03-03 18:01:27 +01:00
|
|
|
FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size);
|
2013-02-05 13:32:34 -05:00
|
|
|
#if !INCLUDE_MANAGEMENT
|
2014-12-11 02:43:50 +01:00
|
|
|
} else if (match_option(option, "-XX:+ManagementServer")) {
|
2013-03-06 13:38:17 -05:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"ManagementServer is not supported in this VM.\n");
|
|
|
|
return JNI_ERR;
|
2013-02-05 13:32:34 -05:00
|
|
|
#endif // INCLUDE_MANAGEMENT
|
2009-12-23 09:23:54 -08:00
|
|
|
} else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
|
2007-12-01 00:00:00 +00:00
|
|
|
// Skip -XX:Flags= since that case has already been handled
|
|
|
|
if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
|
|
|
|
if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Unknown option
|
|
|
|
} else if (is_bad_option(option, args->ignoreUnrecognized)) {
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
|
|
|
}
|
2011-06-10 15:08:36 -07:00
|
|
|
|
2014-08-12 17:29:00 -07:00
|
|
|
// PrintSharedArchiveAndExit will turn on
|
|
|
|
// -Xshare:on
|
|
|
|
// -XX:+TraceClassPaths
|
|
|
|
if (PrintSharedArchiveAndExit) {
|
|
|
|
FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
|
|
|
|
FLAG_SET_CMDLINE(bool, TraceClassPaths, true);
|
|
|
|
}
|
|
|
|
|
2008-11-22 00:16:09 -08:00
|
|
|
// Change the default value for flags which have different default values
|
|
|
|
// when working with older JDKs.
|
2010-07-28 17:38:21 +01:00
|
|
|
#ifdef LINUX
|
|
|
|
if (JDK_Version::current().compare_major(6) <= 0 &&
|
|
|
|
FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
|
|
|
|
FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
|
|
|
|
}
|
|
|
|
#endif // LINUX
|
2014-08-12 17:29:00 -07:00
|
|
|
fix_appclasspath();
|
2007-12-01 00:00:00 +00:00
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-12 17:29:00 -07:00
|
|
|
// Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
|
|
|
|
//
|
|
|
|
// This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
|
|
|
|
// in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
|
|
|
|
// Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
|
|
|
|
// path is treated as the current directory.
|
|
|
|
//
|
|
|
|
// This causes problems with CDS, which requires that all directories specified in the classpath
|
|
|
|
// must be empty. In most cases, applications do NOT want to load classes from the current
|
|
|
|
// directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
|
|
|
|
// scripts compatible with CDS.
|
|
|
|
void Arguments::fix_appclasspath() {
|
|
|
|
if (IgnoreEmptyClassPaths) {
|
|
|
|
const char separator = *os::path_separator();
|
|
|
|
const char* src = _java_class_path->value();
|
|
|
|
|
|
|
|
// skip over all the leading empty paths
|
|
|
|
while (*src == separator) {
|
|
|
|
src ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* copy = AllocateHeap(strlen(src) + 1, mtInternal);
|
|
|
|
strncpy(copy, src, strlen(src) + 1);
|
|
|
|
|
|
|
|
// trim all trailing empty paths
|
|
|
|
for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
|
|
|
|
*tail = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
char from[3] = {separator, separator, '\0'};
|
|
|
|
char to [2] = {separator, '\0'};
|
|
|
|
while (StringUtils::replace_no_expand(copy, from, to) > 0) {
|
|
|
|
// Keep replacing "::" -> ":" until we have no more "::" (non-windows)
|
|
|
|
// Keep replacing ";;" -> ";" until we have no more ";;" (windows)
|
|
|
|
}
|
|
|
|
|
|
|
|
_java_class_path->set_value(copy);
|
|
|
|
FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!PrintSharedArchiveAndExit) {
|
|
|
|
ClassLoader::trace_class_path("[classpath: ", _java_class_path->value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-03 14:21:14 +00:00
|
|
|
static bool has_jar_files(const char* directory) {
|
|
|
|
DIR* dir = os::opendir(directory);
|
|
|
|
if (dir == NULL) return false;
|
|
|
|
|
|
|
|
struct dirent *entry;
|
|
|
|
char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
|
|
|
|
bool hasJarFile = false;
|
|
|
|
while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
|
|
|
|
const char* name = entry->d_name;
|
|
|
|
const char* ext = name + strlen(name) - 4;
|
|
|
|
hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0);
|
|
|
|
}
|
2014-12-05 16:36:07 -08:00
|
|
|
FREE_C_HEAP_ARRAY(char, dbuf);
|
2014-12-03 14:21:14 +00:00
|
|
|
os::closedir(dir);
|
|
|
|
return hasJarFile ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int check_non_empty_dirs(const char* path) {
|
|
|
|
const char separator = *os::path_separator();
|
|
|
|
const char* const end = path + strlen(path);
|
|
|
|
int nonEmptyDirs = 0;
|
|
|
|
while (path < end) {
|
|
|
|
const char* tmp_end = strchr(path, separator);
|
|
|
|
if (tmp_end == NULL) {
|
|
|
|
if (has_jar_files(path)) {
|
|
|
|
nonEmptyDirs++;
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"Non-empty directory: %s\n", path);
|
|
|
|
}
|
|
|
|
path = end;
|
|
|
|
} else {
|
|
|
|
char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1, mtInternal);
|
|
|
|
memcpy(dirpath, path, tmp_end - path);
|
|
|
|
dirpath[tmp_end - path] = '\0';
|
|
|
|
if (has_jar_files(dirpath)) {
|
|
|
|
nonEmptyDirs++;
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"Non-empty directory: %s\n", dirpath);
|
|
|
|
}
|
2014-12-05 16:36:07 -08:00
|
|
|
FREE_C_HEAP_ARRAY(char, dirpath);
|
2014-12-03 14:21:14 +00:00
|
|
|
path = tmp_end + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nonEmptyDirs;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
|
2014-12-03 14:21:14 +00:00
|
|
|
// check if the default lib/endorsed directory exists; if so, error
|
|
|
|
char path[JVM_MAXPATHLEN];
|
|
|
|
const char* fileSep = os::file_separator();
|
|
|
|
sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
|
|
|
|
|
|
|
|
if (CheckEndorsedAndExtDirs) {
|
|
|
|
int nonEmptyDirs = 0;
|
|
|
|
// check endorsed directory
|
|
|
|
nonEmptyDirs += check_non_empty_dirs(path);
|
|
|
|
// check the extension directories
|
|
|
|
nonEmptyDirs += check_non_empty_dirs(Arguments::get_ext_dirs());
|
|
|
|
if (nonEmptyDirs > 0) {
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DIR* dir = os::opendir(path);
|
|
|
|
if (dir != NULL) {
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
|
|
|
|
"in modular form will be supported via the concept of upgradeable modules.\n");
|
|
|
|
os::closedir(dir);
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(path, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
|
|
|
|
dir = os::opendir(path);
|
|
|
|
if (dir != NULL) {
|
|
|
|
jio_fprintf(defaultStream::output_stream(),
|
|
|
|
"<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
|
|
|
|
"Use -classpath instead.\n.");
|
|
|
|
os::closedir(dir);
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-12-03 14:21:14 +00:00
|
|
|
if (scp_assembly_required) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Assemble the bootclasspath elements into the final path.
|
|
|
|
Arguments::set_sysclasspath(scp_p->combined_path());
|
|
|
|
}
|
|
|
|
|
|
|
|
// This must be done after all arguments have been processed.
|
|
|
|
// java_compiler() true means set to "NONE" or empty.
|
|
|
|
if (java_compiler() && !xdebug_mode()) {
|
|
|
|
// For backwards compatibility, we switch to interpreted mode if
|
|
|
|
// -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
|
|
|
|
// not specified.
|
|
|
|
set_mode_flags(_int);
|
|
|
|
}
|
2014-10-15 14:00:41 +02:00
|
|
|
|
2015-01-26 10:43:42 +01:00
|
|
|
// CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
|
|
|
|
// but like -Xint, leave compilation thresholds unaffected.
|
|
|
|
// With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
|
|
|
|
if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
set_mode_flags(_int);
|
|
|
|
}
|
|
|
|
|
2013-05-16 23:51:51 +02:00
|
|
|
// eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
|
|
|
|
if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
|
|
|
|
FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifndef COMPILER2
|
|
|
|
// Don't degrade server performance for footprint
|
|
|
|
if (FLAG_IS_DEFAULT(UseLargePages) &&
|
|
|
|
MaxHeapSize < LargePageHeapSizeThreshold) {
|
|
|
|
// No need for large granularity pages w/small heaps.
|
|
|
|
// Note that large pages are enabled/disabled for both the
|
|
|
|
// Java heap and the code cache.
|
|
|
|
FLAG_SET_DEFAULT(UseLargePages, false);
|
|
|
|
}
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
#else
|
|
|
|
if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
|
|
|
|
FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-29 11:54:18 +04:00
|
|
|
#ifndef TIERED
|
|
|
|
// Tiered compilation is undefined.
|
|
|
|
UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
|
|
|
|
#endif
|
|
|
|
|
2010-08-03 08:13:38 -04:00
|
|
|
// If we are running in a headless jre, force java.awt.headless property
|
|
|
|
// to be true unless the property has already been set.
|
|
|
|
// Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
|
|
|
|
if (os::is_headless_jre()) {
|
|
|
|
const char* headless = Arguments::get_property("java.awt.headless");
|
|
|
|
if (headless == NULL) {
|
2015-03-30 17:32:18 -04:00
|
|
|
const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
|
|
|
|
if (headless_env == NULL) {
|
2010-08-03 08:13:38 -04:00
|
|
|
if (!add_property("java.awt.headless=true")) {
|
|
|
|
return JNI_ENOMEM;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
char buffer[256];
|
2015-03-30 17:32:18 -04:00
|
|
|
const char *key = "java.awt.headless=";
|
|
|
|
strcpy(buffer, key);
|
|
|
|
strncat(buffer, headless_env, 256 - strlen(key) - 1);
|
2010-08-03 08:13:38 -04:00
|
|
|
if (!add_property(buffer)) {
|
|
|
|
return JNI_ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-27 21:02:13 +01:00
|
|
|
if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) {
|
|
|
|
// CMS can only be used with ParNew
|
|
|
|
FLAG_SET_ERGO(bool, UseParNewGC, true);
|
|
|
|
}
|
|
|
|
|
2014-11-25 13:41:08 +01:00
|
|
|
if (!check_vm_args_consistency()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return JNI_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) {
|
|
|
|
return parse_options_environment_variable("_JAVA_OPTIONS", scp_p,
|
|
|
|
scp_assembly_required_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) {
|
|
|
|
return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p,
|
|
|
|
scp_assembly_required_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) {
|
2015-03-30 17:32:18 -04:00
|
|
|
char *buffer = ::getenv(name);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Don't check this variable if user has special privileges
|
|
|
|
// (e.g. unix su command).
|
2015-03-30 17:32:18 -04:00
|
|
|
if (buffer == NULL || os::have_special_privileges()) {
|
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((buffer = os::strdup(buffer)) == NULL) {
|
|
|
|
return JNI_ENOMEM;
|
|
|
|
}
|
|
|
|
|
2015-04-01 15:27:04 +02:00
|
|
|
GrowableArray<JavaVMOption> *options = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<JavaVMOption>(2, true); // Construct option array
|
2015-03-30 17:32:18 -04:00
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Picked up %s: %s\n", name, buffer);
|
|
|
|
char* rd = buffer; // pointer to the input string (rd)
|
|
|
|
while (true) { // repeat for all options in the input string
|
|
|
|
while (isspace(*rd)) rd++; // skip whitespace
|
|
|
|
if (*rd == 0) break; // we re done when the input string is read completely
|
|
|
|
|
|
|
|
// The output, option string, overwrites the input string.
|
|
|
|
// Because of quoting, the pointer to the option string (wrt) may lag the pointer to
|
|
|
|
// input string (rd).
|
|
|
|
char* wrt = rd;
|
|
|
|
|
|
|
|
JavaVMOption option;
|
|
|
|
option.optionString = wrt;
|
2015-04-01 15:27:04 +02:00
|
|
|
options->append(option); // Fill in option
|
2015-03-30 17:32:18 -04:00
|
|
|
while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL
|
|
|
|
if (*rd == '\'' || *rd == '"') { // handle a quoted string
|
|
|
|
int quote = *rd; // matching quote to look for
|
|
|
|
rd++; // don't copy open quote
|
|
|
|
while (*rd != quote) { // include everything (even spaces) up until quote
|
|
|
|
if (*rd == 0) { // string termination means unmatched string
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Unmatched quote in %s\n", name);
|
2015-04-01 15:27:04 +02:00
|
|
|
delete options;
|
2015-03-30 17:32:18 -04:00
|
|
|
os::free(buffer);
|
|
|
|
return JNI_ERR;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-03-30 17:32:18 -04:00
|
|
|
*wrt++ = *rd++; // copy to option string
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-03-30 17:32:18 -04:00
|
|
|
rd++; // don't copy close quote
|
|
|
|
} else {
|
|
|
|
*wrt++ = *rd++; // copy to option string
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-30 17:32:18 -04:00
|
|
|
// Need to check if we're done before writing a NULL,
|
|
|
|
// because the write could be to the byte that rd is pointing to.
|
|
|
|
if (*rd++ == 0) {
|
|
|
|
*wrt = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*wrt = 0; // Zero terminate option
|
|
|
|
}
|
|
|
|
JavaVMOption* options_arr =
|
2015-04-01 15:27:04 +02:00
|
|
|
NEW_C_HEAP_ARRAY_RETURN_NULL(JavaVMOption, options->length(), mtInternal);
|
2015-03-30 17:32:18 -04:00
|
|
|
if (options_arr == NULL) {
|
2015-04-01 15:27:04 +02:00
|
|
|
delete options;
|
|
|
|
os::free(buffer);
|
2015-03-30 17:32:18 -04:00
|
|
|
return JNI_ENOMEM;
|
|
|
|
}
|
2015-04-01 15:27:04 +02:00
|
|
|
for (int i = 0; i < options->length(); i++) {
|
|
|
|
options_arr[i] = options->at(i);
|
2015-03-30 17:32:18 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-03-30 17:32:18 -04:00
|
|
|
// Construct JavaVMInitArgs structure and parse as if it was part of the command line
|
|
|
|
JavaVMInitArgs vm_args;
|
|
|
|
vm_args.version = JNI_VERSION_1_2;
|
|
|
|
vm_args.options = options_arr;
|
2015-04-01 15:27:04 +02:00
|
|
|
vm_args.nOptions = options->length();
|
2015-03-30 17:32:18 -04:00
|
|
|
vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
|
|
|
|
|
|
|
|
if (PrintVMOptions) {
|
|
|
|
const char* tail;
|
|
|
|
for (int i = 0; i < vm_args.nOptions; i++) {
|
|
|
|
const JavaVMOption *option = vm_args.options + i;
|
|
|
|
if (match_option(option, "-XX:", &tail)) {
|
|
|
|
logOption(tail);
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-03-30 17:32:18 -04:00
|
|
|
|
|
|
|
jint result = parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p,
|
|
|
|
Flag::ENVIRON_VAR);
|
|
|
|
FREE_C_HEAP_ARRAY(JavaVMOption, options_arr);
|
2015-04-01 15:27:04 +02:00
|
|
|
delete options;
|
2015-03-30 17:32:18 -04:00
|
|
|
os::free(buffer);
|
|
|
|
return result;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-03-06 11:37:18 -08:00
|
|
|
void Arguments::set_shared_spaces_flags() {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (DumpSharedSpaces) {
|
|
|
|
if (RequireSharedSpaces) {
|
|
|
|
warning("cannot dump shared archive while using shared archive");
|
|
|
|
}
|
|
|
|
UseSharedSpaces = false;
|
2013-08-15 20:04:10 -04:00
|
|
|
#ifdef _LP64
|
2013-08-12 17:37:02 +02:00
|
|
|
if (!UseCompressedOops || !UseCompressedClassPointers) {
|
2013-08-15 20:04:10 -04:00
|
|
|
vm_exit_during_initialization(
|
2013-08-12 17:37:02 +02:00
|
|
|
"Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
} else {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (!UseCompressedOops || !UseCompressedClassPointers) {
|
2014-08-12 17:29:00 -07:00
|
|
|
no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
#endif
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2011-03-06 11:37:18 -08:00
|
|
|
}
|
2010-11-02 16:02:46 -07:00
|
|
|
|
2013-04-04 10:01:26 -07:00
|
|
|
#if !INCLUDE_ALL_GCS
|
2013-02-14 11:08:58 -05:00
|
|
|
static void force_serial_gc() {
|
|
|
|
FLAG_SET_DEFAULT(UseSerialGC, true);
|
|
|
|
UNSUPPORTED_GC_OPTION(UseG1GC);
|
|
|
|
UNSUPPORTED_GC_OPTION(UseParallelGC);
|
|
|
|
UNSUPPORTED_GC_OPTION(UseParallelOldGC);
|
|
|
|
UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
|
|
|
|
UNSUPPORTED_GC_OPTION(UseParNewGC);
|
|
|
|
}
|
2013-04-04 10:01:26 -07:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2013-02-14 11:08:58 -05:00
|
|
|
|
2013-05-14 09:17:52 -04:00
|
|
|
// Sharing support
|
|
|
|
// Construct the path to the archive
|
|
|
|
static char* get_shared_archive_path() {
|
|
|
|
char *shared_archive_path;
|
|
|
|
if (SharedArchiveFile == NULL) {
|
|
|
|
char jvm_path[JVM_MAXPATHLEN];
|
|
|
|
os::jvm_path(jvm_path, sizeof(jvm_path));
|
|
|
|
char *end = strrchr(jvm_path, *os::file_separator());
|
|
|
|
if (end != NULL) *end = '\0';
|
|
|
|
size_t jvm_path_len = strlen(jvm_path);
|
|
|
|
size_t file_sep_len = strlen(os::file_separator());
|
|
|
|
shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len +
|
|
|
|
file_sep_len + 20, mtInternal);
|
|
|
|
if (shared_archive_path != NULL) {
|
|
|
|
strncpy(shared_archive_path, jvm_path, jvm_path_len + 1);
|
|
|
|
strncat(shared_archive_path, os::file_separator(), file_sep_len);
|
|
|
|
strncat(shared_archive_path, "classes.jsa", 11);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal);
|
|
|
|
if (shared_archive_path != NULL) {
|
|
|
|
strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return shared_archive_path;
|
|
|
|
}
|
|
|
|
|
2013-09-13 04:16:54 -07:00
|
|
|
#ifndef PRODUCT
|
|
|
|
// Determine whether LogVMOutput should be implicitly turned on.
|
|
|
|
static bool use_vm_log() {
|
|
|
|
if (LogCompilation || !FLAG_IS_DEFAULT(LogFile) ||
|
|
|
|
PrintCompilation || PrintInlining || PrintDependencies || PrintNativeNMethods ||
|
|
|
|
PrintDebugInfo || PrintRelocations || PrintNMethods || PrintExceptionHandlers ||
|
|
|
|
PrintAssembly || TraceDeoptimization || TraceDependencies ||
|
|
|
|
(VerifyDependencies && FLAG_IS_CMDLINE(VerifyDependencies))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COMPILER1
|
|
|
|
if (PrintC1Statistics) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif // COMPILER1
|
|
|
|
|
|
|
|
#ifdef COMPILER2
|
|
|
|
if (PrintOptoAssembly || PrintOptoStatistics) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif // COMPILER2
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Parse entry point called from JNI_CreateJavaVM
|
|
|
|
|
|
|
|
jint Arguments::parse(const JavaVMInitArgs* args) {
|
|
|
|
|
|
|
|
// Remaining part of option string
|
|
|
|
const char* tail;
|
|
|
|
|
|
|
|
// If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
|
2012-07-02 10:54:17 -04:00
|
|
|
const char* hotspotrc = ".hotspotrc";
|
2007-12-01 00:00:00 +00:00
|
|
|
bool settings_file_specified = false;
|
2012-07-02 10:54:17 -04:00
|
|
|
bool needs_hotspotrc_warning = false;
|
|
|
|
|
2009-02-05 13:38:52 -08:00
|
|
|
const char* flags_file;
|
2007-12-01 00:00:00 +00:00
|
|
|
int index;
|
|
|
|
for (index = 0; index < args->nOptions; index++) {
|
|
|
|
const JavaVMOption *option = args->options + index;
|
2014-10-16 14:11:53 -04:00
|
|
|
if (ArgumentsExt::process_options(option)) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if (match_option(option, "-XX:Flags=", &tail)) {
|
2009-02-05 13:38:52 -08:00
|
|
|
flags_file = tail;
|
2007-12-01 00:00:00 +00:00
|
|
|
settings_file_specified = true;
|
2014-10-16 14:11:53 -04:00
|
|
|
continue;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
if (match_option(option, "-XX:+PrintVMOptions")) {
|
2007-12-01 00:00:00 +00:00
|
|
|
PrintVMOptions = true;
|
2014-10-16 14:11:53 -04:00
|
|
|
continue;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
if (match_option(option, "-XX:-PrintVMOptions")) {
|
2008-07-28 17:12:52 -07:00
|
|
|
PrintVMOptions = false;
|
2014-10-16 14:11:53 -04:00
|
|
|
continue;
|
2008-07-28 17:12:52 -07:00
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
if (match_option(option, "-XX:+IgnoreUnrecognizedVMOptions")) {
|
2009-02-05 13:38:52 -08:00
|
|
|
IgnoreUnrecognizedVMOptions = true;
|
2014-10-16 14:11:53 -04:00
|
|
|
continue;
|
2009-02-05 13:38:52 -08:00
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
if (match_option(option, "-XX:-IgnoreUnrecognizedVMOptions")) {
|
2009-02-05 13:38:52 -08:00
|
|
|
IgnoreUnrecognizedVMOptions = false;
|
2014-10-16 14:11:53 -04:00
|
|
|
continue;
|
2009-02-05 13:38:52 -08:00
|
|
|
}
|
2014-12-11 02:43:50 +01:00
|
|
|
if (match_option(option, "-XX:+PrintFlagsInitial")) {
|
2012-01-09 10:27:24 +01:00
|
|
|
CommandLineFlags::printFlags(tty, false);
|
2010-01-07 16:24:17 -08:00
|
|
|
vm_exit(0);
|
|
|
|
}
|
2012-10-10 14:35:58 -04:00
|
|
|
#if INCLUDE_NMT
|
2014-08-07 12:18:58 -07:00
|
|
|
if (match_option(option, "-XX:NativeMemoryTracking", &tail)) {
|
|
|
|
// The launcher did not setup nmt environment variable properly.
|
2014-08-14 13:15:23 -04:00
|
|
|
if (!MemTracker::check_launcher_nmt_support(tail)) {
|
|
|
|
warning("Native Memory Tracking did not setup properly, using wrong launcher?");
|
|
|
|
}
|
2014-08-07 12:18:58 -07:00
|
|
|
|
|
|
|
// Verify if nmt option is valid.
|
|
|
|
if (MemTracker::verify_nmt_option()) {
|
|
|
|
// Late initialization, still in single-threaded mode.
|
|
|
|
if (MemTracker::tracking_level() >= NMT_summary) {
|
|
|
|
MemTracker::init();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
|
|
|
|
}
|
2014-10-16 14:11:53 -04:00
|
|
|
continue;
|
2012-06-28 17:03:16 -04:00
|
|
|
}
|
2014-08-07 12:18:58 -07:00
|
|
|
#endif
|
2012-06-28 17:03:16 -04:00
|
|
|
|
2010-08-31 03:14:00 -07:00
|
|
|
|
|
|
|
#ifndef PRODUCT
|
2014-12-11 02:43:50 +01:00
|
|
|
if (match_option(option, "-XX:+PrintFlagsWithComments")) {
|
2012-01-09 10:27:24 +01:00
|
|
|
CommandLineFlags::printFlags(tty, true);
|
2010-08-31 03:14:00 -07:00
|
|
|
vm_exit(0);
|
|
|
|
}
|
|
|
|
#endif
|
2009-02-05 13:38:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IgnoreUnrecognizedVMOptions) {
|
|
|
|
// uncast const to modify the flag args->ignoreUnrecognized
|
|
|
|
*(jboolean*)(&args->ignoreUnrecognized) = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse specified settings file
|
|
|
|
if (settings_file_specified) {
|
|
|
|
if (!process_settings_file(flags_file, true, args->ignoreUnrecognized)) {
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2012-07-02 10:54:17 -04:00
|
|
|
} else {
|
2012-03-29 18:55:32 -04:00
|
|
|
#ifdef ASSERT
|
2012-07-02 10:54:17 -04:00
|
|
|
// Parse default .hotspotrc settings file
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) {
|
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
2012-07-02 10:54:17 -04:00
|
|
|
#else
|
|
|
|
struct stat buf;
|
|
|
|
if (os::stat(hotspotrc, &buf) == 0) {
|
|
|
|
needs_hotspotrc_warning = true;
|
|
|
|
}
|
2012-03-29 18:55:32 -04:00
|
|
|
#endif
|
2012-07-02 10:54:17 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (PrintVMOptions) {
|
|
|
|
for (index = 0; index < args->nOptions; index++) {
|
|
|
|
const JavaVMOption *option = args->options + index;
|
|
|
|
if (match_option(option, "-XX:", &tail)) {
|
|
|
|
logOption(tail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS
|
|
|
|
jint result = parse_vm_init_args(args);
|
|
|
|
if (result != JNI_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-05-14 09:17:52 -04:00
|
|
|
// Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
|
|
|
|
SharedArchivePath = get_shared_archive_path();
|
|
|
|
if (SharedArchivePath == NULL) {
|
|
|
|
return JNI_ENOMEM;
|
|
|
|
}
|
|
|
|
|
2014-10-14 18:47:46 -07:00
|
|
|
// Set up VerifySharedSpaces
|
|
|
|
if (FLAG_IS_DEFAULT(VerifySharedSpaces) && SharedArchiveFile != NULL) {
|
|
|
|
VerifySharedSpaces = true;
|
|
|
|
}
|
|
|
|
|
2012-07-02 10:54:17 -04:00
|
|
|
// Delay warning until here so that we've had a chance to process
|
|
|
|
// the -XX:-PrintWarnings flag
|
|
|
|
if (needs_hotspotrc_warning) {
|
|
|
|
warning("%s file is present but has been ignored. "
|
|
|
|
"Run with -XX:Flags=%s to load the file.",
|
|
|
|
hotspotrc, hotspotrc);
|
|
|
|
}
|
|
|
|
|
2012-10-25 16:33:40 -04:00
|
|
|
#ifdef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
|
|
|
|
UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages");
|
|
|
|
#endif
|
|
|
|
|
2015-02-04 13:14:27 -05:00
|
|
|
ArgumentsExt::report_unsupported_options();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifndef PRODUCT
|
|
|
|
if (TraceBytecodesAt != 0) {
|
|
|
|
TraceBytecodes = true;
|
|
|
|
}
|
|
|
|
if (CountCompiledCalls) {
|
|
|
|
if (UseCounterDecay) {
|
|
|
|
warning("UseCounterDecay disabled because CountCalls is set");
|
|
|
|
UseCounterDecay = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
2014-04-29 08:08:44 +02:00
|
|
|
if (ScavengeRootsInCode == 0) {
|
2009-09-15 21:53:47 -07:00
|
|
|
if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
|
2014-04-29 08:08:44 +02:00
|
|
|
warning("forcing ScavengeRootsInCode non-zero");
|
2009-09-15 21:53:47 -07:00
|
|
|
}
|
|
|
|
ScavengeRootsInCode = 1;
|
|
|
|
}
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (PrintGCDetails) {
|
|
|
|
// Turn on -verbose:gc options as well
|
|
|
|
PrintGC = true;
|
|
|
|
}
|
|
|
|
|
2010-05-27 18:01:56 -07:00
|
|
|
// Set object alignment values.
|
|
|
|
set_object_alignment();
|
|
|
|
|
2013-01-23 13:02:39 -05:00
|
|
|
#if !INCLUDE_ALL_GCS
|
2009-10-28 16:25:51 -04:00
|
|
|
force_serial_gc();
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2012-10-10 14:35:58 -04:00
|
|
|
#if !INCLUDE_CDS
|
2013-03-06 13:38:17 -05:00
|
|
|
if (DumpSharedSpaces || RequireSharedSpaces) {
|
|
|
|
jio_fprintf(defaultStream::error_stream(),
|
|
|
|
"Shared spaces are not supported in this VM\n");
|
|
|
|
return JNI_ERR;
|
|
|
|
}
|
2013-03-12 00:02:16 -04:00
|
|
|
if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
|
2013-03-06 13:38:17 -05:00
|
|
|
warning("Shared spaces are not supported in this VM");
|
|
|
|
FLAG_SET_DEFAULT(UseSharedSpaces, false);
|
|
|
|
FLAG_SET_DEFAULT(PrintSharedSpaces, false);
|
|
|
|
}
|
2014-08-12 17:29:00 -07:00
|
|
|
no_shared_spaces("CDS Disabled");
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // INCLUDE_CDS
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-09-11 16:25:02 +02:00
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
jint Arguments::apply_ergo() {
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Set flags based on ergonomics.
|
|
|
|
set_ergonomics_flags();
|
|
|
|
|
2011-03-06 11:37:18 -08:00
|
|
|
set_shared_spaces_flags();
|
2010-01-04 18:38:08 +01:00
|
|
|
|
2008-02-22 17:17:14 -08:00
|
|
|
// Check the GC selections again.
|
2015-03-02 11:08:09 +01:00
|
|
|
if (!check_gc_consistency()) {
|
2008-02-22 17:17:14 -08:00
|
|
|
return JNI_EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-09-03 17:51:07 -07:00
|
|
|
if (TieredCompilation) {
|
|
|
|
set_tiered_flags();
|
|
|
|
} else {
|
|
|
|
// Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
|
|
|
|
if (CompilationPolicyChoice >= 2) {
|
|
|
|
vm_exit_during_initialization(
|
|
|
|
"Incompatible compilation policy selected", NULL);
|
|
|
|
}
|
2014-10-15 14:00:41 +02:00
|
|
|
// Scale CompileThreshold
|
2015-02-06 18:16:55 +01:00
|
|
|
// CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves CompileThreshold unchanged.
|
|
|
|
if (!FLAG_IS_DEFAULT(CompileThresholdScaling) && CompileThresholdScaling > 0.0) {
|
2015-01-21 10:51:35 +01:00
|
|
|
FLAG_SET_ERGO(intx, CompileThreshold, scaled_compile_threshold(CompileThreshold));
|
2014-10-15 14:00:41 +02:00
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
2014-10-15 10:51:43 +02:00
|
|
|
|
|
|
|
#ifdef COMPILER2
|
|
|
|
#ifndef PRODUCT
|
|
|
|
if (PrintIdealGraphLevel > 0) {
|
|
|
|
FLAG_SET_ERGO(bool, PrintIdealGraph, true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-03-16 10:37:08 -07:00
|
|
|
// Set heap size based on available physical memory
|
|
|
|
set_heap_size();
|
2012-10-10 14:35:58 -04:00
|
|
|
|
2014-11-25 13:41:08 +01:00
|
|
|
ArgumentsExt::set_gc_specific_flags();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-01-23 14:47:23 +01:00
|
|
|
// Initialize Metaspace flags and alignments
|
2013-10-07 15:51:08 +02:00
|
|
|
Metaspace::ergo_initialize();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Set bytecode rewriting flags
|
|
|
|
set_bytecode_flags();
|
|
|
|
|
2014-01-23 14:47:23 +01:00
|
|
|
// Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled
|
2007-12-01 00:00:00 +00:00
|
|
|
set_aggressive_opts_flags();
|
|
|
|
|
2011-02-16 11:34:44 -05:00
|
|
|
// Turn off biased locking for locking debug mode flags,
|
2014-01-23 14:47:23 +01:00
|
|
|
// which are subtly different from each other but neither works with
|
|
|
|
// biased locking
|
2011-03-03 19:51:36 -05:00
|
|
|
if (UseHeavyMonitors
|
|
|
|
#ifdef COMPILER1
|
|
|
|
|| !UseFastLocking
|
|
|
|
#endif // COMPILER1
|
|
|
|
) {
|
2011-02-16 11:34:44 -05:00
|
|
|
if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
|
|
|
|
// flag set to true on command line; warn the user that they
|
|
|
|
// can't enable biased locking here
|
|
|
|
warning("Biased Locking is not supported with locking debug flags"
|
|
|
|
"; ignoring UseBiasedLocking flag." );
|
|
|
|
}
|
|
|
|
UseBiasedLocking = false;
|
|
|
|
}
|
|
|
|
|
2013-09-15 15:28:58 +02:00
|
|
|
#ifdef ZERO
|
|
|
|
// Clear flags not supported on zero.
|
2010-01-04 00:22:57 -08:00
|
|
|
FLAG_SET_DEFAULT(ProfileInterpreter, false);
|
2007-12-01 00:00:00 +00:00
|
|
|
FLAG_SET_DEFAULT(UseBiasedLocking, false);
|
2010-01-04 00:22:57 -08:00
|
|
|
LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
|
2013-08-12 17:37:02 +02:00
|
|
|
LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
|
2010-01-04 00:22:57 -08:00
|
|
|
#endif // CC_INTERP
|
|
|
|
|
2008-11-07 09:29:38 -08:00
|
|
|
#ifdef COMPILER2
|
2012-01-07 13:26:43 -08:00
|
|
|
if (!EliminateLocks) {
|
|
|
|
EliminateNestedLocks = false;
|
|
|
|
}
|
2012-12-23 17:08:22 +01:00
|
|
|
if (!Inline) {
|
|
|
|
IncrementalInline = false;
|
|
|
|
}
|
|
|
|
#ifndef PRODUCT
|
|
|
|
if (!IncrementalInline) {
|
|
|
|
AlwaysIncrementalInline = false;
|
|
|
|
}
|
|
|
|
#endif
|
2013-10-23 12:40:23 +02:00
|
|
|
if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) {
|
|
|
|
// nothing to use the profiling, turn if off
|
|
|
|
FLAG_SET_DEFAULT(TypeProfileLevel, 0);
|
|
|
|
}
|
2008-11-07 09:29:38 -08:00
|
|
|
#endif
|
|
|
|
|
2010-01-08 13:47:01 -08:00
|
|
|
if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
|
|
|
|
warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
|
|
|
|
DebugNonSafepoints = true;
|
|
|
|
}
|
|
|
|
|
2013-08-12 17:37:02 +02:00
|
|
|
if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
|
|
|
|
warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
|
|
|
|
}
|
|
|
|
|
2010-01-26 08:53:24 -08:00
|
|
|
#ifndef PRODUCT
|
2013-09-13 04:16:54 -07:00
|
|
|
if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
|
|
|
|
if (use_vm_log()) {
|
|
|
|
LogVMOutput = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
2010-01-26 08:53:24 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (PrintCommandLineFlags) {
|
2012-01-09 10:27:24 +01:00
|
|
|
CommandLineFlags::printSetFlags(tty);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 08:13:38 -04:00
|
|
|
// Apply CPU specific policy for the BiasedLocking
|
|
|
|
if (UseBiasedLocking) {
|
|
|
|
if (!VM_Version::use_biased_locking() &&
|
|
|
|
!(FLAG_IS_CMDLINE(UseBiasedLocking))) {
|
|
|
|
UseBiasedLocking = false;
|
|
|
|
}
|
|
|
|
}
|
2014-03-20 17:49:27 -07:00
|
|
|
#ifdef COMPILER2
|
|
|
|
if (!UseBiasedLocking || EmitSync != 0) {
|
|
|
|
UseOptoBiasInlining = false;
|
|
|
|
}
|
|
|
|
#endif
|
2010-08-03 08:13:38 -04:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-20 11:40:11 +01:00
|
|
|
jint Arguments::adjust_after_os() {
|
2014-01-16 13:25:25 -08:00
|
|
|
if (UseNUMA) {
|
|
|
|
if (UseParallelGC || UseParallelOldGC) {
|
2012-11-20 11:40:11 +01:00
|
|
|
if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
|
2014-01-16 13:25:25 -08:00
|
|
|
FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
|
2012-11-20 11:40:11 +01:00
|
|
|
}
|
2014-01-16 13:25:25 -08:00
|
|
|
}
|
|
|
|
// UseNUMAInterleaving is set to ON for all collectors and
|
|
|
|
// platforms when UseNUMA is set to ON. NUMA-aware collectors
|
|
|
|
// such as the parallel collector for Linux and Solaris will
|
|
|
|
// interleave old gen and survivor spaces on top of NUMA
|
|
|
|
// allocation policy for the eden space.
|
|
|
|
// Non NUMA-aware collectors such as CMS, G1 and Serial-GC on
|
|
|
|
// all platforms and ParallelGC on Windows will interleave all
|
|
|
|
// of the heap spaces across NUMA nodes.
|
|
|
|
if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) {
|
|
|
|
FLAG_SET_ERGO(bool, UseNUMAInterleaving, true);
|
2012-11-20 11:40:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return JNI_OK;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
int Arguments::PropertyList_count(SystemProperty* pl) {
|
|
|
|
int count = 0;
|
|
|
|
while(pl != NULL) {
|
|
|
|
count++;
|
|
|
|
pl = pl->next();
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) {
|
|
|
|
assert(key != NULL, "just checking");
|
|
|
|
SystemProperty* prop;
|
|
|
|
for (prop = pl; prop != NULL; prop = prop->next()) {
|
|
|
|
if (strcmp(key, prop->key()) == 0) return prop->value();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) {
|
|
|
|
int count = 0;
|
|
|
|
const char* ret_val = NULL;
|
|
|
|
|
|
|
|
while(pl != NULL) {
|
|
|
|
if(count >= index) {
|
|
|
|
ret_val = pl->key();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
pl = pl->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* Arguments::PropertyList_get_value_at(SystemProperty* pl, int index) {
|
|
|
|
int count = 0;
|
|
|
|
char* ret_val = NULL;
|
|
|
|
|
|
|
|
while(pl != NULL) {
|
|
|
|
if(count >= index) {
|
|
|
|
ret_val = pl->value();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
pl = pl->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments::PropertyList_add(SystemProperty** plist, SystemProperty *new_p) {
|
|
|
|
SystemProperty* p = *plist;
|
|
|
|
if (p == NULL) {
|
|
|
|
*plist = new_p;
|
|
|
|
} else {
|
|
|
|
while (p->next() != NULL) {
|
|
|
|
p = p->next();
|
|
|
|
}
|
|
|
|
p->set_next(new_p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments::PropertyList_add(SystemProperty** plist, const char* k, char* v) {
|
|
|
|
if (plist == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SystemProperty* new_p = new SystemProperty(k, v, true);
|
|
|
|
PropertyList_add(plist, new_p);
|
|
|
|
}
|
|
|
|
|
2015-01-05 12:07:37 -05:00
|
|
|
void Arguments::PropertyList_add(SystemProperty *element) {
|
|
|
|
PropertyList_add(&_system_properties, element);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// This add maintains unique property key in the list.
|
2009-04-01 16:38:01 -04:00
|
|
|
void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, char* v, jboolean append) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (plist == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If property key exist then update with new value.
|
|
|
|
SystemProperty* prop;
|
|
|
|
for (prop = *plist; prop != NULL; prop = prop->next()) {
|
|
|
|
if (strcmp(k, prop->key()) == 0) {
|
2009-04-01 16:38:01 -04:00
|
|
|
if (append) {
|
|
|
|
prop->append_value(v);
|
|
|
|
} else {
|
|
|
|
prop->set_value(v);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyList_add(plist, k, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copies src into buf, replacing "%%" with "%" and "%p" with pid
|
|
|
|
// Returns true if all of the source pointed by src has been copied over to
|
|
|
|
// the destination buffer pointed by buf. Otherwise, returns false.
|
|
|
|
// Notes:
|
|
|
|
// 1. If the length (buflen) of the destination buffer excluding the
|
|
|
|
// NULL terminator character is not long enough for holding the expanded
|
|
|
|
// pid characters, it also returns false instead of returning the partially
|
|
|
|
// expanded one.
|
|
|
|
// 2. The passed in "buflen" should be large enough to hold the null terminator.
|
|
|
|
bool Arguments::copy_expand_pid(const char* src, size_t srclen,
|
|
|
|
char* buf, size_t buflen) {
|
|
|
|
const char* p = src;
|
|
|
|
char* b = buf;
|
|
|
|
const char* src_end = &src[srclen];
|
|
|
|
char* buf_end = &buf[buflen - 1];
|
|
|
|
|
|
|
|
while (p < src_end && b < buf_end) {
|
|
|
|
if (*p == '%') {
|
|
|
|
switch (*(++p)) {
|
|
|
|
case '%': // "%%" ==> "%"
|
|
|
|
*b++ = *p++;
|
|
|
|
break;
|
|
|
|
case 'p': { // "%p" ==> current process id
|
|
|
|
// buf_end points to the character before the last character so
|
|
|
|
// that we could write '\0' to the end of the buffer.
|
|
|
|
size_t buf_sz = buf_end - b + 1;
|
|
|
|
int ret = jio_snprintf(b, buf_sz, "%d", os::current_process_id());
|
|
|
|
|
|
|
|
// if jio_snprintf fails or the buffer is not long enough to hold
|
|
|
|
// the expanded pid, returns false.
|
|
|
|
if (ret < 0 || ret >= (int)buf_sz) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
b += ret;
|
|
|
|
assert(*b == '\0', "fail in copy_expand_pid");
|
|
|
|
if (p == src_end && b == buf_end + 1) {
|
|
|
|
// reach the end of the buffer.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default :
|
|
|
|
*b++ = '%';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*b++ = *p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*b = '\0';
|
|
|
|
return (p == src_end); // return false if not all of the source was copied
|
|
|
|
}
|