src/share/vm/memory/metablock.cpp

Mon, 17 Jun 2013 11:17:49 +0100

author
chegar
date
Mon, 17 Jun 2013 11:17:49 +0100
changeset 5251
eaf3742822ec
parent 4715
5939f5953b45
child 5705
335b388c4b28
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "memory/allocation.hpp"
    27 #include "memory/metablock.hpp"
    28 #include "utilities/copy.hpp"
    29 #include "utilities/debug.hpp"
    31 // Blocks of space for metadata are allocated out of Metachunks.
    32 //
    33 // Metachunk are allocated out of MetadataVirtualspaces and once
    34 // allocated there is no explicit link between a Metachunk and
    35 // the MetadataVirtualspaces from which it was allocated.
    36 //
    37 // Each SpaceManager maintains a
    38 // list of the chunks it is using and the current chunk.  The current
    39 // chunk is the chunk from which allocations are done.  Space freed in
    40 // a chunk is placed on the free list of blocks (BlockFreelist) and
    41 // reused from there.
    42 //
    43 // Future modification
    44 //
    45 // The Metachunk can conceivable be replaced by the Chunk in
    46 // allocation.hpp.  Note that the latter Chunk is the space for
    47 // allocation (allocations from the chunk are out of the space in
    48 // the Chunk after the header for the Chunk) where as Metachunks
    49 // point to space in a VirtualSpace.  To replace Metachunks with
    50 // Chunks, change Chunks so that they can be allocated out of a VirtualSpace.
    51 size_t Metablock::_min_block_byte_size = sizeof(Metablock);
    53 #ifdef ASSERT
    54 size_t Metablock::_overhead =
    55   Chunk::aligned_overhead_size(sizeof(Metablock)) / BytesPerWord;
    56 #else
    57 size_t Metablock::_overhead = 0;
    58 #endif
    60 // New blocks returned by the Metaspace are zero initialized.
    61 // We should fix the constructors to not assume this instead.
    62 Metablock* Metablock::initialize(MetaWord* p, size_t word_size) {
    63   if (p == NULL) {
    64     return NULL;
    65   }
    67   Metablock* result = (Metablock*) p;
    69   // Clear the memory
    70   Copy::fill_to_aligned_words((HeapWord*)result, word_size);
    71 #ifdef ASSERT
    72   result->set_word_size(word_size);
    73 #endif
    74   return result;
    75 }

mercurial