提交 89037d56 编写于 作者: J jcoomes

8057531: refactor gc argument processing code slightly

Reviewed-by: mgerdin, tschatzl, jmasa
上级 a69a7e6b
......@@ -1532,24 +1532,25 @@ void Arguments::set_conservative_max_heap_alignment() {
CollectorPolicy::compute_heap_alignment());
}
void Arguments::set_ergonomics_flags() {
void Arguments::select_gc_ergonomically() {
if (os::is_server_class_machine()) {
// If no other collector is requested explicitly,
// let the VM select the collector based on
// machine class and automatic selection policy.
if (!UseSerialGC &&
!UseConcMarkSweepGC &&
!UseG1GC &&
!UseParNewGC &&
FLAG_IS_DEFAULT(UseParallelGC)) {
if (should_auto_select_low_pause_collector()) {
FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
} else {
FLAG_SET_ERGO(bool, UseParallelGC, true);
}
}
}
void Arguments::select_gc() {
if (!gc_selected()) {
select_gc_ergonomically();
}
}
void Arguments::set_ergonomics_flags() {
select_gc();
#ifdef COMPILER2
// Shared spaces work fine with other GCs but causes bytecode rewriting
// to be disabled, which hurts interpreter performance and decreases
......@@ -1669,6 +1670,46 @@ void Arguments::set_g1_gc_flags() {
}
}
#if !INCLUDE_ALL_GCS
#ifdef ASSERT
static bool verify_serial_gc_flags() {
return (UseSerialGC &&
!(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
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();
} else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
set_cms_and_parnew_gc_flags();
} else if (UseParNewGC) { // Skipped if CMS is set above
set_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_gc_flags();
}
check_deprecated_gcs();
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
}
julong Arguments::limit_by_allocatable_memory(julong limit) {
julong max_allocatable;
julong result = limit;
......@@ -1892,16 +1933,6 @@ bool Arguments::verify_percentage(uintx value, const char* name) {
return false;
}
#if !INCLUDE_ALL_GCS
#ifdef ASSERT
static bool verify_serial_gc_flags() {
return (UseSerialGC &&
!(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
UseParallelGC || UseParallelOldGC));
}
#endif // ASSERT
#endif // INCLUDE_ALL_GCS
// check if do gclog rotation
// +UseGCLogFileRotation is a must,
// no gc log rotation when log file not supplied or
......@@ -3784,33 +3815,7 @@ jint Arguments::apply_ergo() {
// Set heap size based on available physical memory
set_heap_size();
#if INCLUDE_ALL_GCS
// Set per-collector flags
if (UseParallelGC || UseParallelOldGC) {
set_parallel_gc_flags();
} else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
set_cms_and_parnew_gc_flags();
} else if (UseParNewGC) { // Skipped if CMS is set above
set_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_gc_flags();
}
check_deprecated_gcs();
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
set_gc_specific_flags();
// Initialize Metaspace flags and alignments.
Metaspace::ergo_initialize();
......
......@@ -338,8 +338,10 @@ class Arguments : AllStatic {
static void set_conservative_max_heap_alignment();
static void set_use_compressed_oops();
static void set_use_compressed_klass_ptrs();
static void select_gc();
static void set_ergonomics_flags();
static void set_shared_spaces_flags();
static void set_gc_specific_flags();
// limits the given memory size by the maximum amount of memory this process is
// currently allowed to allocate or reserve.
static julong limit_by_allocatable_memory(julong size);
......@@ -451,6 +453,9 @@ class Arguments : AllStatic {
// Adjusts the arguments after the OS have adjusted the arguments
static jint adjust_after_os();
static inline bool gc_selected(); // whether a gc has been selected
static void select_gc_ergonomically();
// Verifies that the given value will fit as a MinHeapFreeRatio. If not, an error
// message is returned in the provided buffer.
static bool verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio);
......@@ -602,4 +607,8 @@ class Arguments : AllStatic {
static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
};
bool Arguments::gc_selected() {
return UseConcMarkSweepGC || UseG1GC || UseParallelGC || UseParallelOldGC ||
UseParNewGC || UseSerialGC;
}
#endif // SHARE_VM_RUNTIME_ARGUMENTS_HPP
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册