This commit is contained in:
Bob Vandette 2017-11-16 09:50:49 -05:00
commit 68c5f06bc1
30 changed files with 1946 additions and 411 deletions

@ -0,0 +1,194 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/cms/cmsArguments.hpp"
#include "gc/cms/compactibleFreeListSpace.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "runtime/arguments.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/defaultStream.hpp"
size_t CMSArguments::conservative_max_heap_alignment() {
return GenCollectedHeap::conservative_max_heap_alignment();
}
void CMSArguments::set_parnew_gc_flags() {
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
"control point invariant");
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
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);
}
// 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");
}
FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
}
assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
}
// Adjust some sizes to suit CMS and/or ParNew needs; these work well on
// sparc/solaris for certain applications, but would gain from
// further optimization and tuning efforts, and would almost
// certainly gain from analysis of platform and environment.
void CMSArguments::initialize_flags() {
GCArguments::initialize_flags();
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
// Set CMS global values
CompactibleFreeListSpace::set_cms_values();
// Turn off AdaptiveSizePolicy by default for cms until it is complete.
disable_adaptive_size_policy("UseConcMarkSweepGC");
set_parnew_gc_flags();
size_t max_heap = align_down(MaxHeapSize,
CardTableRS::ct_max_alignment_constraint());
// Now make adjustments for CMS
intx tenuring_default = (intx)6;
size_t young_gen_per_worker = CMSYoungGenPerWorker;
// Preferred young gen size for "short" pauses:
// upper bound depends on # of threads and NewRatio.
const size_t preferred_max_new_size_unaligned =
MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
size_t preferred_max_new_size =
align_up(preferred_max_new_size_unaligned, os::vm_page_size());
// Unless explicitly requested otherwise, size young gen
// for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
// If either MaxNewSize or NewRatio is set on the command line,
// assume the user is trying to set the size of the young gen.
if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
// Set MaxNewSize to our calculated preferred_max_new_size unless
// NewSize was set on the command line and it is larger than
// preferred_max_new_size.
if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
} else {
FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
}
log_trace(gc, heap)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
// Code along this path potentially sets NewSize and OldSize
log_trace(gc, heap)("CMS set min_heap_size: " SIZE_FORMAT " initial_heap_size: " SIZE_FORMAT " max_heap: " SIZE_FORMAT,
Arguments::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 && Arguments::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));
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));
log_trace(gc, heap)("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
}
}
}
}
// Unless explicitly requested otherwise, definitely
// promote all objects surviving "tenuring_default" scavenges.
if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
FLAG_IS_DEFAULT(SurvivorRatio)) {
FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
}
// If we decided above (or user explicitly requested)
// `promote all' (via MaxTenuringThreshold := 0),
// prefer minuscule survivor spaces so as not to waste
// space for (non-existent) survivors
if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
}
// 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.
FLAG_SET_ERGO(size_t, OldPLABSize, CompactibleFreeListSpaceLAB::_default_static_old_plab_size); // default value before 6631166
} else {
FLAG_SET_DEFAULT(OldPLABSize, CompactibleFreeListSpaceLAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
}
}
// If either of the static initialization defaults have changed, note this
// modification.
if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
CompactibleFreeListSpaceLAB::modify_initialization(OldPLABSize, OldPLABWeight);
}
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
}
void CMSArguments::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);
}
}

@ -0,0 +1,39 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_CMS_CMSARGUMENTS_HPP
#define SHARE_GC_CMS_CMSARGUMENTS_HPP
#include "gc/shared/gcArguments.hpp"
class CMSArguments : public GCArguments {
private:
void disable_adaptive_size_policy(const char* collector_name);
void set_parnew_gc_flags();
public:
virtual void initialize_flags();
virtual size_t conservative_max_heap_alignment();
};
#endif // SHARE_GC_CMS_CMSARGUMENTS_HPP

@ -0,0 +1,92 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/g1/g1Arguments.hpp"
#include "gc/g1/heapRegion.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/vm_version.hpp"
size_t G1Arguments::conservative_max_heap_alignment() {
return HeapRegion::max_region_size();
}
void G1Arguments::initialize_flags() {
GCArguments::initialize_flags();
assert(UseG1GC, "Error");
#if defined(COMPILER1) || INCLUDE_JVMCI
FastTLABRefill = false;
#endif
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
if (ParallelGCThreads == 0) {
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);
}
#if INCLUDE_ALL_GCS
if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
FLAG_SET_ERGO(uint, G1ConcRefinementThreads, ParallelGCThreads);
}
#endif
// 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);
}
if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
// In G1, we want the default GC overhead goal to be higher than
// it is for PS, or the heap might be expanded too aggressively.
// We set it here to ~8%.
FLAG_SET_DEFAULT(GCTimeRatio, 12);
}
// Below, we might need to calculate the pause time interval based on
// the pause target. When we do so we are going to give G1 maximum
// flexibility and allow it to do pauses when it needs to. So, we'll
// arrange that the pause interval to be pause time target + 1 to
// ensure that a) the pause time target is maximized with respect to
// the pause interval and b) we maintain the invariant that pause
// time target < pause interval. If the user does not want this
// maximum flexibility, they will have to set the pause interval
// explicitly.
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
// The default pause time target in G1 is 200ms
FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
}
// Then, if the interval parameter was not set, set it according to
// the pause time target (this will also deal with the case when the
// pause time target is the default value).
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
}
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
}

