src/hotspot/share/memory/metaspace/chunkAllocSequence.cpp
author stuefe
Mon, 21 Oct 2019 16:43:06 +0200
branchstuefe-new-metaspace-branch
changeset 58716 960e372a6065
parent 58381 5f5558a1a113
child 58807 3863dfd99d8e
permissions -rw-r--r--
Fix error in chunk allocation strategy which caused small chunks to dominate
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     1
/*
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     2
 * Copyright (c) 2019, SAP SE. All rights reserved.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     3
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     5
 *
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     8
 * published by the Free Software Foundation.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
     9
 *
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    14
 * accompanied this code).
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    15
 *
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    19
 *
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    22
 * questions.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    23
 *
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    24
 */
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    25
#include "precompiled.hpp"
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    26
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    27
#include "memory/metaspace/chunkAllocSequence.hpp"
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    28
#include "memory/metaspace/chunkLevel.hpp"
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    29
#include "utilities/globalDefinitions.hpp"
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    30
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    31
namespace metaspace {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    32
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    33
// A chunk allocation sequence which can be encoded with a simple const array.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    34
class ConstantChunkAllocSequence : public ChunkAllocSequence {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    35
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    36
  // integer array specifying chunk level allocation progression.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    37
  // Last chunk is to be an endlessly repeated allocation.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    38
  const chklvl_t* const _entries;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    39
  const int _num_entries;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    40
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    41
public:
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    42
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    43
  ConstantChunkAllocSequence(const chklvl_t* array, int num_entries)
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    44
    : _entries(array)
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    45
    , _num_entries(num_entries)
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    46
  {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    47
    assert(_num_entries > 0, "must not be empty.");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    48
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    49
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    50
  chklvl_t get_next_chunk_level(int num_allocated) const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    51
    if (num_allocated >= _num_entries) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    52
      // Caller shall repeat last allocation
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    53
      return _entries[_num_entries - 1];
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    54
    }
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    55
    return _entries[num_allocated];
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    56
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    57
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    58
};
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    59
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    60
// hard-coded chunk allocation sequences for various space types
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    61
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    62
///////////////////////////
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    63
// chunk allocation sequences for normal loaders:
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    64
static const chklvl_t g_sequ_standard_non_class[] = {
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    65
    chklvl::CHUNK_LEVEL_4K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    66
    chklvl::CHUNK_LEVEL_4K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    67
    chklvl::CHUNK_LEVEL_4K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    68
    chklvl::CHUNK_LEVEL_4K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    69
    chklvl::CHUNK_LEVEL_64K
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    70
    // .. repeat last
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    71
};
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    72
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    73
static const chklvl_t g_sequ_standard_class[] = {
58381
5f5558a1a113 Correct chunk allocation size for standard loaders in class space
stuefe
parents: 58063
diff changeset
    74
    chklvl::CHUNK_LEVEL_2K,
5f5558a1a113 Correct chunk allocation size for standard loaders in class space
stuefe
parents: 58063
diff changeset
    75
    chklvl::CHUNK_LEVEL_2K,
5f5558a1a113 Correct chunk allocation size for standard loaders in class space
stuefe
parents: 58063
diff changeset
    76
    chklvl::CHUNK_LEVEL_2K,
5f5558a1a113 Correct chunk allocation size for standard loaders in class space
stuefe
parents: 58063
diff changeset
    77
    chklvl::CHUNK_LEVEL_2K,
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    78
    chklvl::CHUNK_LEVEL_32K
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    79
    // .. repeat last
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    80
};
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    81
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    82
///////////////////////////
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    83
// chunk allocation sequences for reflection/anonymous loaders:
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    84
// We allocate four smallish chunks before progressing to bigger chunks.
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    85
static const chklvl_t g_sequ_anon_non_class[] = {
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    86
    chklvl::CHUNK_LEVEL_1K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    87
    chklvl::CHUNK_LEVEL_1K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    88
    chklvl::CHUNK_LEVEL_1K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    89
    chklvl::CHUNK_LEVEL_1K,
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    90
    chklvl::CHUNK_LEVEL_2K
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    91
    // .. repeat last
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    92
};
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    93
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    94
static const chklvl_t g_sequ_anon_class[] = {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    95
    chklvl::CHUNK_LEVEL_1K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    96
    chklvl::CHUNK_LEVEL_1K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    97
    chklvl::CHUNK_LEVEL_1K,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
    98
    chklvl::CHUNK_LEVEL_1K,
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
    99
    chklvl::CHUNK_LEVEL_2K
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   100
    // .. repeat last
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   101
};
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   102
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   103
#define DEFINE_CLASS_FOR_ARRAY(what) \
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   104
  static ConstantChunkAllocSequence g_chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(chklvl_t));
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   105
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   106
DEFINE_CLASS_FOR_ARRAY(standard_non_class)
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   107
DEFINE_CLASS_FOR_ARRAY(standard_class)
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   108
DEFINE_CLASS_FOR_ARRAY(anon_non_class)
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   109
DEFINE_CLASS_FOR_ARRAY(anon_class)
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   110
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   111
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   112
class BootLoaderChunkAllocSequence : public ChunkAllocSequence {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   113
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   114
  // For now, this mirrors what the old code did
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   115
  // (see SpaceManager::get_initial_chunk_size() and SpaceManager::calc_chunk_size).
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   116
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   117
  // Not sure how much sense this still makes, especially with CDS - by default we
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   118
  // now load JDK classes from CDS and therefore most of the boot loader
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   119
  // chunks remain unoccupied.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   120
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   121
  // Also, InitialBootClassLoaderMetaspaceSize was/is confusing since it only applies
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   122
  // to the non-class chunk.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   123
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   124
  const bool _is_class;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   125
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   126
  static chklvl_t calc_initial_chunk_level(bool is_class) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   127
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   128
    size_t word_size = 0;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   129
    if (is_class) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   130
      // In the old version first class space chunk for boot loader was always medium class chunk size * 6.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   131
      word_size = (32 * K * 6) / BytesPerWord;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   132
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   133
    } else {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   134
      //assert(InitialBootClassLoaderMetaspaceSize < chklvl::MAX_CHUNK_BYTE_SIZE,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   135
      //       "InitialBootClassLoaderMetaspaceSize too large");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   136
      word_size = MIN2(InitialBootClassLoaderMetaspaceSize,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   137
                       chklvl::MAX_CHUNK_BYTE_SIZE) / BytesPerWord;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   138
    }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   139
    return chklvl::level_fitting_word_size(word_size);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   140
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   141
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   142
public:
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   143
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   144
  BootLoaderChunkAllocSequence(bool is_class)
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   145
    : _is_class(is_class)
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   146
  {}
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   147
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   148
  chklvl_t get_next_chunk_level(int num_allocated) const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   149
    if (num_allocated == 0) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   150
      return calc_initial_chunk_level(_is_class);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   151
    }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   152
    // bit arbitrary, but this is what the old code did. Can tweak later if needed.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   153
    return chklvl::CHUNK_LEVEL_64K;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   154
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   155
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   156
};
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   157
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   158
static BootLoaderChunkAllocSequence g_chunk_alloc_sequence_boot_non_class(false);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   159
static BootLoaderChunkAllocSequence g_chunk_alloc_sequence_boot_class(true);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   160
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   161
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   162
const ChunkAllocSequence* ChunkAllocSequence::alloc_sequence_by_space_type(MetaspaceType space_type, bool is_class) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   163
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   164
  if (is_class) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   165
    switch(space_type) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   166
    case StandardMetaspaceType:          return &g_chunk_alloc_sequence_standard_class;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   167
    case ReflectionMetaspaceType:
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   168
    case UnsafeAnonymousMetaspaceType:   return &g_chunk_alloc_sequence_anon_class;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   169
    case BootMetaspaceType:              return &g_chunk_alloc_sequence_boot_non_class;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   170
    default: ShouldNotReachHere();
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   171
    }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   172
  } else {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   173
    switch(space_type) {
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   174
    case StandardMetaspaceType:          return &g_chunk_alloc_sequence_standard_non_class;
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   175
    case ReflectionMetaspaceType:
58716
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   176
    case UnsafeAnonymousMetaspaceType:   return &g_chunk_alloc_sequence_anon_non_class;
960e372a6065 Fix error in chunk allocation strategy which caused small chunks to dominate
stuefe
parents: 58381
diff changeset
   177
    case BootMetaspaceType:              return &g_chunk_alloc_sequence_boot_non_class;
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   178
    default: ShouldNotReachHere();
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   179
    }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   180
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   181
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   182
  return NULL;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   183
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   184
}
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   185
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   186
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   187
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   188
} // namespace metaspace
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff changeset
   189