/*
* 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 "memory/freeBlockDictionary.hpp"
#include "memory/freeList.hpp"
#include "memory/sharedHeap.hpp"
#include "runtime/globals.hpp"
#include "runtime/vmThread.hpp"
#ifndef SERIALGC
#include "gc_implementation/concurrentMarkSweep/freeChunk.hpp"
#endif // SERIALGC
// Free list. A FreeList is used to access a linked list of chunks
// of space in the heap. The head and tail are maintained so that
// items can be (as in the current implementation) added at the
// at the tail of the list and removed from the head of the list to
// maintain a FIFO queue.
template <class Chunk>
#ifdef ASSERT
#endif
{
_size = 0;
_count = 0;
_hint = 0;
}
template <class Chunk>
#ifdef ASSERT
#endif
{
_count = 1;
_hint = 0;
#ifndef PRODUCT
#endif
}
template <class Chunk>
set_count(0);
}
template <class Chunk>
}
template <class Chunk>
// The chunk fc being removed has a "next". Set the "next" to the
// "prev" of fc.
} else { // removed tail of list
}
}
return fc;
}
template <class Chunk>
if (count() > 0) {
int k = 1;
}
// First, fix up the list we took from.
} else {
}
// Now we can fix up the tail.
// And return the result.
}
}
// Remove this chunk from the list
template <class Chunk>
// The chunk fc being removed has a "next". Set the "next" to the
// "prev" of fc.
} else { // removed tail of list
}
"Prev of head should be NULL");
} else {
"Next of tail should be NULL");
}
"H/T/C Inconsistency");
// clear next and prev fields of fc, debug only
)
}
// Add this chunk at the head of the list.
template <class Chunk>
}
increment_count(); // of # of chunks in list
if (record_return) {
}
)
}
template <class Chunk>
return_chunk_at_head(chunk, true);
}
// Add this chunk at the tail of the list.
template <class Chunk>
} else { // only chunk in list
}
increment_count(); // of # of chunks in list
if (record_return) {
}
)
}
template <class Chunk>
return_chunk_at_tail(chunk, true);
}
template <class Chunk>
if (count() == 0) {
} else {
// Both are non-empty.
}
}
}
// verify_chunk_in_free_list() is used to verify that an item is in this free list.
// It is used as a debugging aid.
template <class Chunk>
// This is an internal consistency check, not part of the check that the
// chunk is in the free lists.
while (curFC) {
// This is an internal consistency check.
return true;
}
}
return false;
}
#ifndef PRODUCT
template <class Chunk>
// The +1 of the LH comparand is to allow some "looseness" in
// checking: we usually call this interface when adding a block
// and we'll subsequently update the stats; we cannot update the
// stats beforehand because in the case of the large-block BT
// dictionary for example, this might be the first block and
// in that case there would be no place that we could record
// the stats (which are kept in the block itself).
" violates Conservation Principle: "
}
template <class Chunk>
// assert that we are holding the freelist lock
} else if (thr->is_GC_task_thread()) {
} else if (thr->is_Java_thread()) {
} else {
ShouldNotReachHere(); // unaccounted thread type?
}
}
#endif
// Print the "label line" for free list stats.
template <class Chunk>
"%14s\t" "%14s\t" "%14s\t" "%14s\t" "%14s\t" "\n",
"bfrsurp", "surplus", "desired", "prvSwep", "bfrSwep",
"count", "cBirths", "cDeaths", "sBirths", "sDeaths");
}
// Print the AllocationStats for the given free list. If the second argument
// to the call is a non-null string, it is printed in the first column;
// otherwise, if the argument is null (the default), then the size of the
// (free list) block is printed in the first column.
template <class Chunk>
if (c != NULL) {
} else {
}
SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t"
SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\n",
}
#ifndef SERIALGC
// Needs to be after the definitions have been seen.
#endif // SERIALGC