/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc_implementation/shared/gcHeapSummary.hpp"
#include "gc_implementation/shared/gcTrace.hpp"
#include "gc_implementation/shared/gcTraceTime.hpp"
#include "gc_implementation/shared/gcWhen.hpp"
#include "gc_implementation/shared/vmGCOperations.hpp"
#include "gc_interface/allocTracer.hpp"
#include "gc_interface/collectedHeap.hpp"
#include "gc_interface/collectedHeap.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/instanceMirrorKlass.hpp"
#include "services/heapDumper.hpp"
#ifdef TARGET_OS_FAMILY_linux
# include "thread_linux.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_solaris
# include "thread_solaris.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_windows
# include "thread_windows.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "thread_bsd.inline.hpp"
#endif
#ifdef ASSERT
#endif
= "The size of the object heap + perm gen exceeds the maximum representable size";
template <>
}
if (!should_log()) {
return;
}
if (before) {
} else {
}
}
return VirtualSpaceSummary(
}
}
}
if (PrintHeapAtGC) {
}
if (_gc_heap_log != NULL) {
}
}
if (PrintHeapAtGC) {
}
if (_gc_heap_log != NULL) {
}
}
}
}
}
// Memory state functions.
{
_barrier_set = NULL;
_is_gc_active = false;
if (UsePerfData) {
// create the gc cause jvmstat counters
}
_defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below.
// Create the ring log
if (LogEvents) {
_gc_heap_log = new GCHeapLog();
} else {
_gc_heap_log = NULL;
}
}
// Used for ReduceInitialCardMarks (when COMPILER2 is used);
// otherwise remains unused.
#ifdef COMPILER2
&& (DeferInitialCardMark || card_mark_must_follow_store());
#else
#endif
}
// We must have overflowed
}
return result;
}
// We must have overflowed
}
return result;
}
#ifndef PRODUCT
if (CheckMemoryInitialization && ZapUnusedHeapArea) {
"Found badHeapWordValue in post-allocation check");
}
}
}
if (CheckMemoryInitialization && ZapUnusedHeapArea) {
"Found non badHeapWordValue in pre-allocation check");
}
}
}
#endif // PRODUCT
#ifdef ASSERT
// How to choose between a pending exception and a potential
// OutOfMemoryError? Don't allow pending exceptions.
// This is a VM policy failure, so how do we exhaustively test it?
"shouldn't be allocating with pending exception");
if (StrictSafepointChecks) {
"Allocation done by thread for which allocation is blocked "
"by No_Allocation_Verifier!");
// Allocation of an oop can always invoke a safepoint,
// hence, the true argument
}
}
#endif
// Retain tlab and allocate object in shared space if
// the amount free in the tlab is too large to discard.
return NULL;
}
// Discard tlab and allocate a new one.
// To minimize fragmentation, the last TLAB may be smaller than the rest.
if (new_tlab_size == 0) {
return NULL;
}
// Allocate a new TLAB...
return NULL;
}
AllocTracer::send_allocation_in_new_tlab_event(klass, new_tlab_size * HeapWordSize, size * HeapWordSize);
if (ZeroTLAB) {
// ..and clear it.
} else {
// ...and zap just allocated object.
#ifdef ASSERT
// Skip mangling the space corresponding to the object header to
// ensure that the returned space is not considered parsable by
// any concurrent GC thread.
#endif // ASSERT
}
return obj;
}
{
// Verify that the storage points to a parsable object in heap
"Else should have been filtered in new_store_pre_barrier()");
"Mismatch: multiple objects?");
}
// "Clear" the deferred_card_mark field
}
}
// Helper for ReduceInitialCardMarks. For performance,
// compiled code may elide card-marks for initializing stores
// to a newly allocated object along the fast-path. We
// compensate for such elided card-marks as follows:
// (a) Generational, non-concurrent collectors, such as
// GenCollectedHeap(ParNew,DefNew,Tenured) and
// ParallelScavengeHeap(ParallelGC, ParallelOldGC)
// need the card-mark if and only if the region is
// in the old gen, and do not care if the card-mark
// succeeds or precedes the initializing stores themselves,
// so long as the card-mark is completed before the next
// scavenge. For all these cases, we can do a card mark
// at the point at which we do a slow path allocation
// in the old gen, i.e. in this call.
// (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires
// in addition that the card-mark for an old gen allocated
// object strictly follow any associated initializing stores.
// In these cases, the memRegion remembered below is
// used to card-mark the entire region either just before the next
// slow-path allocation by this thread or just before the next scavenge or
// CMS-associated safepoint, whichever of these events happens first.
// (The implicit assumption is that the object has been fully
// initialized by this point, a fact that we assert when doing the
// card-mark.)
// (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a
// G1 concurrent marking is in progress an SATB (pre-write-)barrier is
// is used to remember the pre-value of any store. Initializing
// stores will not need this barrier, so we need not worry about
// compensating for the missing pre-barrier here. Turning now
// to the post-barrier, we note that G1 needs a RS update barrier
// which simply enqueues a (sequence of) dirty cards which may
// optionally be refined by the concurrent update threads. Note
// that this barrier need only be applied to a non-young write,
// but, like in CMS, because of the presence of concurrent refinement
// (much like CMS' precleaning), must strictly follow the oop-store.
// Thus, using the same protocol for maintaining the intended
// invariants turns out, serendepitously, to be the same for both
// G1 and CMS.
//
// For any future collector, this code should be reexamined with
// that specific collector in mind, and the documentation above suitably
// extended and updated.
// If a previous card-mark was deferred, flush it now.
// The deferred_card_mark region should be empty
// following the flush above.
} else {
if (_defer_initial_card_mark) {
// Defer the card mark
} else {
// Do the card mark
}
}
return new_obj;
}
}
}
#ifdef ASSERT
{
}
{
if (ZapFillerObjects && zap) {
}
}
#endif // ASSERT
void
{
// Set the length first for concurrent GC.
}
void
{
if (words >= filler_array_min_size()) {
} else if (words > 0) {
}
}
{
}
{
#ifdef _LP64
// A single array can fill ~8G, so multiple objects are needed only in 64-bit.
// First fill with arrays, ensuring that any remaining space is big enough to
// fill. The remainder is filled with a single object.
}
#endif
}
guarantee(false, "thread-local allocation buffers not supported");
return NULL;
}
// The second disjunct in the assertion below makes a concession
// for the start-up verification done while the VM is being
// created. Callers be careful that you know that mutators
// aren't going to interfere -- for instance, this is permissible
// if we are still single-threaded and have either not yet
// started allocating (nothing much to verify) or we have
// started allocating but are now a full-fledged JavaThread
// (and have thus made our TLAB's) available for filling.
"Should only be called at a safepoint or at start-up"
" otherwise concurrent mutator activity may make heap "
" unparsable again");
// The main thread starts allocating via a TLAB even before it
// has added itself to the threads list at vm boot-up.
"Attempt to fill tlabs before main thread has been added"
" to threads list is doomed to failure!");
#ifdef COMPILER2
// The deferred store barriers must all have been flushed to the
// card-table (or other remembered set structure) before GC starts
// processing the card-table (or other remembered set).
#else
#endif
}
}
if (UseTLAB) {
"should only accumulate statistics on tlabs at safepoint");
}
}
if (UseTLAB) {
"should only resize tlabs at safepoint");
}
}
if (HeapDumpBeforeFullGC) {
// We are doing a "major" collection and a heap dump before
// major collection has been requested.
HeapDumper::dump_heap();
}
}
}
if (HeapDumpAfterFullGC) {
HeapDumper::dump_heap();
}
}
}
if (JavaObjectsInPerm) {
} else {
}
// Setup indirections
if (!real_klass.is_null()) {
}
// notify jvmti and dtrace
return mirror;
}
/////////////// Unit tests ///////////////
#ifndef PRODUCT
// Test that NULL is not in the heap.
// Test that a pointer to before the heap start is reported as outside the heap.
// Test that a pointer to after the heap end is reported as outside the heap.
}
#endif