< prev index next >

src/hotspot/share/memory/metaspace/spaceManager.cpp

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 73,90 **** size_t requested; if (is_class()) { switch (type) { case Metaspace::BootMetaspaceType: requested = Metaspace::first_class_chunk_word_size(); break; ! case Metaspace::UnsafeAnonymousMetaspaceType: requested = ClassSpecializedChunk; break; case Metaspace::ReflectionMetaspaceType: requested = ClassSpecializedChunk; break; default: requested = ClassSmallChunk; break; } } else { switch (type) { case Metaspace::BootMetaspaceType: requested = Metaspace::first_chunk_word_size(); break; ! case Metaspace::UnsafeAnonymousMetaspaceType: requested = SpecializedChunk; break; case Metaspace::ReflectionMetaspaceType: requested = SpecializedChunk; break; default: requested = SmallChunk; break; } } --- 73,90 ---- size_t requested; if (is_class()) { switch (type) { case Metaspace::BootMetaspaceType: requested = Metaspace::first_class_chunk_word_size(); break; ! case Metaspace::ShortLivedMetaspaceType: requested = ClassSpecializedChunk; break; case Metaspace::ReflectionMetaspaceType: requested = ClassSpecializedChunk; break; default: requested = ClassSmallChunk; break; } } else { switch (type) { case Metaspace::BootMetaspaceType: requested = Metaspace::first_chunk_word_size(); break; ! case Metaspace::ShortLivedMetaspaceType: requested = SpecializedChunk; break; case Metaspace::ReflectionMetaspaceType: requested = SpecializedChunk; break; default: requested = SmallChunk; break; } }
*** 112,130 **** // Decide between a small chunk and a medium chunk. Up to // _small_chunk_limit small chunks can be allocated. // After that a medium chunk is preferred. size_t chunk_word_size; ! // Special case for unsafe anonymous metadata space. ! // UnsafeAnonymous metadata space is usually small since it is used for ! // class loader data's whose life cycle is governed by one class such as an ! // unsafe anonymous class. The majority within 1K - 2K range and // rarely about 4K (64-bits JVM). // Instead of jumping to SmallChunk after initial chunk exhausted, keeping allocation // from SpecializeChunk up to _anon_or_delegating_metadata_specialize_chunk_limit (4) // reduces space waste from 60+% to around 30%. ! if ((_space_type == Metaspace::UnsafeAnonymousMetaspaceType || _space_type == Metaspace::ReflectionMetaspaceType) && _mdtype == Metaspace::NonClassType && num_chunks_by_type(SpecializedIndex) < anon_and_delegating_metadata_specialize_chunk_limit && word_size + Metachunk::overhead() <= SpecializedChunk) { return SpecializedChunk; } --- 112,130 ---- // Decide between a small chunk and a medium chunk. Up to // _small_chunk_limit small chunks can be allocated. // After that a medium chunk is preferred. size_t chunk_word_size; ! // Special case for nonfindable metadata space. ! // ShortLived metadata space is usually small since it is used for ! // class loader data's whose life cycle is governed by one class such as a ! // weak nonfindable or unsafe anonymous class. The majority within 1K - 2K range and // rarely about 4K (64-bits JVM). // Instead of jumping to SmallChunk after initial chunk exhausted, keeping allocation // from SpecializeChunk up to _anon_or_delegating_metadata_specialize_chunk_limit (4) // reduces space waste from 60+% to around 30%. ! if ((_space_type == Metaspace::ShortLivedMetaspaceType || _space_type == Metaspace::ReflectionMetaspaceType) && _mdtype == Metaspace::NonClassType && num_chunks_by_type(SpecializedIndex) < anon_and_delegating_metadata_specialize_chunk_limit && word_size + Metachunk::overhead() <= SpecializedChunk) { return SpecializedChunk; }
*** 177,187 **** assert(vs_list()->current_virtual_space() != NULL, "Should have been set"); assert(current_chunk() == NULL || current_chunk()->allocate(word_size) == NULL, "Don't need to expand"); ! MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); if (log_is_enabled(Trace, gc, metaspace, freelist)) { size_t words_left = 0; size_t words_used = 0; if (current_chunk() != NULL) { --- 177,187 ---- assert(vs_list()->current_virtual_space() != NULL, "Should have been set"); assert(current_chunk() == NULL || current_chunk()->allocate(word_size) == NULL, "Don't need to expand"); ! MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); if (log_is_enabled(Trace, gc, metaspace, freelist)) { size_t words_left = 0; size_t words_used = 0; if (current_chunk() != NULL) {
*** 282,292 **** SpaceManager::~SpaceManager() { // This call this->_lock which can't be done while holding MetaspaceExpand_lock DEBUG_ONLY(verify_metrics()); ! MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); account_for_spacemanager_death(); Log(gc, metaspace, freelist) log; if (log.is_trace()) { --- 282,293 ---- SpaceManager::~SpaceManager() { // This call this->_lock which can't be done while holding MetaspaceExpand_lock DEBUG_ONLY(verify_metrics()); ! MutexLockerEx fcl(MetaspaceExpand_lock, ! Mutex::_no_safepoint_check_flag); account_for_spacemanager_death(); Log(gc, metaspace, freelist) log; if (log.is_trace()) {
*** 399,409 **** return next; } MetaWord* SpaceManager::allocate(size_t word_size) { ! MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag); size_t raw_word_size = get_allocation_word_size(word_size); BlockFreelist* fl = block_freelists(); MetaWord* p = NULL; // Allocation from the dictionary is expensive in the sense that --- 400,410 ---- return next; } MetaWord* SpaceManager::allocate(size_t word_size) { ! MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); size_t raw_word_size = get_allocation_word_size(word_size); BlockFreelist* fl = block_freelists(); MetaWord* p = NULL; // Allocation from the dictionary is expensive in the sense that
*** 495,505 **** out->add_free_blocks_info(block_freelists()->num_blocks(), block_freelists()->total_size()); } } void SpaceManager::add_to_statistics(SpaceManagerStatistics* out) const { ! MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag); add_to_statistics_locked(out); } #ifdef ASSERT void SpaceManager::verify_metrics_locked() const { --- 496,506 ---- out->add_free_blocks_info(block_freelists()->num_blocks(), block_freelists()->total_size()); } } void SpaceManager::add_to_statistics(SpaceManagerStatistics* out) const { ! MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); add_to_statistics_locked(out); } #ifdef ASSERT void SpaceManager::verify_metrics_locked() const {
*** 516,526 **** assert_counter(_used_words, chunk_stats.used(), "SpaceManager::_used_words"); assert_counter(_overhead_words, chunk_stats.overhead(), "SpaceManager::_overhead_words"); } void SpaceManager::verify_metrics() const { ! MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag); verify_metrics_locked(); } #endif // ASSERT --- 517,527 ---- assert_counter(_used_words, chunk_stats.used(), "SpaceManager::_used_words"); assert_counter(_overhead_words, chunk_stats.overhead(), "SpaceManager::_overhead_words"); } void SpaceManager::verify_metrics() const { ! MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); verify_metrics_locked(); } #endif // ASSERT
< prev index next >