< prev index next >

src/hotspot/share/memory/classLoaderMetaspace.cpp

Print this page

 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 #include "precompiled.hpp"
 27 #include "logging/log.hpp"
 28 #include "memory/classLoaderMetaspace.hpp"
 29 #include "memory/metaspace.hpp"
 30 #include "memory/metaspaceUtils.hpp"

 31 #include "memory/metaspace/chunkManager.hpp"
 32 #include "memory/metaspace/internalStats.hpp"
 33 #include "memory/metaspace/metaspaceArena.hpp"
 34 #include "memory/metaspace/metaspaceArenaGrowthPolicy.hpp"
 35 #include "memory/metaspace/metaspaceSettings.hpp"
 36 #include "memory/metaspace/metaspaceStatistics.hpp"
 37 #include "memory/metaspace/runningCounters.hpp"
 38 #include "memory/metaspaceTracer.hpp"


 39 #include "utilities/debug.hpp"

 40 
 41 using metaspace::ChunkManager;
 42 using metaspace::MetaspaceArena;
 43 using metaspace::ArenaGrowthPolicy;
 44 using metaspace::RunningCounters;
 45 using metaspace::InternalStats;
 46 
 47 #define LOGFMT         "CLMS @" PTR_FORMAT " "
 48 #define LOGFMT_ARGS    p2i(this)
 49 
 50 ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType space_type) :
 51   _lock(lock),
 52   _space_type(space_type),
 53   _non_class_space_arena(NULL),
 54   _class_space_arena(NULL)
 55 {
 56   ChunkManager* const non_class_cm =
 57           ChunkManager::chunkmanager_nonclass();
 58 


 59   // Initialize non-class Arena
 60   _non_class_space_arena = new MetaspaceArena(
 61       non_class_cm,
 62       ArenaGrowthPolicy::policy_for_space_type(space_type, false),

 63       lock,
 64       RunningCounters::used_nonclass_counter(),
 65       "non-class sm");
 66 
 67   // If needed, initialize class arena
 68   if (Metaspace::using_class_space()) {

 69     ChunkManager* const class_cm =
 70             ChunkManager::chunkmanager_class();
 71     _class_space_arena = new MetaspaceArena(
 72         class_cm,
 73         ArenaGrowthPolicy::policy_for_space_type(space_type, true),

 74         lock,
 75         RunningCounters::used_class_counter(),
 76         "class sm");





 77   }
 78 
 79   UL2(debug, "born (nonclass arena: " PTR_FORMAT ", class arena: " PTR_FORMAT ".",
 80       p2i(_non_class_space_arena), p2i(_class_space_arena));
 81 }
 82 
 83 ClassLoaderMetaspace::~ClassLoaderMetaspace() {
 84   UL(debug, "dies.");
 85 
 86   delete _non_class_space_arena;
 87   delete _class_space_arena;
 88 
 89 }
 90 
 91 // Allocate word_size words from Metaspace.
 92 MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdType) {
 93   if (Metaspace::is_class_space_allocation(mdType)) {
 94     return class_space_arena()->allocate(word_size);
 95   } else {
 96     return non_class_space_arena()->allocate(word_size);

 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 #include "precompiled.hpp"
 27 #include "logging/log.hpp"
 28 #include "memory/classLoaderMetaspace.hpp"
 29 #include "memory/metaspace.hpp"
 30 #include "memory/metaspaceUtils.hpp"
 31 #include "memory/metaspace/metaspaceAlignment.hpp"
 32 #include "memory/metaspace/chunkManager.hpp"
 33 #include "memory/metaspace/internalStats.hpp"
 34 #include "memory/metaspace/metaspaceArena.hpp"
 35 #include "memory/metaspace/metaspaceArenaGrowthPolicy.hpp"
 36 #include "memory/metaspace/metaspaceSettings.hpp"
 37 #include "memory/metaspace/metaspaceStatistics.hpp"
 38 #include "memory/metaspace/runningCounters.hpp"
 39 #include "memory/metaspaceTracer.hpp"
 40 #include "oops/compressedKlass.hpp"
 41 #include "utilities/align.hpp"
 42 #include "utilities/debug.hpp"
 43 #include "utilities/globalDefinitions.hpp"
 44 
 45 using metaspace::ChunkManager;
 46 using metaspace::MetaspaceArena;
 47 using metaspace::ArenaGrowthPolicy;
 48 using metaspace::RunningCounters;
 49 using metaspace::InternalStats;
 50 
 51 #define LOGFMT         "CLMS @" PTR_FORMAT " "
 52 #define LOGFMT_ARGS    p2i(this)
 53 
 54 ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType space_type) :
 55   _lock(lock),
 56   _space_type(space_type),
 57   _non_class_space_arena(NULL),
 58   _class_space_arena(NULL)
 59 {
 60   ChunkManager* const non_class_cm =
 61           ChunkManager::chunkmanager_nonclass();
 62 
 63   const int klass_alignment_words = KlassAlignmentInBytes / BytesPerWord;
 64 
 65   // Initialize non-class Arena
 66   _non_class_space_arena = new MetaspaceArena(
 67       non_class_cm,
 68       ArenaGrowthPolicy::policy_for_space_type(space_type, false),
 69       metaspace::MetaspaceMinAlignmentWords,
 70       lock,
 71       RunningCounters::used_nonclass_counter(),
 72       "non-class sm");
 73 
 74   // If needed, initialize class arena
 75   if (Metaspace::using_class_space()) {
 76     // Klass instances live in class space and must be aligned correctly.
 77     ChunkManager* const class_cm =
 78             ChunkManager::chunkmanager_class();
 79     _class_space_arena = new MetaspaceArena(
 80         class_cm,
 81         ArenaGrowthPolicy::policy_for_space_type(space_type, true),
 82         klass_alignment_words,
 83         lock,
 84         RunningCounters::used_class_counter(),
 85         "class sm");
 86   } else {
 87     // note for lilliput, this path should be restricted to 32bit only. There, klass alignment
 88     //  should be compatible with metaspace minimal alignment since we store Klass structures
 89     //  in regular metaspace.
 90     NOT_LP64(STATIC_ASSERT(metaspace::MetaspaceMinAlignmentBytes == KlassAlignmentInBytes));
 91   }
 92 
 93   UL2(debug, "born (nonclass arena: " PTR_FORMAT ", class arena: " PTR_FORMAT ".",
 94       p2i(_non_class_space_arena), p2i(_class_space_arena));
 95 }
 96 
 97 ClassLoaderMetaspace::~ClassLoaderMetaspace() {
 98   UL(debug, "dies.");
 99 
100   delete _non_class_space_arena;
101   delete _class_space_arena;
102 
103 }
104 
105 // Allocate word_size words from Metaspace.
106 MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdType) {
107   if (Metaspace::is_class_space_allocation(mdType)) {
108     return class_space_arena()->allocate(word_size);
109   } else {
110     return non_class_space_arena()->allocate(word_size);
< prev index next >