@ -0,0 +1,36 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_G1_G1ARGUMENTS_HPP
#define SHARE_GC_G1_G1ARGUMENTS_HPP
#include "gc/shared/gcArguments.hpp"
class G1Arguments : public GCArguments {
public:
virtual void initialize_flags();
virtual size_t conservative_max_heap_alignment();
};
#endif // SHARE_GC_G1_G1ARGUMENTS_HPP

@ -0,0 +1,89 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/parallel/parallelArguments.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/defaultStream.hpp"
size_t ParallelArguments::conservative_max_heap_alignment() {
return CollectorPolicy::compute_heap_alignment();
}
void ParallelArguments::initialize_flags() {
GCArguments::initialize_flags();
assert(UseParallelGC || UseParallelOldGC, "Error");
// Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
FLAG_SET_DEFAULT(UseParallelOldGC, true);
}
FLAG_SET_DEFAULT(UseParallelGC, true);
// If no heap maximum was requested explicitly, use some reasonable fraction
// of the physical memory, up to a maximum of 1GB.
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);
}
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);
}
if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
}
}
// 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);
}
if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
}
}
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);
}
}
}

@ -0,0 +1,36 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_PARALLEL_PARALLELARGUMENTS_HPP
#define SHARE_GC_PARALLEL_PARALLELARGUMENTS_HPP
#include "gc/shared/gcArguments.hpp"
class ParallelArguments : public GCArguments {
public:
virtual void initialize_flags();
virtual size_t conservative_max_heap_alignment();
};
#endif // SHARE_GC_CMS_PARALLELARGUMENTS_HPP

