Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.cpp
40957 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2020 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "memory/metaspace/metaspaceArenaGrowthPolicy.hpp"27#include "utilities/globalDefinitions.hpp"2829namespace metaspace {3031// hard-coded chunk allocation sequences for various space types32// (Note: when modifying this, don't add jumps of more than double the33// last chunk size. There is a gtest testing this, see test_arenagrowthpolicy.cpp)3435static const chunklevel_t g_sequ_standard_non_class[] = {36chunklevel::CHUNK_LEVEL_4K,37chunklevel::CHUNK_LEVEL_4K,38chunklevel::CHUNK_LEVEL_4K,39chunklevel::CHUNK_LEVEL_8K,40chunklevel::CHUNK_LEVEL_16K41// .. repeat last42};4344static const chunklevel_t g_sequ_standard_class[] = {45chunklevel::CHUNK_LEVEL_2K,46chunklevel::CHUNK_LEVEL_2K,47chunklevel::CHUNK_LEVEL_4K,48chunklevel::CHUNK_LEVEL_8K,49chunklevel::CHUNK_LEVEL_16K50// .. repeat last51};5253static const chunklevel_t g_sequ_anon_non_class[] = {54chunklevel::CHUNK_LEVEL_1K,55// .. repeat last56};5758static const chunklevel_t g_sequ_anon_class[] = {59chunklevel::CHUNK_LEVEL_1K,60// .. repeat last61};6263static const chunklevel_t g_sequ_refl_non_class[] = {64chunklevel::CHUNK_LEVEL_2K,65chunklevel::CHUNK_LEVEL_1K66// .. repeat last67};6869static const chunklevel_t g_sequ_refl_class[] = {70chunklevel::CHUNK_LEVEL_1K,71// .. repeat last72};7374// Boot class loader: give it large chunks: beyond commit granule size75// (typically 64K) the costs for large chunks largely diminishes since76// they are committed on the fly.77static const chunklevel_t g_sequ_boot_non_class[] = {78chunklevel::CHUNK_LEVEL_4M,79chunklevel::CHUNK_LEVEL_1M80// .. repeat last81};8283static const chunklevel_t g_sequ_boot_class[] = {84chunklevel::CHUNK_LEVEL_256K85// .. repeat last86};8788const ArenaGrowthPolicy* ArenaGrowthPolicy::policy_for_space_type(Metaspace::MetaspaceType space_type, bool is_class) {8990#define DEFINE_CLASS_FOR_ARRAY(what) \91static ArenaGrowthPolicy chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(chunklevel_t));9293DEFINE_CLASS_FOR_ARRAY(standard_non_class)94DEFINE_CLASS_FOR_ARRAY(standard_class)95DEFINE_CLASS_FOR_ARRAY(anon_non_class)96DEFINE_CLASS_FOR_ARRAY(anon_class)97DEFINE_CLASS_FOR_ARRAY(refl_non_class)98DEFINE_CLASS_FOR_ARRAY(refl_class)99DEFINE_CLASS_FOR_ARRAY(boot_non_class)100DEFINE_CLASS_FOR_ARRAY(boot_class)101102if (is_class) {103switch(space_type) {104case Metaspace::StandardMetaspaceType: return &chunk_alloc_sequence_standard_class;105case Metaspace::ReflectionMetaspaceType: return &chunk_alloc_sequence_refl_class;106case Metaspace::ClassMirrorHolderMetaspaceType: return &chunk_alloc_sequence_anon_class;107case Metaspace::BootMetaspaceType: return &chunk_alloc_sequence_boot_class;108default: ShouldNotReachHere();109}110} else {111switch(space_type) {112case Metaspace::StandardMetaspaceType: return &chunk_alloc_sequence_standard_non_class;113case Metaspace::ReflectionMetaspaceType: return &chunk_alloc_sequence_refl_non_class;114case Metaspace::ClassMirrorHolderMetaspaceType: return &chunk_alloc_sequence_anon_non_class;115case Metaspace::BootMetaspaceType: return &chunk_alloc_sequence_boot_non_class;116default: ShouldNotReachHere();117}118}119120return NULL;121122}123124} // namespace125126127128