src/share/vm/memory/metablock.cpp

changeset 4327
eade6b2e4782
child 4712
3efdfd6ddbf2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/memory/metablock.cpp	Thu Nov 29 10:09:04 2012 -0800
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "memory/allocation.hpp"
    1.30 +#include "memory/metablock.hpp"
    1.31 +#include "utilities/copy.hpp"
    1.32 +#include "utilities/debug.hpp"
    1.33 +
    1.34 +// Blocks of space for metadata are allocated out of Metachunks.
    1.35 +//
    1.36 +// Metachunk are allocated out of MetadataVirtualspaces and once
    1.37 +// allocated there is no explicit link between a Metachunk and
    1.38 +// the MetadataVirtualspaces from which it was allocated.
    1.39 +//
    1.40 +// Each SpaceManager maintains a
    1.41 +// list of the chunks it is using and the current chunk.  The current
    1.42 +// chunk is the chunk from which allocations are done.  Space freed in
    1.43 +// a chunk is placed on the free list of blocks (BlockFreelist) and
    1.44 +// reused from there.
    1.45 +//
    1.46 +// Future modification
    1.47 +//
    1.48 +// The Metachunk can conceivable be replaced by the Chunk in
    1.49 +// allocation.hpp.  Note that the latter Chunk is the space for
    1.50 +// allocation (allocations from the chunk are out of the space in
    1.51 +// the Chunk after the header for the Chunk) where as Metachunks
    1.52 +// point to space in a VirtualSpace.  To replace Metachunks with
    1.53 +// Chunks, change Chunks so that they can be allocated out of a VirtualSpace.
    1.54 +size_t Metablock::_min_block_byte_size = sizeof(Metablock);
    1.55 +
    1.56 +#ifdef ASSERT
    1.57 +size_t Metablock::_overhead =
    1.58 +  Chunk::aligned_overhead_size(sizeof(Metablock)) / BytesPerWord;
    1.59 +#else
    1.60 +size_t Metablock::_overhead = 0;
    1.61 +#endif
    1.62 +
    1.63 +// New blocks returned by the Metaspace are zero initialized.
    1.64 +// We should fix the constructors to not assume this instead.
    1.65 +Metablock* Metablock::initialize(MetaWord* p, size_t word_size) {
    1.66 +  if (p == NULL) {
    1.67 +    return NULL;
    1.68 +  }
    1.69 +
    1.70 +  Metablock* result = (Metablock*) p;
    1.71 +
    1.72 +  // Clear the memory
    1.73 +  Copy::fill_to_aligned_words((HeapWord*)result, word_size);
    1.74 +#ifdef ASSERT
    1.75 +  result->set_word_size(word_size);
    1.76 +#endif
    1.77 +  return result;
    1.78 +}

mercurial