@ -167,10 +167,8 @@ void GenMarkSweep::allocate_stacks() {
void GenMarkSweep::deallocate_stacks() {
if (!UseG1GC) {
GenCollectedHeap* gch = GenCollectedHeap::heap();
gch->release_scratch();
}
GenCollectedHeap* gch = GenCollectedHeap::heap();
gch->release_scratch();
_preserved_mark_stack.clear(true);
_preserved_oop_stack.clear(true);

@ -29,7 +29,6 @@
class GenMarkSweep : public MarkSweep {
friend class VM_MarkSweep;
friend class G1MarkSweep;
public:
static void invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_softrefs);

@ -40,9 +40,6 @@
#include "oops/typeArrayOop.inline.hpp"
#include "utilities/macros.hpp"
#include "utilities/stack.inline.hpp"
#if INCLUDE_ALL_GCS
#include "gc/g1/g1StringDedup.hpp"
#endif // INCLUDE_ALL_GCS
uint MarkSweep::_total_invocations = 0;
@ -79,8 +76,7 @@ template <class T> inline void MarkSweep::mark_and_push(T* p) {
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
if (!obj->mark()->is_marked() &&
!is_closed_archive_object(obj)) {
if (!obj->mark()->is_marked()) {
mark_object(obj);
_marking_stack.push(obj);
}
@ -176,8 +172,7 @@ template <class T> inline void MarkSweep::follow_root(T* p) {
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
if (!obj->mark()->is_marked() &&
!is_closed_archive_object(obj)) {
if (!obj->mark()->is_marked()) {
mark_object(obj);
follow_object(obj);
}
@ -261,7 +256,7 @@ void MarkSweep::restore_marks() {
MarkSweep::IsAliveClosure MarkSweep::is_alive;
bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked() || is_closed_archive_object(p); }
bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
MarkSweep::KeepAliveClosure MarkSweep::keep_alive;

@ -133,11 +133,6 @@ class MarkSweep : AllStatic {
static ReferenceProcessor* const ref_processor() { return _ref_processor; }
static void set_ref_processor(ReferenceProcessor* rp);
// Archive Object handling
static inline bool is_closed_archive_object(oop object);
static inline bool is_open_archive_object(oop object);
static inline bool is_archive_object(oop object);
static STWGCTimer* gc_timer() { return _gc_timer; }
static SerialOldTracer* gc_tracer() { return _gc_tracer; }

@ -30,33 +30,6 @@
#include "memory/universe.hpp"
#include "oops/markOop.inline.hpp"
#include "oops/oop.inline.hpp"
#if INCLUDE_ALL_GCS
#include "gc/g1/g1Allocator.inline.hpp"
#endif // INCLUDE_ALL_GCS
inline bool MarkSweep::is_closed_archive_object(oop object) {
#if INCLUDE_ALL_GCS
return G1ArchiveAllocator::is_closed_archive_object(object);
#else
return false;
#endif
}
inline bool MarkSweep::is_open_archive_object(oop object) {
#if INCLUDE_ALL_GCS
return G1ArchiveAllocator::is_open_archive_object(object);
#else
return false;
#endif
}
inline bool MarkSweep::is_archive_object(oop object) {
#if INCLUDE_ALL_GCS
return G1ArchiveAllocator::is_archive_object(object);
#else
return false;
#endif
}
inline int MarkSweep::adjust_pointers(oop obj) {
return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
@ -70,27 +43,16 @@ template <class T> inline void MarkSweep::adjust_pointer(T* p) {
oop new_obj = oop(obj->mark()->decode_pointer());
assert(is_archive_object(obj) || // no forwarding of archive objects
new_obj != NULL || // is forwarding ptr?
assert(new_obj != NULL || // is forwarding ptr?
obj->mark() == markOopDesc::prototype() || // not gc marked?
(UseBiasedLocking && obj->mark()->has_bias_pattern()),
// not gc marked?
"should be forwarded");
#ifndef PRODUCT
// open_archive objects are marked by GC. Their mark should
// not have forwarding ptr.
if (is_open_archive_object(obj)) {
assert(new_obj == NULL, "archive heap object has forwarding ptr");
}
#endif
if (new_obj != NULL) {
if (!is_closed_archive_object(obj)) {
assert(Universe::heap()->is_in_reserved(new_obj),
"should be in object space");
oopDesc::encode_store_heap_oop_not_null(p, new_obj);
}
assert(Universe::heap()->is_in_reserved(new_obj),
"should be in object space");
oopDesc::encode_store_heap_oop_not_null(p, new_obj);
}
}
}

@ -0,0 +1,31 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/serial/serialArguments.hpp"
#include "gc/shared/genCollectedHeap.hpp"
size_t SerialArguments::conservative_max_heap_alignment() {
return GenCollectedHeap::conservative_max_heap_alignment();
}

@ -0,0 +1,35 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_SERIAL_SERIALARGUMENTS_HPP
#define SHARE_GC_SERIAL_SERIALARGUMENTS_HPP
#include "gc/shared/gcArguments.hpp"
class SerialArguments : public GCArguments {
public:
virtual size_t conservative_max_heap_alignment();
};
#endif // SHARE_GC_SERIAL_SERIALARGUMENTS_HPP

@ -0,0 +1,135 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/shared/gcArguments.hpp"
#include "gc/serial/serialArguments.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "utilities/macros.hpp"
#if INCLUDE_ALL_GCS
#include "gc/parallel/parallelArguments.hpp"
#include "gc/cms/cmsArguments.hpp"
#include "gc/g1/g1Arguments.hpp"
#endif
GCArguments* GCArguments::_instance = NULL;
GCArguments* GCArguments::arguments() {
assert(is_initialized(), "Heap factory not yet created");
return _instance;
}
bool GCArguments::is_initialized() {
return _instance != NULL;
}
bool GCArguments::gc_selected() {
#if INCLUDE_ALL_GCS
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
#else
return UseSerialGC;
#endif // INCLUDE_ALL_GCS
}
void GCArguments::select_gc() {
if (!gc_selected()) {
select_gc_ergonomically();
if (!gc_selected()) {
vm_exit_during_initialization("Garbage collector not selected (default collector explicitly disabled)", NULL);
}
}
}
void GCArguments::select_gc_ergonomically() {
#if INCLUDE_ALL_GCS
if (os::is_server_class_machine()) {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
} else {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
}
#else
UNSUPPORTED_OPTION(UseG1GC);
UNSUPPORTED_OPTION(UseParallelGC);
UNSUPPORTED_OPTION(UseParallelOldGC);
UNSUPPORTED_OPTION(UseConcMarkSweepGC);
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
#endif // INCLUDE_ALL_GCS
}
void GCArguments::initialize_flags() {
#if INCLUDE_ALL_GCS
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);
}
// If class unloading is disabled, also disable concurrent class unloading.
if (!ClassUnloading) {
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
}
#endif // INCLUDE_ALL_GCS
}
jint GCArguments::initialize() {
assert(!is_initialized(), "GC arguments already initialized");
select_gc();
#if !INCLUDE_ALL_GCS
if (UseParallelGC || UseParallelOldGC) {
jio_fprintf(defaultStream::error_stream(), "UseParallelGC not supported in this VM.\n");
return JNI_ERR;
} else if (UseG1GC) {
jio_fprintf(defaultStream::error_stream(), "UseG1GC not supported in this VM.\n");
return JNI_ERR;
} else if (UseConcMarkSweepGC) {
jio_fprintf(defaultStream::error_stream(), "UseConcMarkSweepGC not supported in this VM.\n");
return JNI_ERR;
#else
if (UseParallelGC || UseParallelOldGC) {
_instance = new ParallelArguments();
} else if (UseG1GC) {
_instance = new G1Arguments();
} else if (UseConcMarkSweepGC) {
_instance = new CMSArguments();
#endif
} else if (UseSerialGC) {
_instance = new SerialArguments();
} else {
ShouldNotReachHere();
}
return JNI_OK;
}

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_SHARED_GCARGUMENTS_HPP
#define SHARE_GC_SHARED_GCARGUMENTS_HPP
#include "memory/allocation.hpp"
class GCArguments : public CHeapObj<mtGC> {
private:
static GCArguments* _instance;
static void select_gc();
static void select_gc_ergonomically();
static bool gc_selected();
public:
static jint initialize();
static bool is_initialized();
static GCArguments* arguments();
virtual void initialize_flags();
virtual size_t conservative_max_heap_alignment() = 0;
};
#endif // SHARE_GC_SHARED_GCARGUMENTS_HPP

@ -29,7 +29,7 @@
#include "classfile/moduleEntry.hpp"
#include "classfile/stringTable.hpp"
#include "classfile/symbolTable.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/gcArguments.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/taskqueue.hpp"
@ -61,11 +61,6 @@
#if INCLUDE_JVMCI
#include "jvmci/jvmciRuntime.hpp"
#endif
#if INCLUDE_ALL_GCS
#include "gc/cms/compactibleFreeListSpace.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/parallel/parallelScavengeHeap.hpp"
#endif // INCLUDE_ALL_GCS
// Note: This is a special bug reporting site for the JVM
#define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
@ -1508,161 +1503,6 @@ void Arguments::set_tiered_flags() {
}
}
#if INCLUDE_ALL_GCS
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);
}
}
void Arguments::set_parnew_gc_flags() {
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
"control point invariant");
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
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);
}
// 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");
}
FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
}
assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
}
// Adjust some sizes to suit CMS and/or ParNew needs; these work well on
// sparc/solaris for certain applications, but would gain from
// further optimization and tuning efforts, and would almost
// certainly gain from analysis of platform and environment.
void Arguments::set_cms_and_parnew_gc_flags() {
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
// Turn off AdaptiveSizePolicy by default for cms until it is complete.
disable_adaptive_size_policy("UseConcMarkSweepGC");
set_parnew_gc_flags();
size_t max_heap = align_down(MaxHeapSize,
CardTableRS::ct_max_alignment_constraint());
// Now make adjustments for CMS
intx tenuring_default = (intx)6;
size_t young_gen_per_worker = CMSYoungGenPerWorker;
// Preferred young gen size for "short" pauses:
// upper bound depends on # of threads and NewRatio.
const size_t preferred_max_new_size_unaligned =
MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
size_t preferred_max_new_size =
align_up(preferred_max_new_size_unaligned, os::vm_page_size());
// Unless explicitly requested otherwise, size young gen
// for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
// If either MaxNewSize or NewRatio is set on the command line,
// assume the user is trying to set the size of the young gen.
if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
// Set MaxNewSize to our calculated preferred_max_new_size unless
// NewSize was set on the command line and it is larger than
// preferred_max_new_size.
if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
} else {
FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
}
log_trace(gc, heap)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
// Code along this path potentially sets NewSize and OldSize
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));
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));
log_trace(gc, heap)("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
}
}
}
}
// Unless explicitly requested otherwise, definitely
// promote all objects surviving "tenuring_default" scavenges.
if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
FLAG_IS_DEFAULT(SurvivorRatio)) {
FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
}
// If we decided above (or user explicitly requested)
// `promote all' (via MaxTenuringThreshold := 0),
// prefer minuscule survivor spaces so as not to waste
// space for (non-existent) survivors
if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
}
// 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.
FLAG_SET_ERGO(size_t, OldPLABSize, CompactibleFreeListSpaceLAB::_default_static_old_plab_size); // default value before 6631166
} else {
FLAG_SET_DEFAULT(OldPLABSize, CompactibleFreeListSpaceLAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
}
}
// If either of the static initialization defaults have changed, note this
// modification.
if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
CompactibleFreeListSpaceLAB::modify_initialization(OldPLABSize, OldPLABWeight);
}
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
}
#endif // INCLUDE_ALL_GCS
void set_object_alignment() {
// Object alignment.
assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
@ -1681,11 +1521,6 @@ void set_object_alignment() {
if (SurvivorAlignmentInBytes == 0) {
SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
}
#if INCLUDE_ALL_GCS
// Set CMS global values
CompactibleFreeListSpace::set_cms_values();
#endif // INCLUDE_ALL_GCS
}
size_t Arguments::max_heap_for_compressed_oops() {
@ -1761,28 +1596,13 @@ void Arguments::set_conservative_max_heap_alignment() {
// 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
size_t heap_alignment = GCArguments::arguments()->conservative_max_heap_alignment();
_conservative_max_heap_alignment = MAX4(heap_alignment,
(size_t)os::vm_allocation_granularity(),
os::max_page_size(),
CollectorPolicy::compute_heap_alignment());
}
bool Arguments::gc_selected() {
#if INCLUDE_ALL_GCS
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
#else
return UseSerialGC;
#endif // INCLUDE_ALL_GCS
}
#ifdef TIERED
bool Arguments::compilation_mode_selected() {
return !FLAG_IS_DEFAULT(TieredCompilation) || !FLAG_IS_DEFAULT(TieredStopAtLevel) ||
@ -1802,31 +1622,6 @@ void Arguments::select_compilation_mode_ergonomically() {
}
#endif //TIERED
void Arguments::select_gc_ergonomically() {
#if INCLUDE_ALL_GCS
if (os::is_server_class_machine()) {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
} else {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
}
#else
UNSUPPORTED_OPTION(UseG1GC);
UNSUPPORTED_OPTION(UseParallelGC);
UNSUPPORTED_OPTION(UseParallelOldGC);
UNSUPPORTED_OPTION(UseConcMarkSweepGC);
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
#endif // INCLUDE_ALL_GCS
}
void Arguments::select_gc() {
if (!gc_selected()) {
select_gc_ergonomically();
if (!gc_selected()) {
vm_exit_during_initialization("Garbage collector not selected (default collector explicitly disabled)", NULL);
}
}
}
#if INCLUDE_JVMCI
void Arguments::set_jvmci_specific_flags() {
if (UseJVMCICompiler) {
@ -1860,13 +1655,17 @@ void Arguments::set_jvmci_specific_flags() {
}
#endif
void Arguments::set_ergonomics_flags() {
jint Arguments::set_ergonomics_flags() {
#ifdef TIERED
if (!compilation_mode_selected()) {
select_compilation_mode_ergonomically();
}
#endif
select_gc();
jint gc_result = GCArguments::initialize();
if (gc_result != JNI_OK) {
return gc_result;
}
#if COMPILER2_OR_JVMCI
// Shared spaces work fine with other GCs but causes bytecode rewriting
@ -1895,145 +1694,12 @@ void Arguments::set_ergonomics_flags() {
#endif // _LP64
#endif // !ZERO
}
void Arguments::set_parallel_gc_flags() {
assert(UseParallelGC || UseParallelOldGC, "Error");
// Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
FLAG_SET_DEFAULT(UseParallelOldGC, true);
}
FLAG_SET_DEFAULT(UseParallelGC, true);
// If no heap maximum was requested explicitly, use some reasonable fraction
// of the physical memory, up to a maximum of 1GB.
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);
}
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);
}
if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
}
}
// 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);
}
if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
}
}
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);
}
}
}
void Arguments::set_g1_gc_flags() {
assert(UseG1GC, "Error");
#if defined(COMPILER1) || INCLUDE_JVMCI
FastTLABRefill = false;
#endif
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
if (ParallelGCThreads == 0) {
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);
}
#if INCLUDE_ALL_GCS
if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
FLAG_SET_ERGO(uint, G1ConcRefinementThreads, ParallelGCThreads);
}
#endif
// 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);
}
if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
// In G1, we want the default GC overhead goal to be higher than
// it is for PS, or the heap might be expanded too aggressively.
// We set it here to ~8%.
FLAG_SET_DEFAULT(GCTimeRatio, 12);
}
// Below, we might need to calculate the pause time interval based on
// the pause target. When we do so we are going to give G1 maximum
// flexibility and allow it to do pauses when it needs to. So, we'll
// arrange that the pause interval to be pause time target + 1 to
// ensure that a) the pause time target is maximized with respect to
// the pause interval and b) we maintain the invariant that pause
// time target < pause interval. If the user does not want this
// maximum flexibility, they will have to set the pause interval
// explicitly.
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
// The default pause time target in G1 is 200ms
FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
}
// Then, if the interval parameter was not set, set it according to
// the pause time target (this will also deal with the case when the
// pause time target is the default value).
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
}
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
return JNI_OK;
}
void Arguments::set_gc_specific_flags() {
#if INCLUDE_ALL_GCS
// Set per-collector flags
if (UseParallelGC || UseParallelOldGC) {
set_parallel_gc_flags();
} else if (UseConcMarkSweepGC) {
set_cms_and_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_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);
}
// If class unloading is disabled, also disable concurrent class unloading.
if (!ClassUnloading) {
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
}
#endif // INCLUDE_ALL_GCS
// Set GC flags
GCArguments::arguments()->initialize_flags();
}
julong Arguments::limit_by_allocatable_memory(julong limit) {
@ -4491,7 +4157,8 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
jint Arguments::apply_ergo() {
// Set flags based on ergonomics.
set_ergonomics_flags();
jint result = set_ergonomics_flags();
if (result != JNI_OK) return result;
#if INCLUDE_JVMCI
set_jvmci_specific_flags();

@ -472,8 +472,7 @@ 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 jint set_ergonomics_flags();
static void set_shared_spaces_flags();
// limits the given memory size by the maximum amount of memory this process is
// currently allowed to allocate or reserve.
@ -635,8 +634,6 @@ class Arguments : AllStatic {
static jint adjust_after_os();
static void set_gc_specific_flags();
static bool gc_selected(); // whether a gc has been selected
static void select_gc_ergonomically();
#if INCLUDE_JVMCI
// Check consistency of jvmci vm argument settings.
static bool check_jvmci_args_consistency();

@ -197,7 +197,8 @@ hotspot_cds = \
hotspot_tier1_serviceability = \
serviceability/dcmd/compiler \
serviceability/logging
serviceability/logging \
serviceability/sa
hotspot_tier1 = \
:hotspot_tier1_common \

@ -0,0 +1,91 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
/*
* @test
* @bug 8190198
* @summary Test clhsdb flags command
* @library /test/lib
* @run main/othervm ClhsdbFlags
*/
public class ClhsdbFlags {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbFlags test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UnlockExperimentalVMOptions");
vmArgs.add("-XX:+UseJVMCICompiler");
vmArgs.add("-XX:-MaxFDLimit");
vmArgs.addAll(Utils.getVmOptions());
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of(
"flags", "flags -nd",
"flags UseJVMCICompiler", "flags MaxFDLimit",
"flags MaxJavaStackTraceDepth");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("flags", List.of(
"UseJVMCICompiler = true",
"MaxFDLimit = false",
"MaxJavaStackTraceDepth = 1024",
"UseCompressedClassPointers", "VerifyMergedCPBytecodes",
"ConcGCThreads", "UseThreadPriorities",
"UseInterpreter", "StartFlightRecording",
"ShowHiddenFrames", "UseAppCDS"));
expStrMap.put("flags -nd", List.of(
"UseJVMCICompiler = true",
"MaxFDLimit = false",
"UseCompressedClassPointers",
"ConcGCThreads"));
expStrMap.put("flags UseJVMCICompiler", List.of(
"UseJVMCICompiler = true"));
expStrMap.put("flags MaxFDLimit", List.of(
"MaxFDLimit = false"));
expStrMap.put("flags MaxJavaStackTraceDepth", List.of(
"MaxJavaStackTraceDepth = 1024"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,70 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb Jstack command
* @library /test/lib
* @run main/othervm ClhsdbJstack
*/
public class ClhsdbJstack {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbJstack test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("jstack -v");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("jstack -v", List.of(
"No deadlocks found",
"Common-Cleaner",
"Signal Dispatcher",
"java.lang.ref.Finalizer$FinalizerThread.run",
"java.lang.ref.Reference",
"Method*",
"LingeredApp.main"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,160 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.OutputAnalyzer;
/**
* This is a framework to run 'jhsdb clhsdb' commands.
* See open/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java for
* an example of how to write a test.
*/
public class ClhsdbLauncher {
private Process toolProcess;
public void ClhsdbLauncher() {
toolProcess = null;
}
/**
*
* Launches 'jhsdb clhsdb' and attaches to the Lingered App process.
* @param lingeredAppPid - pid of the Lingered App or one its sub-classes.
*/
private void attach(long lingeredAppPid)
throws IOException {
System.out.println("Starting clhsdb against " + lingeredAppPid);
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
launcher.addToolArg("clhsdb");
launcher.addToolArg("--pid=" + Long.toString(lingeredAppPid));
ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
toolProcess = processBuilder.start();
}
/**
*
* Runs 'jhsdb clhsdb' commands and checks for expected and unexpected strings.
* @param commands - clhsdb commands to execute.
* @param expectedStrMap - Map of expected strings per command which need to
* be checked in the output of the command.
* @param unExpectedStrMap - Map of unexpected strings per command which should
* not be present in the output of the command.
* @return Output of the commands as a String.
*/
private String runCmd(List<String> commands,
Map<String, List<String>> expectedStrMap,
Map<String, List<String>> unExpectedStrMap)
throws IOException, InterruptedException {
String output;
if (commands == null) {
throw new RuntimeException("CLHSDB command must be provided\n");
}
try (OutputStream out = toolProcess.getOutputStream()) {
for (String cmd : commands) {
out.write((cmd + "\n").getBytes());
}
out.write("quit\n".getBytes());
out.flush();
}
OutputAnalyzer oa = new OutputAnalyzer(toolProcess);
try {
toolProcess.waitFor();
} catch (InterruptedException ie) {
toolProcess.destroyForcibly();
throw new Error("Problem awaiting the child process: " + ie);
}
oa.shouldHaveExitValue(0);
output = oa.getOutput();
System.out.println(output);
String[] parts = output.split("hsdb>");
for (String cmd : commands) {
int index = commands.indexOf(cmd) + 1;
OutputAnalyzer out = new OutputAnalyzer(parts[index]);
if (expectedStrMap != null) {
List<String> expectedStr = expectedStrMap.get(cmd);
if (expectedStr != null) {
for (String exp : expectedStr) {
out.shouldContain(exp);
}
}
}
if (unExpectedStrMap != null) {
List<String> unExpectedStr = unExpectedStrMap.get(cmd);
if (unExpectedStr != null) {
for (String unExp : unExpectedStr) {
out.shouldNotContain(unExp);
}
}
}
}
return output;
}
/**
*
* Launches 'jhsdb clhsdb', attaches to the Lingered App, executes the commands,
* checks for expected and unexpected strings.
* @param lingeredAppPid - pid of the Lingered App or one its sub-classes.
* @param commands - clhsdb commands to execute.
* @param expectedStrMap - Map of expected strings per command which need to
* be checked in the output of the command.
* @param unExpectedStrMap - Map of unexpected strings per command which should
* not be present in the output of the command.
* @return Output of the commands as a String.
*/
public String run(long lingeredAppPid,
List<String> commands,
Map<String, List<String>> expectedStrMap,
Map<String, List<String>> unExpectedStrMap)
throws IOException, InterruptedException {
if (!Platform.shouldSAAttach()) {
// Silently skip the test if we don't have enough permissions to attach
System.out.println("SA attach not expected to work - test skipped.");
return null;
}
attach(lingeredAppPid);
return runCmd(commands, expectedStrMap, unExpectedStrMap);
}
}

@ -0,0 +1,82 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb longConstant command
* @library /test/lib
* @run main/othervm ClhsdbLongConstant
*/
public class ClhsdbLongConstant {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbLongConstant test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of(
"longConstant",
"longConstant markOopDesc::locked_value",
"longConstant markOopDesc::lock_bits",
"longConstant jtreg::test 6",
"longConstant jtreg::test");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("longConstant", List.of(
"longConstant markOopDesc::locked_value",
"longConstant markOopDesc::lock_bits",
"InvocationCounter::count_increment",
"markOopDesc::epoch_mask_in_place"));
expStrMap.put("longConstant markOopDesc::locked_value", List.of(
"longConstant markOopDesc::locked_value"));
expStrMap.put("longConstant markOopDesc::lock_bits", List.of(
"longConstant markOopDesc::lock_bits"));
expStrMap.put("longConstant jtreg::test", List.of(
"longConstant jtreg::test 6"));
Map<String, List<String>> unExpStrMap = new HashMap<>();
unExpStrMap.put("longConstant jtreg::test", List.of(
"Error: java.lang.RuntimeException: No long constant named"));
test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,66 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb pmap command
* @library /test/lib
* @requires os.family != "mac"
* @run main/othervm ClhsdbPmap
*/
public class ClhsdbPmap {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbPmap test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("pmap");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("pmap", List.of(
"jvm", "java", "net", "nio",
"jimage", "zip", "verify"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,93 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb printstatics command
* @library /test/lib
* @run main/othervm ClhsdbPrintStatics
*/
public class ClhsdbPrintStatics {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbPrintStatics test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of(
"printstatics", "printstatics SystemDictionary",
"printstatics Threads", "printstatics Universe",
"printstatics JvmtiExport");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("printstatics", List.of(
"All known static fields",
"Abstract_VM_Version::_vm_major_version",
"ClassLoaderDataGraph::_head", "SymbolTable::_the_table",
"JNIHandles::_weak_global_handles", "PerfMemory::_top",
"_jfr_checkpoints", "ObjectSynchronizer::gBlockList",
"java_lang_Class::_oop_size_offset",
"CodeCache::_scavenge_root_nmethods"));
expStrMap.put("printstatics SystemDictionary", List.of(
"Static fields of SystemDictionary",
"SystemDictionary::Class_klass_knum",
"SystemDictionary::ClassLoader_klass_knum",
"SystemDictionary::Object_klass_knum"));
expStrMap.put("printstatics Threads", List.of(
"Static fields of Threads",
"_number_of_threads", "_number_of_non_daemon_threads",
"JavaThread* Threads"));
expStrMap.put("printstatics Universe", List.of(
"Static fields of Universe",
"uintptr_t Universe::_verify_oop_mask",
"intptr_t Universe::_non_oop_bits",
"bool Universe::_fully_initialized",
"Universe::_doubleArrayKlassObj"));
expStrMap.put("printstatics JvmtiExport", List.of(
"Static fields of JvmtiExport",
"bool JvmtiExport::_can_access_local_variables",
"bool JvmtiExport::_can_hotswap_or_post_breakpoint",
"bool JvmtiExport::_can_post_on_exceptions"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,68 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb pstack command
* @library /test/lib
* @requires os.family != "mac"
* @run main/othervm ClhsdbPstack
*/
public class ClhsdbPstack {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbPstack test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("pstack -v");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("pstack -v", List.of(
"No deadlocks found", "Common-Cleaner",
"Signal Dispatcher", "CompilerThread",
"Sweeper thread", "Service Thread",
"Reference Handler", "Finalizer", "main"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,69 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb symboldump command
* @library /test/lib
* @run main/othervm ClhsdbSymbol
*/
public class ClhsdbSymbol {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbSymbol test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("symboldump");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("symboldump", List.of(
"java/lang/String", "java/util/HashMap", "UsageTracker",
"Ljava/io/InputStream", "LambdaMetafactory", "PerfCounter",
"isAnonymousClass", "JVMTI_THREAD_STATE_TERMINATED", "jdi",
"checkGetClassLoaderPermission", "lockCreationTime",
"storedAppOutput", "storedAppOutput", "getProcess",
"LingeredApp"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,74 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
/*
* @test
* @bug 8190198
* @summary Test clhsdb where command
* @library /test/lib
* @run main/othervm ClhsdbWhere
*/
public class ClhsdbWhere {
public static void main(String[] args) throws Exception {
System.out.println("Starting ClhsdbWhere test");
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("where -a");
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("where -a", List.of(
"Java Stack Trace for Service Thread",
"Java Stack Trace for Common-Cleaner",
"Java Stack Trace for Sweeper thread",
"CompilerThread",
"Java Stack Trace for Finalizer",
"java.lang.ref.Reference",
"private static void processPendingReferences",
"private static native void waitForReferencePendingList",
"Java Stack Trace for main",
"public static native void sleep"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
System.out.println("Test PASSED");
}
}

@ -0,0 +1,144 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.OutputStream;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
/*
* @test
* @summary Test the 'intConstant' command of jhsdb clhsdb.
* @bug 8190307
* @library /test/lib
* @build jdk.test.lib.apps.*
* @run main/othervm TestIntConstant
*/
public class TestIntConstant {
private static void testClhsdbForIntConstant(
long lingeredAppPid,
String commandString,
String[] expectedOutputStrings) throws Exception {
Process p;
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
launcher.addToolArg("clhsdb");
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(lingeredAppPid));
ProcessBuilder pb = new ProcessBuilder();
pb.command(launcher.getCommand());
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
System.out.println(
pb.command().stream().collect(Collectors.joining(" ")));
try {
p = pb.start();
} catch (Exception attachE) {
throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
}
// Issue the 'intConstant' inputs at the clhsdb prompt.
OutputStream input = p.getOutputStream();
try {
input.write((commandString + "\n").getBytes());
input.write("quit\n".getBytes());
input.flush();
} catch (IOException ioe) {
throw new Error("Problem issuing the intConstant command: " +
commandString + ioe);
}
OutputAnalyzer output = new OutputAnalyzer(p);
System.out.println("Awaiting process completion");
try {
p.waitFor();
} catch (InterruptedException ie) {
p.destroyForcibly();
throw new Error("Problem awaiting the child process: " + ie);
}
output.shouldHaveExitValue(0);
System.out.println(output.getOutput());
for (String expectedOutputString: expectedOutputStrings) {
output.shouldContain(expectedOutputString);
}
}
public static void testIntConstant() throws Exception {
LingeredApp app = null;
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.addAll(Utils.getVmOptions());
app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with pid " + app.getPid());
// Strings to check for in the output of 'intConstant'. The
// 'intConstant' command prints out entries from the
// 'gHotSpotVMIntConstants', which is a table of integer constants,
// with names and the values derived from enums and #define preprocessor
// macros in hotspot.
String[] defaultOutputStrings =
{"CollectedHeap::G1CollectedHeap 2",
"RUNNABLE 2",
"Deoptimization::Reason_class_check 4",
"InstanceKlass::_misc_is_anonymous 32",
"Generation::ParNew 1",
"_thread_uninitialized 0"};
String[] tempConstantString = {"intConstant _temp_constant 45"};
testClhsdbForIntConstant(app.getPid(), "intConstant", defaultOutputStrings);
testClhsdbForIntConstant(
app.getPid(),
"intConstant _temp_constant 45\nintConstant _temp_constant",
tempConstantString);
} finally {
LingeredApp.stopApp(app);
}
}
public static void main (String... args) throws Exception {
if (!Platform.shouldSAAttach()) {
System.out.println(
"SA attach not expected to work - test skipped.");
return;
}
try {
testIntConstant();
} catch (Exception e) {
throw new Error("Test failed with " + e);
}
}
}

@ -0,0 +1,132 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.OutputStream;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
/*
* @test
* @summary Test the 'type' command of jhsdb clhsdb.
* @bug 8190307
* @library /test/lib
* @build jdk.test.lib.apps.*
* @run main/othervm TestType
*/
public class TestType {
private static void testClhsdbForType(
long lingeredAppPid,
String commandString,
String[] expectedOutputStrings) throws Exception {
Process p;
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
launcher.addToolArg("clhsdb");
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(lingeredAppPid));
ProcessBuilder pb = new ProcessBuilder();
pb.command(launcher.getCommand());
System.out.println(
pb.command().stream().collect(Collectors.joining(" ")));
try {
p = pb.start();
} catch (Exception attachE) {
throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
}
// Issue the 'type' commands at the clhsdb prompt.
OutputStream input = p.getOutputStream();
try {
input.write((commandString + "\n").getBytes());
input.write("quit\n".getBytes());
input.flush();
} catch (IOException ioe) {
throw new Error("Problem issuing the 'type' command ", ioe);
}
OutputAnalyzer output = new OutputAnalyzer(p);
try {
p.waitFor();
} catch (InterruptedException ie) {
p.destroyForcibly();
throw new Error("Problem awaiting the child process: " + ie);
}
output.shouldHaveExitValue(0);
System.out.println(output.getOutput());
for (String expectedOutputString: expectedOutputStrings) {
output.shouldContain(expectedOutputString);
}
}
public static void main (String... args) throws Exception {
LingeredApp app = null;
if (!Platform.shouldSAAttach()) {
System.out.println(
"SA attach not expected to work - test skipped.");
return;
}
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.addAll(Utils.getVmOptions());
// Strings to check for in the output of 'type'. The 'type'
// command prints out entries from 'gHotSpotVMTypes', which
// is a table containing the hotspot types, their supertypes,
// sizes, etc, which are of interest to the SA.
String[] defaultOutputStrings =
{"type G1CollectedHeap CollectedHeap",
"type ConstantPoolCache MetaspaceObj",
"type ConstantPool Metadata",
"type CompilerThread JavaThread",
"type CardGeneration Generation",
"type ArrayKlass Klass",
"type InstanceKlass Klass"};
// String to check for in the output of "type InstanceKlass"
String[] instanceKlassOutputString = {"type InstanceKlass Klass"};
app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with pid " + app.getPid());
testClhsdbForType(app.getPid(), "type", defaultOutputStrings);
testClhsdbForType(app.getPid(),
"type InstanceKlass",
instanceKlassOutputString);
} finally {
LingeredApp.stopApp(app);
}
}
}

@ -0,0 +1,137 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.OutputStream;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
/*
* @test
* @summary Test the 'universe' command of jhsdb clhsdb.
* @bug 8190307
* @library /test/lib
* @build jdk.test.lib.apps.*
* @run main/othervm TestUniverse
*/
public class TestUniverse {
private static void testClhsdbForUniverse(long lingeredAppPid,
String gc) throws Exception {
Process p;
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
launcher.addToolArg("clhsdb");
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(lingeredAppPid));
ProcessBuilder pb = new ProcessBuilder();
pb.command(launcher.getCommand());
System.out.println(
pb.command().stream().collect(Collectors.joining(" ")));
try {
p = pb.start();
} catch (Exception attachE) {
throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
}
// Issue the 'universe' command at the clhsdb prompt.
OutputStream input = p.getOutputStream();
try {
input.write("universe\n".getBytes());
input.write("quit\n".getBytes());
input.flush();
} catch (IOException ioe) {
throw new Error("Problem issuing the 'universe' command ", ioe);
}
OutputAnalyzer output = new OutputAnalyzer(p);
try {
p.waitFor();
} catch (InterruptedException ie) {
p.destroyForcibly();
throw new Error("Problem awaiting the child process: " + ie, ie);
}
output.shouldHaveExitValue(0);
System.out.println(output.getOutput());
output.shouldContain("Heap Parameters");
if (gc.contains("G1GC")) {
output.shouldContain("garbage-first heap");
}
if (gc.contains("UseConcMarkSweepGC")) {
output.shouldContain("Gen 1: concurrent mark-sweep generation");
}
if (gc.contains("UseSerialGC")) {
output.shouldContain("Gen 1: old");
}
if (gc.contains("UseParallelGC")) {
output.shouldContain("ParallelScavengeHeap");
output.shouldContain("PSYoungGen");
output.shouldContain("eden");
}
}
public static void test(String gc) throws Exception {
LingeredApp app = null;
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add(gc);
app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with the GC option " + gc +
" and pid " + app.getPid());
testClhsdbForUniverse(app.getPid(), gc);
} finally {
LingeredApp.stopApp(app);
}
}
public static void main (String... args) throws Exception {
if (!Platform.shouldSAAttach()) {
System.out.println(
"SA attach not expected to work - test skipped.");
return;
}
try {
test("-XX:+UseG1GC");
test("-XX:+UseParallelGC");
test("-XX:+UseSerialGC");
test("-XX:+UseConcMarkSweepGC");
} catch (Exception e) {
throw new Error("Test failed with " + e);
}
}
}