< prev index next >
src/share/vm/runtime/arguments.cpp
Print this page
@@ -30,10 +30,11 @@
#include "code/codeCacheExtensions.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/taskqueue.hpp"
+#include "logging/log.hpp"
#include "logging/logConfiguration.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/universe.inline.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiExport.hpp"
@@ -79,11 +80,10 @@
int Arguments::_num_jvm_flags = 0;
char** Arguments::_jvm_args_array = NULL;
int Arguments::_num_jvm_args = 0;
char* Arguments::_java_command = NULL;
SystemProperty* Arguments::_system_properties = NULL;
-const char* Arguments::_gc_log_filename = NULL;
bool Arguments::_has_profile = false;
size_t Arguments::_conservative_max_heap_alignment = 0;
size_t Arguments::_min_heap_size = 0;
Arguments::Mode Arguments::_mode = _mixed;
bool Arguments::_java_compiler = false;
@@ -1615,47 +1615,33 @@
if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
} else {
FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
}
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
- }
+ log_trace(gc, heap)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
// Code along this path potentially sets NewSize and OldSize
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
- " initial_heap_size: " SIZE_FORMAT
- " max_heap: " SIZE_FORMAT,
+ log_trace(gc, heap)("CMS set min_heap_size: " SIZE_FORMAT " initial_heap_size: " SIZE_FORMAT " max_heap: " SIZE_FORMAT,
min_heap_size(), InitialHeapSize, max_heap);
- }
size_t min_new = preferred_max_new_size;
if (FLAG_IS_CMDLINE(NewSize)) {
min_new = NewSize;
}
if (max_heap > min_new && min_heap_size() > min_new) {
// Unless explicitly requested otherwise, make young gen
// at least min_new, and at most preferred_max_new_size.
if (FLAG_IS_DEFAULT(NewSize)) {
FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
- }
+ log_trace(gc, heap)("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
}
// Unless explicitly requested otherwise, size old gen
// so it's NewRatio x of NewSize.
if (FLAG_IS_DEFAULT(OldSize)) {
if (max_heap > NewSize) {
FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
- if (PrintGCDetails && Verbose) {
- // Too early to use gclog_or_tty
- tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
- }
+ log_trace(gc, heap)("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
}
}
}
}
// Unless explicitly requested otherwise, definitely
@@ -1695,15 +1681,12 @@
if (!ClassUnloading) {
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
}
- if (PrintGCDetails && Verbose) {
- tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
- (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
- tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
- }
+ log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
+ log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
}
#endif // INCLUDE_ALL_GCS
void set_object_alignment() {
// Object alignment.
@@ -1746,15 +1729,11 @@
bool Arguments::should_auto_select_low_pause_collector() {
if (UseAutoGCSelectPolicy &&
!FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
(MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
- if (PrintGCDetails) {
- // Cannot use gclog_or_tty yet.
- tty->print_cr("Automatic selection of the low pause collector"
- " based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
- }
+ log_trace(gc)("Automatic selection of the low pause collector based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
return true;
}
return false;
}
@@ -1972,15 +1951,12 @@
// (especially small GC stress tests that the main thing they do
// is allocation). We might consider increase it further.
FLAG_SET_DEFAULT(GCTimeRatio, 9);
}
- if (PrintGCDetails && Verbose) {
- tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
- (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
- tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
- }
+ log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
+ log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
}
#if !INCLUDE_ALL_GCS
#ifdef ASSERT
static bool verify_serial_gc_flags() {
@@ -2088,14 +2064,11 @@
// after call to limit_by_allocatable_memory because that
// method might reduce the allocation size.
reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
}
- if (PrintGCDetails && Verbose) {
- // Cannot use gclog_or_tty yet.
- tty->print_cr(" Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
- }
+ log_trace(gc, heap)(" Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
}
// If the minimum or initial heap_size have not been set or requested to be set
// ergonomically, set them accordingly.
@@ -2112,24 +2085,18 @@
reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
- if (PrintGCDetails && Verbose) {
- // Cannot use gclog_or_tty yet.
- tty->print_cr(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
- }
+ log_trace(gc, heap)(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
}
// 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) {
set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
- if (PrintGCDetails && Verbose) {
- // Cannot use gclog_or_tty yet.
- tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
- }
+ log_trace(gc, heap)(" Minimum heap size " SIZE_FORMAT, min_heap_size());
}
}
}
// This option inspects the machine and attempts to set various
@@ -2328,81 +2295,12 @@
}
//===========================================================================================================
// Parsing of main arguments
-// check if do gclog rotation
-// +UseGCLogFileRotation is a must,
-// no gc log rotation when log file not supplied or
-// NumberOfGCLogFiles is 0
-void check_gclog_consistency() {
- if (UseGCLogFileRotation) {
- if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
- jio_fprintf(defaultStream::output_stream(),
- "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
- "where num_of_file > 0\n"
- "GC log rotation is turned off\n");
- UseGCLogFileRotation = false;
- }
- }
-
- if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
- if (FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K) == Flag::SUCCESS) {
- jio_fprintf(defaultStream::output_stream(),
- "GCLogFileSize changed to minimum 8K\n");
- }
- }
-}
-
-// 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;
-}
-
// Check consistency of GC selection
bool Arguments::check_gc_consistency() {
- check_gclog_consistency();
// Ensure that the user has not selected conflicting sets
// of collectors.
uint i = 0;
if (UseSerialGC) i++;
if (UseConcMarkSweepGC) i++;
@@ -2748,11 +2646,12 @@
}
if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) {
return JNI_EINVAL;
}
} else if (!strcmp(tail, ":gc")) {
- if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) {
+ bool ret = LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
+ if (!ret) {
return JNI_EINVAL;
}
} else if (!strcmp(tail, ":jni")) {
if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
return JNI_EINVAL;
@@ -3181,28 +3080,10 @@
// note this flag has been used, then ignore
set_xdebug_mode(true);
// -Xnoagent
} else if (match_option(option, "-Xnoagent")) {
// For compatibility with classic. HotSpot refuses to load the old style agent.dll.
- } 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.
- _gc_log_filename = os::strdup_check_oom(tail);
- 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;
- }
- if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) {
- return JNI_EINVAL;
- }
- if (FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true) != Flag::SUCCESS) {
- return JNI_EINVAL;
- }
} else if (match_option(option, "-Xlog", &tail)) {
bool ret = false;
if (strcmp(tail, ":help") == 0) {
LogConfiguration::print_command_line_help(defaultStream::output_stream());
vm_exit(0);
@@ -4203,15 +4084,10 @@
warning("Forcing ScavengeRootsInCode non-zero");
}
ScavengeRootsInCode = 1;
}
- if (PrintGCDetails) {
- // Turn on -verbose:gc options as well
- PrintGC = true;
- }
-
// Set object alignment values.
set_object_alignment();
#if !INCLUDE_ALL_GCS
force_serial_gc();
< prev index next >