src/hotspot/share/memory/metaspace/classLoaderMetaspace.hpp
branchstuefe-new-metaspace-branch
changeset 58063 bdf136b8ae0e
child 58227 0e7d9a23261e
equal deleted inserted replaced
58062:65cad575ace3 58063:bdf136b8ae0e
       
     1 /*
       
     2  * Copyright (c) 2018, 2019, SAP SE. All rights reserved.
       
     3  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
       
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5  *
       
     6  * This code is free software; you can redistribute it and/or modify it
       
     7  * under the terms of the GNU General Public License version 2 only, as
       
     8  * published by the Free Software Foundation.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    21  * or visit www.oracle.com if you need additional information or have any
       
    22  * questions.
       
    23  *
       
    24  */
       
    25 
       
    26 #ifndef SHARE_MEMORY_METASPACE_CLASSLOADERMETASPACE_HPP
       
    27 #define SHARE_MEMORY_METASPACE_CLASSLOADERMETASPACE_HPP
       
    28 
       
    29 #include "memory/allocation.hpp"
       
    30 #include "memory/metaspace/metaspaceEnums.hpp"
       
    31 
       
    32 class Mutex;
       
    33 
       
    34 namespace metaspace {
       
    35 
       
    36 class SpaceManager;
       
    37 struct clms_stats_t;
       
    38 
       
    39 class ClassLoaderMetaspace : public CHeapObj<mtClass> {
       
    40 
       
    41   // The CLD lock.
       
    42   Mutex* const _lock;
       
    43 
       
    44   const MetaspaceType _space_type;
       
    45 
       
    46   SpaceManager* _non_class_space_manager;
       
    47   SpaceManager* _class_space_manager;
       
    48 
       
    49   Mutex* lock() const                            { return _lock; }
       
    50   SpaceManager* non_class_space_manager() const  { return _non_class_space_manager; }
       
    51   SpaceManager* class_space_manager() const      { return _class_space_manager; }
       
    52 
       
    53   SpaceManager* get_space_manager(bool is_class) {
       
    54     return is_class ? class_space_manager() : non_class_space_manager();
       
    55   }
       
    56 
       
    57 public:
       
    58 
       
    59   ClassLoaderMetaspace(Mutex* lock, MetaspaceType space_type);
       
    60 
       
    61   ~ClassLoaderMetaspace();
       
    62 
       
    63   MetaspaceType space_type() const { return _space_type; }
       
    64 
       
    65   // Allocate word_size words from Metaspace.
       
    66   MetaWord* allocate(size_t word_size, MetadataType mdType);
       
    67 
       
    68   // Attempt to expand the GC threshold to be good for at least another word_size words
       
    69   // and allocate. Returns NULL if failure. Used during Metaspace GC.
       
    70   MetaWord* expand_and_allocate(size_t word_size, MetadataType mdType);
       
    71 
       
    72   // Prematurely returns a metaspace allocation to the _block_freelists
       
    73   // because it is not needed anymore.
       
    74   void deallocate(MetaWord* ptr, size_t word_size, bool is_class);
       
    75 
       
    76   // Update statistics. This walks all in-use chunks.
       
    77   void add_to_statistics(clms_stats_t* out) const;
       
    78 
       
    79   DEBUG_ONLY(void verify(bool slow) const;)
       
    80 
       
    81   // TODO
       
    82   size_t allocated_blocks_bytes() const { return 0; }
       
    83   size_t allocated_chunks_bytes() const { return 0; }
       
    84 
       
    85 };
       
    86 
       
    87 } // namespace metaspace
       
    88 
       
    89 #endif // SHARE_MEMORY_METASPACE_CLASSLOADERMETASPACE_HPP