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