< prev index next > src/hotspot/share/memory/metaspace/metaspaceArena.cpp
Print this page
#include "memory/metaspace/chunkManager.hpp"
#include "memory/metaspace/counters.hpp"
#include "memory/metaspace/freeBlocks.hpp"
#include "memory/metaspace/internalStats.hpp"
#include "memory/metaspace/metachunk.hpp"
+ #include "memory/metaspace/metaspaceAlignment.hpp"
#include "memory/metaspace/metaspaceArena.hpp"
#include "memory/metaspace/metaspaceArenaGrowthPolicy.hpp"
#include "memory/metaspace/metaspaceCommon.hpp"
#include "memory/metaspace/metaspaceSettings.hpp"
#include "memory/metaspace/metaspaceStatistics.hpp"
_fbl = new FreeBlocks(); // Create only on demand
}
_fbl->add_block(p, word_size);
}
! MetaspaceArena::MetaspaceArena(ChunkManager* chunk_manager, const ArenaGrowthPolicy* growth_policy,
Mutex* lock, SizeAtomicCounter* total_used_words_counter,
const char* name) :
_lock(lock),
_chunk_manager(chunk_manager),
_growth_policy(growth_policy),
_chunks(),
_fbl(NULL),
_total_used_words_counter(total_used_words_counter),
_name(name)
#ifdef ASSERT
, _first_fence(NULL)
#endif
{
UL(debug, ": born.");
// Update statistics
InternalStats::inc_num_arena_births();
_fbl = new FreeBlocks(); // Create only on demand
}
_fbl->add_block(p, word_size);
}
! MetaspaceArena::MetaspaceArena(ChunkManager* chunk_manager, const ArenaGrowthPolicy* growth_policy, int alignment_words,
Mutex* lock, SizeAtomicCounter* total_used_words_counter,
const char* name) :
_lock(lock),
_chunk_manager(chunk_manager),
_growth_policy(growth_policy),
_chunks(),
+ _alignment_words(alignment_words),
_fbl(NULL),
_total_used_words_counter(total_used_words_counter),
_name(name)
#ifdef ASSERT
, _first_fence(NULL)
#endif
+
{
UL(debug, ": born.");
// Update statistics
InternalStats::inc_num_arena_births();
MetaWord* MetaspaceArena::allocate(size_t requested_word_size) {
MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag);
UL2(trace, "requested " SIZE_FORMAT " words.", requested_word_size);
MetaWord* p = NULL;
! const size_t raw_word_size = get_raw_word_size_for_requested_word_size(requested_word_size);
// Before bothering the arena proper, attempt to re-use a block from the free blocks list
if (_fbl != NULL && !_fbl->is_empty()) {
p = _fbl->remove_block(raw_word_size);
if (p != NULL) {
MetaWord* MetaspaceArena::allocate(size_t requested_word_size) {
MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag);
UL2(trace, "requested " SIZE_FORMAT " words.", requested_word_size);
MetaWord* p = NULL;
! const size_t raw_word_size = get_raw_word_size_for_requested_word_size(requested_word_size, _alignment_words);
// Before bothering the arena proper, attempt to re-use a block from the free blocks list
if (_fbl != NULL && !_fbl->is_empty()) {
p = _fbl->remove_block(raw_word_size);
if (p != NULL) {
// Allocate from the arena proper, once dictionary allocations and fencing are sorted out.
MetaWord* MetaspaceArena::allocate_inner(size_t requested_word_size) {
assert_lock_strong(lock());
! const size_t raw_word_size = get_raw_word_size_for_requested_word_size(requested_word_size);
MetaWord* p = NULL;
bool current_chunk_too_small = false;
bool commit_failure = false;
if (current_chunk() != NULL) {
// Allocate from the arena proper, once dictionary allocations and fencing are sorted out.
MetaWord* MetaspaceArena::allocate_inner(size_t requested_word_size) {
assert_lock_strong(lock());
! const size_t raw_word_size = get_raw_word_size_for_requested_word_size(requested_word_size, _alignment_words);
MetaWord* p = NULL;
bool current_chunk_too_small = false;
bool commit_failure = false;
if (current_chunk() != NULL) {
p2i(p), p2i(p + word_size));
UL2(trace, "deallocating " PTR_FORMAT ", word size: " SIZE_FORMAT ".",
p2i(p), word_size);
! size_t raw_word_size = get_raw_word_size_for_requested_word_size(word_size);
add_allocation_to_fbl(p, raw_word_size);
DEBUG_ONLY(verify_locked();)
}
p2i(p), p2i(p + word_size));
UL2(trace, "deallocating " PTR_FORMAT ", word size: " SIZE_FORMAT ".",
p2i(p), word_size);
! size_t raw_word_size = get_raw_word_size_for_requested_word_size(word_size, _alignment_words);
add_allocation_to_fbl(p, raw_word_size);
DEBUG_ONLY(verify_locked();)
}
assert_lock_strong(_lock);
st->print_cr("sm %s: %d chunks, total word size: " SIZE_FORMAT ", committed word size: " SIZE_FORMAT, _name,
_chunks.count(), _chunks.calc_word_size(), _chunks.calc_committed_word_size());
_chunks.print_on(st);
st->cr();
! st->print_cr("growth-policy " PTR_FORMAT ", lock " PTR_FORMAT ", cm " PTR_FORMAT ", fbl " PTR_FORMAT,
! p2i(_growth_policy), p2i(_lock), p2i(_chunk_manager), p2i(_fbl));
}
} // namespace metaspace
assert_lock_strong(_lock);
st->print_cr("sm %s: %d chunks, total word size: " SIZE_FORMAT ", committed word size: " SIZE_FORMAT, _name,
_chunks.count(), _chunks.calc_word_size(), _chunks.calc_committed_word_size());
_chunks.print_on(st);
st->cr();
! st->print_cr("growth-policy " PTR_FORMAT ", alignment %d, lock " PTR_FORMAT ", cm " PTR_FORMAT ", fbl " PTR_FORMAT,
! p2i(_growth_policy), _alignment_words * BytesPerWord, p2i(_lock), p2i(_chunk_manager), p2i(_fbl));
}
} // namespace metaspace
< prev index next >