collectedHeap.cpp revision 1753
1753N/A * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A#
include "incls/_precompiled.incl" 0N/A// Memory state functions. 0N/A // create the gc cause jvmstat counters 1166N/A // Used for ReduceInitialCardMarks (when COMPILER2 is used); 1166N/A // otherwise remains unused. 0N/A "Found badHeapWordValue in post-allocation check");
0N/A "Found non badHeapWordValue in pre-allocation check");
0N/A // How to choose between a pending exception and a potential 0N/A // OutOfMemoryError? Don't allow pending exceptions. 0N/A // This is a VM policy failure, so how do we exhaustively test it? 0N/A "shouldn't be allocating with pending exception");
0N/A "Allocation done by thread for which allocation is blocked " 0N/A "by No_Allocation_Verifier!");
0N/A // Allocation of an oop can always invoke a safepoint, 0N/A // hence, the true argument 0N/A // Retain tlab and allocate object in shared space if 0N/A // the amount free in the tlab is too large to discard. 0N/A // Discard tlab and allocate a new one. 0N/A // To minimize fragmentation, the last TLAB may be smaller than the rest. 0N/A // Allocate a new TLAB... 0N/A // ...and clear just the allocated object. 1027N/A // Verify that the storage points to a parsable object in heap 1166N/A "Else should have been filtered in new_store_pre_barrier()");
1027N/A "Mismatch: multiple objects?");
1027N/A // "Clear" the deferred_card_mark field 1027N/A// Helper for ReduceInitialCardMarks. For performance, 1027N/A// compiled code may elide card-marks for initializing stores 1027N/A// to a newly allocated object along the fast-path. We 1027N/A// compensate for such elided card-marks as follows: 1027N/A// (a) Generational, non-concurrent collectors, such as 1027N/A// GenCollectedHeap(ParNew,DefNew,Tenured) and 1027N/A// ParallelScavengeHeap(ParallelGC, ParallelOldGC) 1027N/A// need the card-mark if and only if the region is 1027N/A// in the old gen, and do not care if the card-mark 1027N/A// succeeds or precedes the initializing stores themselves, 1027N/A// so long as the card-mark is completed before the next 1027N/A// scavenge. For all these cases, we can do a card mark 1027N/A// at the point at which we do a slow path allocation 1166N/A// in the old gen, i.e. in this call. 1027N/A// (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires 1027N/A// in addition that the card-mark for an old gen allocated 1027N/A// object strictly follow any associated initializing stores. 1027N/A// In these cases, the memRegion remembered below is 1027N/A// used to card-mark the entire region either just before the next 1027N/A// slow-path allocation by this thread or just before the next scavenge or 1027N/A// CMS-associated safepoint, whichever of these events happens first. 1027N/A// (The implicit assumption is that the object has been fully 1027N/A// initialized by this point, a fact that we assert when doing the 1027N/A// (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a 1027N/A// G1 concurrent marking is in progress an SATB (pre-write-)barrier is 1027N/A// is used to remember the pre-value of any store. Initializing 1027N/A// stores will not need this barrier, so we need not worry about 1027N/A// compensating for the missing pre-barrier here. Turning now 1027N/A// to the post-barrier, we note that G1 needs a RS update barrier 1027N/A// which simply enqueues a (sequence of) dirty cards which may 1027N/A// optionally be refined by the concurrent update threads. Note 1027N/A// that this barrier need only be applied to a non-young write, 1027N/A// but, like in CMS, because of the presence of concurrent refinement 1027N/A// (much like CMS' precleaning), must strictly follow the oop-store. 1027N/A// Thus, using the same protocol for maintaining the intended 1166N/A// invariants turns out, serendepitously, to be the same for both 1166N/A// For any future collector, this code should be reexamined with 1166N/A// that specific collector in mind, and the documentation above suitably 1027N/A // If a previous card-mark was deferred, flush it now. 1027N/A // The deferred_card_mark region should be empty 1027N/A // following the flush above. 481N/A // Set the length first for concurrent GC. 481N/A // A single array can fill ~8G, so multiple objects are needed only in 64-bit. 481N/A // First fill with arrays, ensuring that any remaining space is big enough to 481N/A // fill. The remainder is filled with a single object. 0N/A guarantee(
false,
"thread-local allocation buffers not supported");
0N/A // The second disjunct in the assertion below makes a concession 0N/A // for the start-up verification done while the VM is being 0N/A // created. Callers be careful that you know that mutators 0N/A // aren't going to interfere -- for instance, this is permissible 0N/A // if we are still single-threaded and have either not yet 0N/A // started allocating (nothing much to verify) or we have 0N/A // started allocating but are now a full-fledged JavaThread 0N/A // (and have thus made our TLAB's) available for filling. 0N/A "Should only be called at a safepoint or at start-up" 0N/A " otherwise concurrent mutator activity may make heap " 0N/A " unparsable again");
1166N/A // The main thread starts allocating via a TLAB even before it 1166N/A // has added itself to the threads list at vm boot-up. 1166N/A "Attempt to fill tlabs before main thread has been added" 1166N/A " to threads list is doomed to failure!");
1166N/A // The deferred store barriers must all have been flushed to the 1166N/A // card-table (or other remembered set structure) before GC starts 1166N/A // processing the card-table (or other remembered set). 0N/A "should only accumulate statistics on tlabs at safepoint");
0N/A "should only resize tlabs at safepoint");
615N/A // We are doing a "major" collection and a heap dump before 615N/A // major collection has been requested.