Path: blob/master/src/hotspot/share/memory/classLoaderMetaspace.hpp
40950 views
/*1* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/23#ifndef SHARE_MEMORY_CLASSLOADERMETASPACE_HPP24#define SHARE_MEMORY_CLASSLOADERMETASPACE_HPP2526#include "memory/allocation.hpp"27#include "memory/metaspace.hpp"28#include "utilities/debug.hpp"29#include "utilities/globalDefinitions.hpp"3031class outputStream;3233namespace metaspace {34struct ClmsStats;35class MetaspaceArena;36}3738// A ClassLoaderMetaspace manages MetaspaceArena(s) for a CLD.39//40// A CLD owns one MetaspaceArena if UseCompressedClassPointers is false. Otherwise41// it owns two - one for the Klass* objects from the class space, one for the other42// types of MetaspaceObjs from the non-class space.43//44// +------+ +----------------------+ +-------------------+45// | CLD | ---> | ClassLoaderMetaspace | ----> | (non class) Arena |46// +------+ +----------------------+ | +-------------------+ allocation top47// | | v48// | + chunk -- chunk ... -- chunk49// |50// | +-------------------+51// +--> | (class) Arena |52// +-------------------+53// |54// + chunk ... chunk55// ^56// alloc top57//58class ClassLoaderMetaspace : public CHeapObj<mtClass> {5960// A reference to an outside lock, held by the CLD.61Mutex* const _lock;6263const Metaspace::MetaspaceType _space_type;6465// Arena for allocations from non-class metaspace66// (resp. for all allocations if -XX:-UseCompressedClassPointers).67metaspace::MetaspaceArena* _non_class_space_arena;6869// Arena for allocations from class space70// (NULL if -XX:-UseCompressedClassPointers).71metaspace::MetaspaceArena* _class_space_arena;7273Mutex* lock() const { return _lock; }74metaspace::MetaspaceArena* non_class_space_arena() const { return _non_class_space_arena; }75metaspace::MetaspaceArena* class_space_arena() const { return _class_space_arena; }7677public:7879ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType space_type);8081~ClassLoaderMetaspace();8283Metaspace::MetaspaceType space_type() const { return _space_type; }8485// Allocate word_size words from Metaspace.86MetaWord* allocate(size_t word_size, Metaspace::MetadataType mdType);8788// Attempt to expand the GC threshold to be good for at least another word_size words89// and allocate. Returns NULL if failure. Used during Metaspace GC.90MetaWord* expand_and_allocate(size_t word_size, Metaspace::MetadataType mdType);9192// Prematurely returns a metaspace allocation to the _block_freelists93// because it is not needed anymore.94void deallocate(MetaWord* ptr, size_t word_size, bool is_class);9596// Update statistics. This walks all in-use chunks.97void add_to_statistics(metaspace::ClmsStats* out) const;9899DEBUG_ONLY(void verify() const;)100101// This only exists for JFR and jcmd VM.classloader_stats. We may want to102// change this. Capacity as a stat is of questionable use since it may103// contain committed and uncommitted areas. For now we do this to maintain104// backward compatibility with JFR.105void calculate_jfr_stats(size_t* p_used_bytes, size_t* p_capacity_bytes) const;106107}; // end: ClassLoaderMetaspace108109110#endif // SHARE_MEMORY_CLASSLOADERMETASPACE_HPP111112113