src/hotspot/share/memory/metaspace/smallBlocks.cpp
author dcubed
Sat, 21 Sep 2019 10:13:25 -0400
changeset 58252 14c1ff687621
parent 50193 49c3e91c424f
child 58063 bdf136b8ae0e
permissions -rw-r--r--
8231323: ProblemList jdk/jfr/jcmd/TestJcmdConfigure.java Reviewed-by: ysuenaga
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     1
/*
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     4
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     7
 * published by the Free Software Foundation.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     8
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    13
 * accompanied this code).
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    14
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    18
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    21
 * questions.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    22
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    23
 */
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    24
#include "precompiled.hpp"
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    25
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    26
#include "memory/metaspace/smallBlocks.hpp"
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    27
#include "utilities/globalDefinitions.hpp"
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    28
#include "utilities/ostream.hpp"
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    29
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    30
namespace metaspace {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    31
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    32
void SmallBlocks::print_on(outputStream* st) const {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    33
  st->print_cr("SmallBlocks:");
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    34
  for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    35
    uint k = i - _small_block_min_size;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    36
    st->print_cr("small_lists size " SIZE_FORMAT " count " SIZE_FORMAT, _small_lists[k].size(), _small_lists[k].count());
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    37
  }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    38
}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    39
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    40
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    41
// Returns the total size, in words, of all blocks, across all block sizes.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    42
size_t SmallBlocks::total_size() const {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    43
  size_t result = 0;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    44
  for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    45
    uint k = i - _small_block_min_size;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    46
    result = result + _small_lists[k].count() * _small_lists[k].size();
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    47
  }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    48
  return result;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    49
}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    50
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    51
// Returns the total number of all blocks across all block sizes.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    52
uintx SmallBlocks::total_num_blocks() const {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    53
  uintx result = 0;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    54
  for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    55
    uint k = i - _small_block_min_size;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    56
    result = result + _small_lists[k].count();
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    57
  }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    58
  return result;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    59
}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    60
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    61
} // namespace metaspace
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    62