hotspot/src/share/vm/memory/metablock.cpp
changeset 20729 0a687ee7097d
parent 20728 25114f3ae9af
child 20730 59f433c86d9d
equal deleted inserted replaced
20728:25114f3ae9af 20729:0a687ee7097d
     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  */
       
    24 
       
    25 #include "precompiled.hpp"
       
    26 #include "memory/allocation.hpp"
       
    27 #include "memory/metablock.hpp"
       
    28 #include "utilities/copy.hpp"
       
    29 #include "utilities/debug.hpp"
       
    30 
       
    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);
       
    52 
       
    53 // New blocks returned by the Metaspace are zero initialized.
       
    54 // We should fix the constructors to not assume this instead.
       
    55 Metablock* Metablock::initialize(MetaWord* p, size_t word_size) {
       
    56   if (p == NULL) {
       
    57     return NULL;
       
    58   }
       
    59 
       
    60   Metablock* result = (Metablock*) p;
       
    61 
       
    62   // Clear the memory
       
    63   Copy::fill_to_aligned_words((HeapWord*)result, word_size);
       
    64 #ifdef ASSERT
       
    65   result->set_word_size(word_size);
       
    66 #endif
       
    67   return result;
       
    68 }