6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
/*
|
2013-03-08 11:47:57 -05:00
|
|
|
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "gc_interface/collectedHeap.hpp"
|
2013-09-21 10:09:42 +02:00
|
|
|
#include "memory/allocation.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/binaryTreeDictionary.hpp"
|
2012-09-18 23:35:42 -07:00
|
|
|
#include "memory/freeList.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/collectorPolicy.hpp"
|
|
|
|
#include "memory/filemap.hpp"
|
|
|
|
#include "memory/freeList.hpp"
|
2013-10-07 15:51:08 +02:00
|
|
|
#include "memory/gcLocker.hpp"
|
2012-09-18 23:35:42 -07:00
|
|
|
#include "memory/metablock.hpp"
|
|
|
|
#include "memory/metachunk.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/metaspace.hpp"
|
|
|
|
#include "memory/metaspaceShared.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "memory/universe.hpp"
|
2013-10-07 15:51:08 +02:00
|
|
|
#include "runtime/atomic.inline.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "runtime/globals.hpp"
|
2013-10-07 15:51:08 +02:00
|
|
|
#include "runtime/init.hpp"
|
2013-08-15 20:04:10 -04:00
|
|
|
#include "runtime/java.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "runtime/mutex.hpp"
|
2012-11-28 17:50:21 -05:00
|
|
|
#include "runtime/orderAccess.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "services/memTracker.hpp"
|
2013-10-07 15:51:17 +02:00
|
|
|
#include "services/memoryService.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "utilities/copy.hpp"
|
|
|
|
#include "utilities/debug.hpp"
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
typedef BinaryTreeDictionary<Metablock, FreeList> BlockTreeDictionary;
|
|
|
|
typedef BinaryTreeDictionary<Metachunk, FreeList> ChunkTreeDictionary;
|
2012-11-09 00:38:31 +01:00
|
|
|
// Define this macro to enable slow integrity checking of
|
|
|
|
// the free chunk lists
|
|
|
|
const bool metaspace_slow_verify = false;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Parameters for stress mode testing
|
|
|
|
const uint metadata_deallocate_a_lot_block = 10;
|
|
|
|
const uint metadata_deallocate_a_lock_chunk = 3;
|
2013-09-11 09:37:14 +02:00
|
|
|
size_t const allocation_from_dictionary_limit = 4 * K;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
MetaWord* last_allocated = 0;
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
size_t Metaspace::_class_metaspace_size;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Used in declarations in SpaceManager and ChunkManager
|
|
|
|
enum ChunkIndex {
|
2012-12-03 15:09:39 -08:00
|
|
|
ZeroIndex = 0,
|
|
|
|
SpecializedIndex = ZeroIndex,
|
|
|
|
SmallIndex = SpecializedIndex + 1,
|
|
|
|
MediumIndex = SmallIndex + 1,
|
|
|
|
HumongousIndex = MediumIndex + 1,
|
|
|
|
NumberOfFreeLists = 3,
|
|
|
|
NumberOfInUseLists = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ChunkSizes { // in words.
|
|
|
|
ClassSpecializedChunk = 128,
|
|
|
|
SpecializedChunk = 128,
|
|
|
|
ClassSmallChunk = 256,
|
|
|
|
SmallChunk = 512,
|
2013-07-02 08:42:37 -04:00
|
|
|
ClassMediumChunk = 4 * K,
|
2012-12-03 15:09:39 -08:00
|
|
|
MediumChunk = 8 * K,
|
|
|
|
HumongousChunkGranularity = 8
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static ChunkIndex next_chunk_index(ChunkIndex i) {
|
2012-09-18 23:35:42 -07:00
|
|
|
assert(i < NumberOfInUseLists, "Out of bound");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return (ChunkIndex) (i+1);
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
volatile intptr_t MetaspaceGC::_capacity_until_GC = 0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
uint MetaspaceGC::_shrink_factor = 0;
|
|
|
|
bool MetaspaceGC::_should_concurrent_collect = false;
|
|
|
|
|
|
|
|
// Blocks of space for metadata are allocated out of Metachunks.
|
|
|
|
//
|
|
|
|
// Metachunk are allocated out of MetadataVirtualspaces and once
|
|
|
|
// allocated there is no explicit link between a Metachunk and
|
|
|
|
// the MetadataVirtualspaces from which it was allocated.
|
|
|
|
//
|
|
|
|
// Each SpaceManager maintains a
|
|
|
|
// list of the chunks it is using and the current chunk. The current
|
|
|
|
// chunk is the chunk from which allocations are done. Space freed in
|
|
|
|
// a chunk is placed on the free list of blocks (BlockFreelist) and
|
|
|
|
// reused from there.
|
|
|
|
|
2013-04-01 10:50:30 -07:00
|
|
|
typedef class FreeList<Metachunk> ChunkList;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Manages the global free lists of chunks.
|
|
|
|
// Has three lists of free chunks, and a total size and
|
|
|
|
// count that includes all three
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
class ChunkManager : public CHeapObj<mtInternal> {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Free list of chunks of different sizes.
|
2013-03-01 10:19:29 -08:00
|
|
|
// SpecializedChunk
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// SmallChunk
|
|
|
|
// MediumChunk
|
|
|
|
// HumongousChunk
|
2012-09-18 23:35:42 -07:00
|
|
|
ChunkList _free_chunks[NumberOfFreeLists];
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
// HumongousChunk
|
|
|
|
ChunkTreeDictionary _humongous_dictionary;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// ChunkManager in all lists of this type
|
|
|
|
size_t _free_chunks_total;
|
|
|
|
size_t _free_chunks_count;
|
|
|
|
|
|
|
|
void dec_free_chunks_total(size_t v) {
|
|
|
|
assert(_free_chunks_count > 0 &&
|
|
|
|
_free_chunks_total > 0,
|
|
|
|
"About to go negative");
|
|
|
|
Atomic::add_ptr(-1, &_free_chunks_count);
|
|
|
|
jlong minus_v = (jlong) - (jlong) v;
|
|
|
|
Atomic::add_ptr(minus_v, &_free_chunks_total);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debug support
|
|
|
|
|
|
|
|
size_t sum_free_chunks();
|
|
|
|
size_t sum_free_chunks_count();
|
|
|
|
|
|
|
|
void locked_verify_free_chunks_total();
|
2012-11-09 00:38:31 +01:00
|
|
|
void slow_locked_verify_free_chunks_total() {
|
|
|
|
if (metaspace_slow_verify) {
|
|
|
|
locked_verify_free_chunks_total();
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void locked_verify_free_chunks_count();
|
2012-11-09 00:38:31 +01:00
|
|
|
void slow_locked_verify_free_chunks_count() {
|
|
|
|
if (metaspace_slow_verify) {
|
|
|
|
locked_verify_free_chunks_count();
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void verify_free_chunks_count();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
ChunkManager(size_t specialized_size, size_t small_size, size_t medium_size)
|
|
|
|
: _free_chunks_total(0), _free_chunks_count(0) {
|
|
|
|
_free_chunks[SpecializedIndex].set_size(specialized_size);
|
|
|
|
_free_chunks[SmallIndex].set_size(small_size);
|
|
|
|
_free_chunks[MediumIndex].set_size(medium_size);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// add or delete (return) a chunk to the global freelist.
|
|
|
|
Metachunk* chunk_freelist_allocate(size_t word_size);
|
|
|
|
void chunk_freelist_deallocate(Metachunk* chunk);
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// Map a size to a list index assuming that there are lists
|
|
|
|
// for special, small, medium, and humongous chunks.
|
|
|
|
static ChunkIndex list_index(size_t size);
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
// Remove the chunk from its freelist. It is
|
|
|
|
// expected to be on one of the _free_chunks[] lists.
|
|
|
|
void remove_chunk(Metachunk* chunk);
|
|
|
|
|
2013-04-01 10:50:30 -07:00
|
|
|
// Add the simple linked list of chunks to the freelist of chunks
|
|
|
|
// of type index.
|
|
|
|
void return_chunks(ChunkIndex index, Metachunk* chunks);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Total of the space in the free chunks list
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t free_chunks_total_words();
|
|
|
|
size_t free_chunks_total_bytes();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Number of chunks in the free chunks list
|
|
|
|
size_t free_chunks_count();
|
|
|
|
|
|
|
|
void inc_free_chunks_total(size_t v, size_t count = 1) {
|
|
|
|
Atomic::add_ptr(count, &_free_chunks_count);
|
|
|
|
Atomic::add_ptr(v, &_free_chunks_total);
|
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
ChunkTreeDictionary* humongous_dictionary() {
|
|
|
|
return &_humongous_dictionary;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
ChunkList* free_chunks(ChunkIndex index);
|
|
|
|
|
|
|
|
// Returns the list for the given chunk word size.
|
|
|
|
ChunkList* find_free_chunks_list(size_t word_size);
|
|
|
|
|
|
|
|
// Add and remove from a list by size. Selects
|
|
|
|
// list based on size of chunk.
|
|
|
|
void free_chunks_put(Metachunk* chuck);
|
|
|
|
Metachunk* free_chunks_get(size_t chunk_word_size);
|
|
|
|
|
|
|
|
// Debug support
|
|
|
|
void verify();
|
2012-11-09 00:38:31 +01:00
|
|
|
void slow_verify() {
|
|
|
|
if (metaspace_slow_verify) {
|
|
|
|
verify();
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void locked_verify();
|
2012-11-09 00:38:31 +01:00
|
|
|
void slow_locked_verify() {
|
|
|
|
if (metaspace_slow_verify) {
|
|
|
|
locked_verify();
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void verify_free_chunks_total();
|
|
|
|
|
|
|
|
void locked_print_free_chunks(outputStream* st);
|
|
|
|
void locked_print_sum_free_chunks(outputStream* st);
|
2012-09-18 23:35:42 -07:00
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
void print_on(outputStream* st) const;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Used to manage the free list of Metablocks (a block corresponds
|
|
|
|
// to the allocation of a quantum of metadata).
|
|
|
|
class BlockFreelist VALUE_OBJ_CLASS_SPEC {
|
2012-09-18 23:35:42 -07:00
|
|
|
BlockTreeDictionary* _dictionary;
|
|
|
|
static Metablock* initialize_free_chunk(MetaWord* p, size_t word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-11 09:37:14 +02:00
|
|
|
// Only allocate and split from freelist if the size of the allocation
|
|
|
|
// is at least 1/4th the size of the available block.
|
|
|
|
const static int WasteMultiplier = 4;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Accessors
|
2012-09-18 23:35:42 -07:00
|
|
|
BlockTreeDictionary* dictionary() const { return _dictionary; }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
BlockFreelist();
|
|
|
|
~BlockFreelist();
|
|
|
|
|
|
|
|
// Get and return a block to the free list
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* get_block(size_t word_size);
|
|
|
|
void return_block(MetaWord* p, size_t word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
size_t total_size() {
|
|
|
|
if (dictionary() == NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return 0;
|
2012-09-18 23:35:42 -07:00
|
|
|
} else {
|
|
|
|
return dictionary()->total_size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
void print_on(outputStream* st) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VirtualSpaceNode : public CHeapObj<mtClass> {
|
|
|
|
friend class VirtualSpaceList;
|
|
|
|
|
|
|
|
// Link to next VirtualSpaceNode
|
|
|
|
VirtualSpaceNode* _next;
|
|
|
|
|
|
|
|
// total in the VirtualSpace
|
|
|
|
MemRegion _reserved;
|
|
|
|
ReservedSpace _rs;
|
|
|
|
VirtualSpace _virtual_space;
|
|
|
|
MetaWord* _top;
|
2013-03-01 10:19:29 -08:00
|
|
|
// count of chunks contained in this VirtualSpace
|
|
|
|
uintx _container_count;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Convenience functions to access the _virtual_space
|
|
|
|
char* low() const { return virtual_space()->low(); }
|
|
|
|
char* high() const { return virtual_space()->high(); }
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
// The first Metachunk will be allocated at the bottom of the
|
|
|
|
// VirtualSpace
|
|
|
|
Metachunk* first_chunk() { return (Metachunk*) bottom(); }
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
VirtualSpaceNode(size_t byte_size);
|
2013-03-01 10:19:29 -08:00
|
|
|
VirtualSpaceNode(ReservedSpace rs) : _top(NULL), _next(NULL), _rs(rs), _container_count(0) {}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
~VirtualSpaceNode();
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
// Convenience functions for logical bottom and end
|
|
|
|
MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); }
|
|
|
|
MetaWord* end() const { return (MetaWord*) _virtual_space.high(); }
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
size_t reserved_words() const { return _virtual_space.reserved_size() / BytesPerWord; }
|
|
|
|
size_t committed_words() const { return _virtual_space.actual_committed_size() / BytesPerWord; }
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool is_pre_committed() const { return _virtual_space.special(); }
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// address of next available space in _virtual_space;
|
|
|
|
// Accessors
|
|
|
|
VirtualSpaceNode* next() { return _next; }
|
|
|
|
void set_next(VirtualSpaceNode* v) { _next = v; }
|
|
|
|
|
|
|
|
void set_reserved(MemRegion const v) { _reserved = v; }
|
|
|
|
void set_top(MetaWord* v) { _top = v; }
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
MemRegion* reserved() { return &_reserved; }
|
|
|
|
VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; }
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
// Returns true if "word_size" is available in the VirtualSpace
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool is_available(size_t word_size) { return _top + word_size <= end(); }
|
|
|
|
|
|
|
|
MetaWord* top() const { return _top; }
|
|
|
|
void inc_top(size_t word_size) { _top += word_size; }
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
uintx container_count() { return _container_count; }
|
2013-09-21 10:09:42 +02:00
|
|
|
void inc_container_count();
|
2013-03-01 10:19:29 -08:00
|
|
|
void dec_container_count();
|
|
|
|
#ifdef ASSERT
|
2013-09-21 10:09:42 +02:00
|
|
|
uint container_count_slow();
|
2013-03-01 10:19:29 -08:00
|
|
|
void verify_container_count();
|
|
|
|
#endif
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// used and capacity in this single entry in the list
|
|
|
|
size_t used_words_in_vs() const;
|
|
|
|
size_t capacity_words_in_vs() const;
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t free_words_in_vs() const;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
bool initialize();
|
|
|
|
|
|
|
|
// get space from the virtual space
|
|
|
|
Metachunk* take_from_committed(size_t chunk_word_size);
|
|
|
|
|
|
|
|
// Allocate a chunk from the virtual space and return it.
|
|
|
|
Metachunk* get_chunk_vs(size_t chunk_word_size);
|
|
|
|
|
|
|
|
// Expands/shrinks the committed space in a virtual space. Delegates
|
|
|
|
// to Virtualspace
|
2013-10-07 15:51:08 +02:00
|
|
|
bool expand_by(size_t min_words, size_t preferred_words);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
// In preparation for deleting this node, remove all the chunks
|
|
|
|
// in the node from any freelist.
|
|
|
|
void purge(ChunkManager* chunk_manager);
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
#ifdef ASSERT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Debug support
|
|
|
|
void mangle();
|
2012-11-29 16:50:29 -05:00
|
|
|
#endif
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
void print_on(outputStream* st) const;
|
|
|
|
};
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
#define assert_is_ptr_aligned(ptr, alignment) \
|
|
|
|
assert(is_ptr_aligned(ptr, alignment), \
|
|
|
|
err_msg(PTR_FORMAT " is not aligned to " \
|
|
|
|
SIZE_FORMAT, ptr, alignment))
|
|
|
|
|
|
|
|
#define assert_is_size_aligned(size, alignment) \
|
|
|
|
assert(is_size_aligned(size, alignment), \
|
|
|
|
err_msg(SIZE_FORMAT " is not aligned to " \
|
|
|
|
SIZE_FORMAT, size, alignment))
|
|
|
|
|
|
|
|
|
|
|
|
// Decide if large pages should be committed when the memory is reserved.
|
|
|
|
static bool should_commit_large_pages_when_reserving(size_t bytes) {
|
|
|
|
if (UseLargePages && UseLargePagesInMetaspace && !os::can_commit_large_page_memory()) {
|
|
|
|
size_t words = bytes / BytesPerWord;
|
|
|
|
bool is_class = false; // We never reserve large pages for the class space.
|
|
|
|
if (MetaspaceGC::can_expand(words, is_class) &&
|
|
|
|
MetaspaceGC::allowed_expansion() >= words) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// byte_size is the size of the associated virtualspace.
|
2013-10-07 15:51:08 +02:00
|
|
|
VirtualSpaceNode::VirtualSpaceNode(size_t bytes) : _top(NULL), _next(NULL), _rs(), _container_count(0) {
|
|
|
|
assert_is_size_aligned(bytes, Metaspace::reserve_alignment());
|
2013-03-15 11:53:28 -04:00
|
|
|
|
2013-03-20 08:04:54 -04:00
|
|
|
// This allocates memory with mmap. For DumpSharedspaces, try to reserve
|
|
|
|
// configurable address, generally at the top of the Java heap so other
|
|
|
|
// memory addresses don't conflict.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (DumpSharedSpaces) {
|
2013-10-07 15:51:08 +02:00
|
|
|
bool large_pages = false; // No large pages when dumping the CDS archive.
|
|
|
|
char* shared_base = (char*)align_ptr_up((char*)SharedBaseAddress, Metaspace::reserve_alignment());
|
|
|
|
|
|
|
|
_rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages, shared_base, 0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (_rs.is_reserved()) {
|
2013-03-20 08:04:54 -04:00
|
|
|
assert(shared_base == 0 || _rs.base() == shared_base, "should match");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2013-03-20 08:04:54 -04:00
|
|
|
// Get a mmap region anywhere if the SharedBaseAddress fails.
|
2013-10-07 15:51:08 +02:00
|
|
|
_rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
MetaspaceShared::set_shared_rs(&_rs);
|
|
|
|
} else {
|
2013-10-07 15:51:08 +02:00
|
|
|
bool large_pages = should_commit_large_pages_when_reserving(bytes);
|
|
|
|
|
|
|
|
_rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
if (_rs.is_reserved()) {
|
|
|
|
assert(_rs.base() != NULL, "Catch if we get a NULL address");
|
|
|
|
assert(_rs.size() != 0, "Catch if we get a 0 size");
|
|
|
|
assert_is_ptr_aligned(_rs.base(), Metaspace::reserve_alignment());
|
|
|
|
assert_is_size_aligned(_rs.size(), Metaspace::reserve_alignment());
|
|
|
|
|
|
|
|
MemTracker::record_virtual_memory_type((address)_rs.base(), mtClass);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
void VirtualSpaceNode::purge(ChunkManager* chunk_manager) {
|
|
|
|
Metachunk* chunk = first_chunk();
|
|
|
|
Metachunk* invalid_chunk = (Metachunk*) top();
|
|
|
|
while (chunk < invalid_chunk ) {
|
|
|
|
assert(chunk->is_free(), "Should be marked free");
|
|
|
|
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
|
|
|
|
chunk_manager->remove_chunk(chunk);
|
|
|
|
assert(chunk->next() == NULL &&
|
|
|
|
chunk->prev() == NULL,
|
|
|
|
"Was not removed from its list");
|
|
|
|
chunk = (Metachunk*) next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
uint VirtualSpaceNode::container_count_slow() {
|
|
|
|
uint count = 0;
|
|
|
|
Metachunk* chunk = first_chunk();
|
|
|
|
Metachunk* invalid_chunk = (Metachunk*) top();
|
|
|
|
while (chunk < invalid_chunk ) {
|
|
|
|
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
|
|
|
|
// Don't count the chunks on the free lists. Those are
|
|
|
|
// still part of the VirtualSpaceNode but not currently
|
|
|
|
// counted.
|
|
|
|
if (!chunk->is_free()) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
chunk = (Metachunk*) next;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// List of VirtualSpaces for metadata allocation.
|
|
|
|
class VirtualSpaceList : public CHeapObj<mtClass> {
|
|
|
|
friend class VirtualSpaceNode;
|
|
|
|
|
|
|
|
enum VirtualSpaceSizes {
|
|
|
|
VirtualSpaceSize = 256 * K
|
|
|
|
};
|
|
|
|
|
|
|
|
// Head of the list
|
|
|
|
VirtualSpaceNode* _virtual_space_list;
|
|
|
|
// virtual space currently being used for allocations
|
|
|
|
VirtualSpaceNode* _current_virtual_space;
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// Is this VirtualSpaceList used for the compressed class space
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool _is_class;
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
// Sum of reserved and committed memory in the virtual spaces
|
|
|
|
size_t _reserved_words;
|
|
|
|
size_t _committed_words;
|
|
|
|
|
|
|
|
// Number of virtual spaces
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
size_t _virtual_space_count;
|
|
|
|
|
|
|
|
~VirtualSpaceList();
|
|
|
|
|
|
|
|
VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; }
|
|
|
|
|
|
|
|
void set_virtual_space_list(VirtualSpaceNode* v) {
|
|
|
|
_virtual_space_list = v;
|
|
|
|
}
|
|
|
|
void set_current_virtual_space(VirtualSpaceNode* v) {
|
|
|
|
_current_virtual_space = v;
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
void link_vs(VirtualSpaceNode* new_entry);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Get another virtual space and add it to the list. This
|
|
|
|
// is typically prompted by a failed attempt to allocate a chunk
|
|
|
|
// and is typically followed by the allocation of a chunk.
|
2013-10-07 15:51:08 +02:00
|
|
|
bool create_new_virtual_space(size_t vs_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
VirtualSpaceList(size_t word_size);
|
|
|
|
VirtualSpaceList(ReservedSpace rs);
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t free_bytes();
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
Metachunk* get_new_chunk(size_t word_size,
|
|
|
|
size_t grow_chunks_by_words,
|
|
|
|
size_t medium_chunk_bunch);
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool expand_node_by(VirtualSpaceNode* node,
|
|
|
|
size_t min_words,
|
|
|
|
size_t preferred_words);
|
2013-09-12 10:15:54 +02:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool expand_by(size_t min_words,
|
|
|
|
size_t preferred_words);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
VirtualSpaceNode* current_virtual_space() {
|
|
|
|
return _current_virtual_space;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_class() const { return _is_class; }
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool initialization_succeeded() { return _virtual_space_list != NULL; }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
size_t reserved_words() { return _reserved_words; }
|
|
|
|
size_t reserved_bytes() { return reserved_words() * BytesPerWord; }
|
|
|
|
size_t committed_words() { return _committed_words; }
|
|
|
|
size_t committed_bytes() { return committed_words() * BytesPerWord; }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
void inc_reserved_words(size_t v);
|
|
|
|
void dec_reserved_words(size_t v);
|
|
|
|
void inc_committed_words(size_t v);
|
|
|
|
void dec_committed_words(size_t v);
|
2013-03-01 10:19:29 -08:00
|
|
|
void inc_virtual_space_count();
|
|
|
|
void dec_virtual_space_count();
|
|
|
|
|
|
|
|
// Unlink empty VirtualSpaceNodes and free it.
|
2013-09-21 10:09:42 +02:00
|
|
|
void purge(ChunkManager* chunk_manager);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
bool contains(const void *ptr);
|
|
|
|
|
|
|
|
void print_on(outputStream* st) const;
|
|
|
|
|
|
|
|
class VirtualSpaceListIterator : public StackObj {
|
|
|
|
VirtualSpaceNode* _virtual_spaces;
|
|
|
|
public:
|
|
|
|
VirtualSpaceListIterator(VirtualSpaceNode* virtual_spaces) :
|
|
|
|
_virtual_spaces(virtual_spaces) {}
|
|
|
|
|
|
|
|
bool repeat() {
|
|
|
|
return _virtual_spaces != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
VirtualSpaceNode* get_next() {
|
|
|
|
VirtualSpaceNode* result = _virtual_spaces;
|
|
|
|
if (_virtual_spaces != NULL) {
|
|
|
|
_virtual_spaces = _virtual_spaces->next();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class Metadebug : AllStatic {
|
|
|
|
// Debugging support for Metaspaces
|
|
|
|
static int _deallocate_block_a_lot_count;
|
|
|
|
static int _deallocate_chunk_a_lot_count;
|
|
|
|
static int _allocation_fail_alot_count;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static int deallocate_block_a_lot_count() {
|
|
|
|
return _deallocate_block_a_lot_count;
|
|
|
|
}
|
|
|
|
static void set_deallocate_block_a_lot_count(int v) {
|
|
|
|
_deallocate_block_a_lot_count = v;
|
|
|
|
}
|
|
|
|
static void inc_deallocate_block_a_lot_count() {
|
|
|
|
_deallocate_block_a_lot_count++;
|
|
|
|
}
|
|
|
|
static int deallocate_chunk_a_lot_count() {
|
|
|
|
return _deallocate_chunk_a_lot_count;
|
|
|
|
}
|
|
|
|
static void reset_deallocate_chunk_a_lot_count() {
|
|
|
|
_deallocate_chunk_a_lot_count = 1;
|
|
|
|
}
|
|
|
|
static void inc_deallocate_chunk_a_lot_count() {
|
|
|
|
_deallocate_chunk_a_lot_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_allocation_fail_alot_count();
|
|
|
|
#ifdef ASSERT
|
|
|
|
static bool test_metadata_failure();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void deallocate_chunk_a_lot(SpaceManager* sm,
|
|
|
|
size_t chunk_word_size);
|
|
|
|
static void deallocate_block_a_lot(SpaceManager* sm,
|
|
|
|
size_t chunk_word_size);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
int Metadebug::_deallocate_block_a_lot_count = 0;
|
|
|
|
int Metadebug::_deallocate_chunk_a_lot_count = 0;
|
|
|
|
int Metadebug::_allocation_fail_alot_count = 0;
|
|
|
|
|
|
|
|
// SpaceManager - used by Metaspace to handle allocations
|
|
|
|
class SpaceManager : public CHeapObj<mtClass> {
|
|
|
|
friend class Metaspace;
|
|
|
|
friend class Metadebug;
|
|
|
|
|
|
|
|
private:
|
2012-12-03 15:09:39 -08:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// protects allocations and contains.
|
|
|
|
Mutex* const _lock;
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
// Type of metadata allocated.
|
|
|
|
Metaspace::MetadataType _mdtype;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// List of chunks in use by this SpaceManager. Allocations
|
|
|
|
// are done from the current chunk. The list is used for deallocating
|
|
|
|
// chunks when the SpaceManager is freed.
|
2012-09-18 23:35:42 -07:00
|
|
|
Metachunk* _chunks_in_use[NumberOfInUseLists];
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metachunk* _current_chunk;
|
|
|
|
|
|
|
|
// Number of small chunks to allocate to a manager
|
|
|
|
// If class space manager, small chunks are unlimited
|
|
|
|
static uint const _small_chunk_limit;
|
|
|
|
|
|
|
|
// Sum of all space in allocated chunks
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t _allocated_blocks_words;
|
|
|
|
|
|
|
|
// Sum of all allocated chunks
|
|
|
|
size_t _allocated_chunks_words;
|
|
|
|
size_t _allocated_chunks_count;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Free lists of blocks are per SpaceManager since they
|
|
|
|
// are assumed to be in chunks in use by the SpaceManager
|
|
|
|
// and all chunks in use by a SpaceManager are freed when
|
|
|
|
// the class loader using the SpaceManager is collected.
|
|
|
|
BlockFreelist _block_freelists;
|
|
|
|
|
|
|
|
// protects virtualspace and chunk expansions
|
|
|
|
static const char* _expand_lock_name;
|
|
|
|
static const int _expand_lock_rank;
|
|
|
|
static Mutex* const _expand_lock;
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
private:
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Accessors
|
|
|
|
Metachunk* chunks_in_use(ChunkIndex index) const { return _chunks_in_use[index]; }
|
|
|
|
void set_chunks_in_use(ChunkIndex index, Metachunk* v) { _chunks_in_use[index] = v; }
|
|
|
|
|
|
|
|
BlockFreelist* block_freelists() const {
|
|
|
|
return (BlockFreelist*) &_block_freelists;
|
|
|
|
}
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
Metaspace::MetadataType mdtype() { return _mdtype; }
|
2013-09-21 10:09:42 +02:00
|
|
|
|
|
|
|
VirtualSpaceList* vs_list() const { return Metaspace::get_space_list(_mdtype); }
|
|
|
|
ChunkManager* chunk_manager() const { return Metaspace::get_chunk_manager(_mdtype); }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
Metachunk* current_chunk() const { return _current_chunk; }
|
|
|
|
void set_current_chunk(Metachunk* v) {
|
|
|
|
_current_chunk = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
Metachunk* find_current_chunk(size_t word_size);
|
|
|
|
|
|
|
|
// Add chunk to the list of chunks in use
|
|
|
|
void add_chunk(Metachunk* v, bool make_current);
|
2013-09-11 09:37:14 +02:00
|
|
|
void retire_current_chunk();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
Mutex* lock() const { return _lock; }
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
const char* chunk_size_name(ChunkIndex index) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void initialize();
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
public:
|
2013-05-20 22:34:24 -07:00
|
|
|
SpaceManager(Metaspace::MetadataType mdtype,
|
2013-09-21 10:09:42 +02:00
|
|
|
Mutex* lock);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
~SpaceManager();
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
enum ChunkMultiples {
|
|
|
|
MediumChunkMultiple = 4
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
};
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
bool is_class() { return _mdtype == Metaspace::ClassType; }
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Accessors
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t specialized_chunk_size() { return SpecializedChunk; }
|
2013-09-21 10:09:42 +02:00
|
|
|
size_t small_chunk_size() { return (size_t) is_class() ? ClassSmallChunk : SmallChunk; }
|
|
|
|
size_t medium_chunk_size() { return (size_t) is_class() ? ClassMediumChunk : MediumChunk; }
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t medium_chunk_bunch() { return medium_chunk_size() * MediumChunkMultiple; }
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t allocated_blocks_words() const { return _allocated_blocks_words; }
|
|
|
|
size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; }
|
|
|
|
size_t allocated_chunks_words() const { return _allocated_chunks_words; }
|
|
|
|
size_t allocated_chunks_count() const { return _allocated_chunks_count; }
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
bool is_humongous(size_t word_size) { return word_size > medium_chunk_size(); }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
static Mutex* expand_lock() { return _expand_lock; }
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
// Increment the per Metaspace and global running sums for Metachunks
|
|
|
|
// by the given size. This is used when a Metachunk to added to
|
|
|
|
// the in-use list.
|
|
|
|
void inc_size_metrics(size_t words);
|
|
|
|
// Increment the per Metaspace and global running sums Metablocks by the given
|
|
|
|
// size. This is used when a Metablock is allocated.
|
|
|
|
void inc_used_metrics(size_t words);
|
|
|
|
// Delete the portion of the running sums for this SpaceManager. That is,
|
|
|
|
// the globals running sums for the Metachunks and Metablocks are
|
|
|
|
// decremented for all the Metachunks in-use by this SpaceManager.
|
|
|
|
void dec_total_from_size_metrics();
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// Set the sizes for the initial chunks.
|
|
|
|
void get_initial_chunk_sizes(Metaspace::MetaspaceType type,
|
|
|
|
size_t* chunk_word_size,
|
|
|
|
size_t* class_chunk_word_size);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
size_t sum_capacity_in_chunks_in_use() const;
|
|
|
|
size_t sum_used_in_chunks_in_use() const;
|
|
|
|
size_t sum_free_in_chunks_in_use() const;
|
|
|
|
size_t sum_waste_in_chunks_in_use() const;
|
|
|
|
size_t sum_waste_in_chunks_in_use(ChunkIndex index ) const;
|
|
|
|
|
|
|
|
size_t sum_count_in_chunks_in_use();
|
|
|
|
size_t sum_count_in_chunks_in_use(ChunkIndex i);
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
Metachunk* get_new_chunk(size_t word_size, size_t grow_chunks_by_words);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Block allocation and deallocation.
|
|
|
|
// Allocates a block from the current chunk
|
|
|
|
MetaWord* allocate(size_t word_size);
|
|
|
|
|
|
|
|
// Helper for allocations
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* allocate_work(size_t word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Returns a block to the per manager freelist
|
2012-09-18 23:35:42 -07:00
|
|
|
void deallocate(MetaWord* p, size_t word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Based on the allocation size and a minimum chunk size,
|
|
|
|
// returned chunk size (for expanding space for chunk allocation).
|
|
|
|
size_t calc_chunk_size(size_t allocation_word_size);
|
|
|
|
|
|
|
|
// Called when an allocation from the current chunk fails.
|
|
|
|
// Gets a new chunk (may require getting a new virtual space),
|
|
|
|
// and allocates from that chunk.
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* grow_and_allocate(size_t word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-07 15:51:17 +02:00
|
|
|
// Notify memory usage to MemoryService.
|
|
|
|
void track_metaspace_memory_usage();
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// debugging support.
|
|
|
|
|
|
|
|
void dump(outputStream* const out) const;
|
|
|
|
void print_on(outputStream* st) const;
|
|
|
|
void locked_print_chunks_in_use_on(outputStream* st) const;
|
|
|
|
|
|
|
|
void verify();
|
2012-11-29 10:09:04 -08:00
|
|
|
void verify_chunk_size(Metachunk* chunk);
|
2012-11-29 16:50:29 -05:00
|
|
|
NOT_PRODUCT(void mangle_freed_chunks();)
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#ifdef ASSERT
|
2013-02-12 14:15:45 -08:00
|
|
|
void verify_allocated_blocks_words();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#endif
|
2013-05-28 16:36:19 -07:00
|
|
|
|
|
|
|
size_t get_raw_word_size(size_t word_size) {
|
|
|
|
// If only the dictionary is going to be used (i.e., no
|
|
|
|
// indexed free list), then there is a minimum size requirement.
|
|
|
|
// MinChunkSize is a placeholder for the real minimum size JJJ
|
|
|
|
size_t byte_size = word_size * BytesPerWord;
|
|
|
|
|
2013-09-13 22:21:06 +02:00
|
|
|
size_t raw_bytes_size = MAX2(byte_size,
|
2013-05-28 16:36:19 -07:00
|
|
|
Metablock::min_block_byte_size());
|
|
|
|
raw_bytes_size = ARENA_ALIGN(raw_bytes_size);
|
|
|
|
size_t raw_word_size = raw_bytes_size / BytesPerWord;
|
|
|
|
assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem");
|
|
|
|
|
|
|
|
return raw_word_size;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
uint const SpaceManager::_small_chunk_limit = 4;
|
|
|
|
|
|
|
|
const char* SpaceManager::_expand_lock_name =
|
|
|
|
"SpaceManager chunk allocation lock";
|
|
|
|
const int SpaceManager::_expand_lock_rank = Monitor::leaf - 1;
|
|
|
|
Mutex* const SpaceManager::_expand_lock =
|
|
|
|
new Mutex(SpaceManager::_expand_lock_rank,
|
|
|
|
SpaceManager::_expand_lock_name,
|
|
|
|
Mutex::_allow_vm_block_flag);
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
void VirtualSpaceNode::inc_container_count() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
_container_count++;
|
|
|
|
assert(_container_count == container_count_slow(),
|
|
|
|
err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT
|
2013-09-21 10:09:42 +02:00
|
|
|
" container_count_slow() " SIZE_FORMAT,
|
2013-03-01 10:19:29 -08:00
|
|
|
_container_count, container_count_slow()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualSpaceNode::dec_container_count() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
_container_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
void VirtualSpaceNode::verify_container_count() {
|
|
|
|
assert(_container_count == container_count_slow(),
|
|
|
|
err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT
|
2013-09-21 10:09:42 +02:00
|
|
|
" container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow()));
|
2013-03-01 10:19:29 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// BlockFreelist methods
|
|
|
|
|
|
|
|
BlockFreelist::BlockFreelist() : _dictionary(NULL) {}
|
|
|
|
|
|
|
|
BlockFreelist::~BlockFreelist() {
|
|
|
|
if (_dictionary != NULL) {
|
|
|
|
if (Verbose && TraceMetadataChunkAllocation) {
|
|
|
|
_dictionary->print_free_lists(gclog_or_tty);
|
|
|
|
}
|
|
|
|
delete _dictionary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
Metablock* BlockFreelist::initialize_free_chunk(MetaWord* p, size_t word_size) {
|
|
|
|
Metablock* block = (Metablock*) p;
|
|
|
|
block->set_word_size(word_size);
|
|
|
|
block->set_prev(NULL);
|
|
|
|
block->set_next(NULL);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
|
|
|
|
Metablock* free_chunk = initialize_free_chunk(p, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (dictionary() == NULL) {
|
2012-09-18 23:35:42 -07:00
|
|
|
_dictionary = new BlockTreeDictionary();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
dictionary()->return_chunk(free_chunk);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* BlockFreelist::get_block(size_t word_size) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (dictionary() == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
|
|
|
|
// Dark matter. Too small for dictionary.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
Metablock* free_block =
|
2013-09-11 09:37:14 +02:00
|
|
|
dictionary()->get_chunk(word_size, FreeBlockDictionary<Metablock>::atLeast);
|
2012-09-18 23:35:42 -07:00
|
|
|
if (free_block == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-09-11 09:37:14 +02:00
|
|
|
const size_t block_size = free_block->size();
|
|
|
|
if (block_size > WasteMultiplier * word_size) {
|
|
|
|
return_block((MetaWord*)free_block, block_size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaWord* new_block = (MetaWord*)free_block;
|
|
|
|
assert(block_size >= word_size, "Incorrect size of block from freelist");
|
|
|
|
const size_t unused = block_size - word_size;
|
|
|
|
if (unused >= TreeChunk<Metablock, FreeList>::min_size()) {
|
|
|
|
return_block(new_block + word_size, unused);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_block;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlockFreelist::print_on(outputStream* st) const {
|
|
|
|
if (dictionary() == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dictionary()->print_free_lists(st);
|
|
|
|
}
|
|
|
|
|
|
|
|
// VirtualSpaceNode methods
|
|
|
|
|
|
|
|
VirtualSpaceNode::~VirtualSpaceNode() {
|
|
|
|
_rs.release();
|
2013-03-01 10:19:29 -08:00
|
|
|
#ifdef ASSERT
|
|
|
|
size_t word_size = sizeof(*this) / BytesPerWord;
|
|
|
|
Copy::fill_to_words((HeapWord*) this, word_size, 0xf1f1f1f1);
|
|
|
|
#endif
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t VirtualSpaceNode::used_words_in_vs() const {
|
|
|
|
return pointer_delta(top(), bottom(), sizeof(MetaWord));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Space committed in the VirtualSpace
|
|
|
|
size_t VirtualSpaceNode::capacity_words_in_vs() const {
|
|
|
|
return pointer_delta(end(), bottom(), sizeof(MetaWord));
|
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t VirtualSpaceNode::free_words_in_vs() const {
|
|
|
|
return pointer_delta(end(), top(), sizeof(MetaWord));
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Allocates the chunk from the virtual space only.
|
|
|
|
// This interface is also used internally for debugging. Not all
|
|
|
|
// chunks removed here are necessarily used for allocation.
|
|
|
|
Metachunk* VirtualSpaceNode::take_from_committed(size_t chunk_word_size) {
|
|
|
|
// Bottom of the new chunk
|
|
|
|
MetaWord* chunk_limit = top();
|
|
|
|
assert(chunk_limit != NULL, "Not safe to call this method");
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// The virtual spaces are always expanded by the
|
|
|
|
// commit granularity to enforce the following condition.
|
|
|
|
// Without this the is_available check will not work correctly.
|
|
|
|
assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(),
|
|
|
|
"The committed memory doesn't match the expanded memory.");
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (!is_available(chunk_word_size)) {
|
|
|
|
if (TraceMetadataChunkAllocation) {
|
2013-09-13 22:25:27 +02:00
|
|
|
gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available %d words ", chunk_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Dump some information about the virtual space that is nearly full
|
2013-09-13 22:25:27 +02:00
|
|
|
print_on(gclog_or_tty);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Take the space (bump top on the current virtual space).
|
|
|
|
inc_top(chunk_word_size);
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
// Initialize the chunk
|
|
|
|
Metachunk* result = ::new (chunk_limit) Metachunk(chunk_word_size, this);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Expand the virtual space (commit more of the reserved space)
|
2013-10-07 15:51:08 +02:00
|
|
|
bool VirtualSpaceNode::expand_by(size_t min_words, size_t preferred_words) {
|
|
|
|
size_t min_bytes = min_words * BytesPerWord;
|
|
|
|
size_t preferred_bytes = preferred_words * BytesPerWord;
|
|
|
|
|
|
|
|
size_t uncommitted = virtual_space()->reserved_size() - virtual_space()->actual_committed_size();
|
|
|
|
|
|
|
|
if (uncommitted < min_bytes) {
|
|
|
|
return false;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
size_t commit = MIN2(preferred_bytes, uncommitted);
|
|
|
|
bool result = virtual_space()->expand_by(commit, false);
|
|
|
|
|
|
|
|
assert(result, "Failed to commit memory");
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Metachunk* VirtualSpaceNode::get_chunk_vs(size_t chunk_word_size) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2013-03-01 10:19:29 -08:00
|
|
|
Metachunk* result = take_from_committed(chunk_word_size);
|
|
|
|
if (result != NULL) {
|
|
|
|
inc_container_count();
|
|
|
|
}
|
|
|
|
return result;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VirtualSpaceNode::initialize() {
|
|
|
|
|
|
|
|
if (!_rs.is_reserved()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// These are necessary restriction to make sure that the virtual space always
|
|
|
|
// grows in steps of Metaspace::commit_alignment(). If both base and size are
|
|
|
|
// aligned only the middle alignment of the VirtualSpace is used.
|
|
|
|
assert_is_ptr_aligned(_rs.base(), Metaspace::commit_alignment());
|
|
|
|
assert_is_size_aligned(_rs.size(), Metaspace::commit_alignment());
|
|
|
|
|
|
|
|
// ReservedSpaces marked as special will have the entire memory
|
|
|
|
// pre-committed. Setting a committed size will make sure that
|
|
|
|
// committed_size and actual_committed_size agrees.
|
|
|
|
size_t pre_committed_size = _rs.special() ? _rs.size() : 0;
|
|
|
|
|
|
|
|
bool result = virtual_space()->initialize_with_granularity(_rs, pre_committed_size,
|
|
|
|
Metaspace::commit_alignment());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (result) {
|
2013-10-07 15:51:08 +02:00
|
|
|
assert(virtual_space()->committed_size() == virtual_space()->actual_committed_size(),
|
|
|
|
"Checking that the pre-committed memory was registered by the VirtualSpace");
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_top((MetaWord*)virtual_space()->low());
|
|
|
|
set_reserved(MemRegion((HeapWord*)_rs.base(),
|
|
|
|
(HeapWord*)(_rs.base() + _rs.size())));
|
|
|
|
|
2012-09-03 18:37:12 -04:00
|
|
|
assert(reserved()->start() == (HeapWord*) _rs.base(),
|
|
|
|
err_msg("Reserved start was not set properly " PTR_FORMAT
|
|
|
|
" != " PTR_FORMAT, reserved()->start(), _rs.base()));
|
|
|
|
assert(reserved()->word_size() == _rs.size() / BytesPerWord,
|
|
|
|
err_msg("Reserved size was not set properly " SIZE_FORMAT
|
|
|
|
" != " SIZE_FORMAT, reserved()->word_size(),
|
|
|
|
_rs.size() / BytesPerWord));
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualSpaceNode::print_on(outputStream* st) const {
|
|
|
|
size_t used = used_words_in_vs();
|
|
|
|
size_t capacity = capacity_words_in_vs();
|
|
|
|
VirtualSpace* vs = virtual_space();
|
|
|
|
st->print_cr(" space @ " PTR_FORMAT " " SIZE_FORMAT "K, %3d%% used "
|
|
|
|
"[" PTR_FORMAT ", " PTR_FORMAT ", "
|
|
|
|
PTR_FORMAT ", " PTR_FORMAT ")",
|
2012-12-03 15:09:39 -08:00
|
|
|
vs, capacity / K,
|
|
|
|
capacity == 0 ? 0 : used * 100 / capacity,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bottom(), top(), end(),
|
|
|
|
vs->high_boundary());
|
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
#ifdef ASSERT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void VirtualSpaceNode::mangle() {
|
|
|
|
size_t word_size = capacity_words_in_vs();
|
|
|
|
Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1);
|
|
|
|
}
|
2012-11-29 16:50:29 -05:00
|
|
|
#endif // ASSERT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// VirtualSpaceList methods
|
|
|
|
// Space allocated from the VirtualSpace
|
|
|
|
|
|
|
|
VirtualSpaceList::~VirtualSpaceList() {
|
|
|
|
VirtualSpaceListIterator iter(virtual_space_list());
|
|
|
|
while (iter.repeat()) {
|
|
|
|
VirtualSpaceNode* vsl = iter.get_next();
|
|
|
|
delete vsl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
void VirtualSpaceList::inc_reserved_words(size_t v) {
|
2013-03-01 10:19:29 -08:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2013-09-12 10:15:54 +02:00
|
|
|
_reserved_words = _reserved_words + v;
|
2013-03-01 10:19:29 -08:00
|
|
|
}
|
2013-09-12 10:15:54 +02:00
|
|
|
void VirtualSpaceList::dec_reserved_words(size_t v) {
|
2013-03-01 10:19:29 -08:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2013-09-12 10:15:54 +02:00
|
|
|
_reserved_words = _reserved_words - v;
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
#define assert_committed_below_limit() \
|
|
|
|
assert(MetaspaceAux::committed_bytes() <= MaxMetaspaceSize, \
|
|
|
|
err_msg("Too much committed memory. Committed: " SIZE_FORMAT \
|
|
|
|
" limit (MaxMetaspaceSize): " SIZE_FORMAT, \
|
|
|
|
MetaspaceAux::committed_bytes(), MaxMetaspaceSize));
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
void VirtualSpaceList::inc_committed_words(size_t v) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
_committed_words = _committed_words + v;
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
assert_committed_below_limit();
|
2013-09-12 10:15:54 +02:00
|
|
|
}
|
|
|
|
void VirtualSpaceList::dec_committed_words(size_t v) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
_committed_words = _committed_words - v;
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
assert_committed_below_limit();
|
2013-03-01 10:19:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualSpaceList::inc_virtual_space_count() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
_virtual_space_count++;
|
|
|
|
}
|
|
|
|
void VirtualSpaceList::dec_virtual_space_count() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
_virtual_space_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::remove_chunk(Metachunk* chunk) {
|
|
|
|
size_t word_size = chunk->word_size();
|
|
|
|
ChunkIndex index = list_index(word_size);
|
|
|
|
if (index != HumongousIndex) {
|
|
|
|
free_chunks(index)->remove_chunk(chunk);
|
|
|
|
} else {
|
|
|
|
humongous_dictionary()->remove_chunk(chunk);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chunk is being removed from the chunks free list.
|
|
|
|
dec_free_chunks_total(chunk->capacity_word_size());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Walk the list of VirtualSpaceNodes and delete
|
|
|
|
// nodes with a 0 container_count. Remove Metachunks in
|
|
|
|
// the node from their respective freelists.
|
2013-09-21 10:09:42 +02:00
|
|
|
void VirtualSpaceList::purge(ChunkManager* chunk_manager) {
|
2013-03-01 10:19:29 -08:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
// Don't use a VirtualSpaceListIterator because this
|
|
|
|
// list is being changed and a straightforward use of an iterator is not safe.
|
|
|
|
VirtualSpaceNode* purged_vsl = NULL;
|
|
|
|
VirtualSpaceNode* prev_vsl = virtual_space_list();
|
|
|
|
VirtualSpaceNode* next_vsl = prev_vsl;
|
|
|
|
while (next_vsl != NULL) {
|
|
|
|
VirtualSpaceNode* vsl = next_vsl;
|
|
|
|
next_vsl = vsl->next();
|
|
|
|
// Don't free the current virtual space since it will likely
|
|
|
|
// be needed soon.
|
|
|
|
if (vsl->container_count() == 0 && vsl != current_virtual_space()) {
|
|
|
|
// Unlink it from the list
|
|
|
|
if (prev_vsl == vsl) {
|
2013-10-07 15:51:08 +02:00
|
|
|
// This is the case of the current node being the first node.
|
|
|
|
assert(vsl == virtual_space_list(), "Expected to be the first node");
|
2013-03-01 10:19:29 -08:00
|
|
|
set_virtual_space_list(vsl->next());
|
|
|
|
} else {
|
|
|
|
prev_vsl->set_next(vsl->next());
|
|
|
|
}
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
vsl->purge(chunk_manager);
|
2013-09-12 10:15:54 +02:00
|
|
|
dec_reserved_words(vsl->reserved_words());
|
|
|
|
dec_committed_words(vsl->committed_words());
|
2013-03-01 10:19:29 -08:00
|
|
|
dec_virtual_space_count();
|
|
|
|
purged_vsl = vsl;
|
|
|
|
delete vsl;
|
|
|
|
} else {
|
|
|
|
prev_vsl = vsl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (purged_vsl != NULL) {
|
|
|
|
// List should be stable enough to use an iterator here.
|
|
|
|
VirtualSpaceListIterator iter(virtual_space_list());
|
|
|
|
while (iter.repeat()) {
|
|
|
|
VirtualSpaceNode* vsl = iter.get_next();
|
|
|
|
assert(vsl != purged_vsl, "Purge of vsl failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
VirtualSpaceList::VirtualSpaceList(size_t word_size) :
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_is_class(false),
|
|
|
|
_virtual_space_list(NULL),
|
|
|
|
_current_virtual_space(NULL),
|
2013-09-12 10:15:54 +02:00
|
|
|
_reserved_words(0),
|
|
|
|
_committed_words(0),
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_virtual_space_count(0) {
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
2013-10-07 15:51:08 +02:00
|
|
|
create_new_virtual_space(word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) :
|
|
|
|
_is_class(true),
|
|
|
|
_virtual_space_list(NULL),
|
|
|
|
_current_virtual_space(NULL),
|
2013-09-12 10:15:54 +02:00
|
|
|
_reserved_words(0),
|
|
|
|
_committed_words(0),
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_virtual_space_count(0) {
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
|
|
|
VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs);
|
|
|
|
bool succeeded = class_entry->initialize();
|
2013-10-07 15:51:08 +02:00
|
|
|
if (succeeded) {
|
|
|
|
link_vs(class_entry);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t VirtualSpaceList::free_bytes() {
|
|
|
|
return virtual_space_list()->free_words_in_vs() * BytesPerWord;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Allocate another meta virtual space and add it to the list.
|
2013-10-07 15:51:08 +02:00
|
|
|
bool VirtualSpaceList::create_new_virtual_space(size_t vs_word_size) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
if (is_class()) {
|
|
|
|
assert(false, "We currently don't support more than one VirtualSpace for"
|
|
|
|
" the compressed class space. The initialization of the"
|
|
|
|
" CCS uses another code path and should not hit this path.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (vs_word_size == 0) {
|
2013-10-07 15:51:08 +02:00
|
|
|
assert(false, "vs_word_size should always be at least _reserve_alignment large.");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return false;
|
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Reserve the space
|
|
|
|
size_t vs_byte_size = vs_word_size * BytesPerWord;
|
2013-10-07 15:51:08 +02:00
|
|
|
assert_is_size_aligned(vs_byte_size, Metaspace::reserve_alignment());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Allocate the meta virtual space and initialize it.
|
|
|
|
VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size);
|
|
|
|
if (!new_entry->initialize()) {
|
|
|
|
delete new_entry;
|
|
|
|
return false;
|
|
|
|
} else {
|
2013-10-07 15:51:08 +02:00
|
|
|
assert(new_entry->reserved_words() == vs_word_size,
|
|
|
|
"Reserved memory size differs from requested memory size");
|
2012-11-28 17:50:21 -05:00
|
|
|
// ensure lock-free iteration sees fully initialized node
|
|
|
|
OrderAccess::storestore();
|
2013-09-12 10:15:54 +02:00
|
|
|
link_vs(new_entry);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (virtual_space_list() == NULL) {
|
|
|
|
set_virtual_space_list(new_entry);
|
|
|
|
} else {
|
|
|
|
current_virtual_space()->set_next(new_entry);
|
|
|
|
}
|
|
|
|
set_current_virtual_space(new_entry);
|
2013-09-12 10:15:54 +02:00
|
|
|
inc_reserved_words(new_entry->reserved_words());
|
|
|
|
inc_committed_words(new_entry->committed_words());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
inc_virtual_space_count();
|
|
|
|
#ifdef ASSERT
|
|
|
|
new_entry->mangle();
|
|
|
|
#endif
|
|
|
|
if (TraceMetavirtualspaceAllocation && Verbose) {
|
|
|
|
VirtualSpaceNode* vsl = current_virtual_space();
|
2013-09-13 22:25:27 +02:00
|
|
|
vsl->print_on(gclog_or_tty);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool VirtualSpaceList::expand_node_by(VirtualSpaceNode* node,
|
|
|
|
size_t min_words,
|
|
|
|
size_t preferred_words) {
|
2013-09-12 10:15:54 +02:00
|
|
|
size_t before = node->committed_words();
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool result = node->expand_by(min_words, preferred_words);
|
2013-09-12 10:15:54 +02:00
|
|
|
|
|
|
|
size_t after = node->committed_words();
|
|
|
|
|
|
|
|
// after and before can be the same if the memory was pre-committed.
|
2013-10-07 15:51:08 +02:00
|
|
|
assert(after >= before, "Inconsistency");
|
2013-09-12 10:15:54 +02:00
|
|
|
inc_committed_words(after - before);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
bool VirtualSpaceList::expand_by(size_t min_words, size_t preferred_words) {
|
|
|
|
assert_is_size_aligned(min_words, Metaspace::commit_alignment_words());
|
|
|
|
assert_is_size_aligned(preferred_words, Metaspace::commit_alignment_words());
|
|
|
|
assert(min_words <= preferred_words, "Invalid arguments");
|
|
|
|
|
|
|
|
if (!MetaspaceGC::can_expand(min_words, this->is_class())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t allowed_expansion_words = MetaspaceGC::allowed_expansion();
|
|
|
|
if (allowed_expansion_words < min_words) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t max_expansion_words = MIN2(preferred_words, allowed_expansion_words);
|
|
|
|
|
|
|
|
// Commit more memory from the the current virtual space.
|
|
|
|
bool vs_expanded = expand_node_by(current_virtual_space(),
|
|
|
|
min_words,
|
|
|
|
max_expansion_words);
|
|
|
|
if (vs_expanded) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get another virtual space.
|
|
|
|
size_t grow_vs_words = MAX2((size_t)VirtualSpaceSize, preferred_words);
|
|
|
|
grow_vs_words = align_size_up(grow_vs_words, Metaspace::reserve_alignment_words());
|
|
|
|
|
|
|
|
if (create_new_virtual_space(grow_vs_words)) {
|
|
|
|
if (current_virtual_space()->is_pre_committed()) {
|
|
|
|
// The memory was pre-committed, so we are done here.
|
|
|
|
assert(min_words <= current_virtual_space()->committed_words(),
|
|
|
|
"The new VirtualSpace was pre-committed, so it"
|
|
|
|
"should be large enough to fit the alloc request.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return expand_node_by(current_virtual_space(),
|
|
|
|
min_words,
|
|
|
|
max_expansion_words);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metachunk* VirtualSpaceList::get_new_chunk(size_t word_size,
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t grow_chunks_by_words,
|
|
|
|
size_t medium_chunk_bunch) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
// Allocate a chunk out of the current virtual space.
|
|
|
|
Metachunk* next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
if (next != NULL) {
|
|
|
|
return next;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// The expand amount is currently only determined by the requested sizes
|
|
|
|
// and not how much committed memory is left in the current virtual space.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t min_word_size = align_size_up(grow_chunks_by_words, Metaspace::commit_alignment_words());
|
|
|
|
size_t preferred_word_size = align_size_up(medium_chunk_bunch, Metaspace::commit_alignment_words());
|
|
|
|
if (min_word_size >= preferred_word_size) {
|
|
|
|
// Can happen when humongous chunks are allocated.
|
|
|
|
preferred_word_size = min_word_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool expanded = expand_by(min_word_size, preferred_word_size);
|
|
|
|
if (expanded) {
|
|
|
|
next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words);
|
|
|
|
assert(next != NULL, "The allocation was expected to succeed after the expansion");
|
|
|
|
}
|
|
|
|
|
|
|
|
return next;
|
2012-12-03 15:09:39 -08:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void VirtualSpaceList::print_on(outputStream* st) const {
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
VirtualSpaceListIterator iter(virtual_space_list());
|
|
|
|
while (iter.repeat()) {
|
|
|
|
VirtualSpaceNode* node = iter.get_next();
|
|
|
|
node->print_on(st);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VirtualSpaceList::contains(const void *ptr) {
|
|
|
|
VirtualSpaceNode* list = virtual_space_list();
|
|
|
|
VirtualSpaceListIterator iter(list);
|
|
|
|
while (iter.repeat()) {
|
|
|
|
VirtualSpaceNode* node = iter.get_next();
|
|
|
|
if (node->reserved()->contains(ptr)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MetaspaceGC methods
|
|
|
|
|
|
|
|
// VM_CollectForMetadataAllocation is the vm operation used to GC.
|
|
|
|
// Within the VM operation after the GC the attempt to allocate the metadata
|
|
|
|
// should succeed. If the GC did not free enough space for the metaspace
|
|
|
|
// allocation, the HWM is increased so that another virtualspace will be
|
|
|
|
// allocated for the metadata. With perm gen the increase in the perm
|
|
|
|
// gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The
|
|
|
|
// metaspace policy uses those as the small and large steps for the HWM.
|
|
|
|
//
|
|
|
|
// After the GC the compute_new_size() for MetaspaceGC is called to
|
|
|
|
// resize the capacity of the metaspaces. The current implementation
|
2013-02-12 14:15:45 -08:00
|
|
|
// is based on the flags MinMetaspaceFreeRatio and MaxMetaspaceFreeRatio used
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// to resize the Java heap by some GC's. New flags can be implemented
|
2013-02-12 14:15:45 -08:00
|
|
|
// if really needed. MinMetaspaceFreeRatio is used to calculate how much
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// free space is desirable in the metaspace capacity to decide how much
|
2013-01-23 19:08:04 -08:00
|
|
|
// to increase the HWM. MaxMetaspaceFreeRatio is used to decide how much
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// free space is desirable in the metaspace capacity before decreasing
|
|
|
|
// the HWM.
|
|
|
|
|
|
|
|
// Calculate the amount to increase the high water mark (HWM).
|
|
|
|
// Increase by a minimum amount (MinMetaspaceExpansion) so that
|
|
|
|
// another expansion is not requested too soon. If that is not
|
2013-10-07 15:51:08 +02:00
|
|
|
// enough to satisfy the allocation, increase by MaxMetaspaceExpansion.
|
|
|
|
// If that is still not enough, expand by the size of the allocation
|
|
|
|
// plus some.
|
|
|
|
size_t MetaspaceGC::delta_capacity_until_GC(size_t bytes) {
|
|
|
|
size_t min_delta = MinMetaspaceExpansion;
|
|
|
|
size_t max_delta = MaxMetaspaceExpansion;
|
|
|
|
size_t delta = align_size_up(bytes, Metaspace::commit_alignment());
|
|
|
|
|
|
|
|
if (delta <= min_delta) {
|
|
|
|
delta = min_delta;
|
|
|
|
} else if (delta <= max_delta) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Don't want to hit the high water mark on the next
|
|
|
|
// allocation so make the delta greater than just enough
|
|
|
|
// for this allocation.
|
2013-10-07 15:51:08 +02:00
|
|
|
delta = max_delta;
|
|
|
|
} else {
|
|
|
|
// This allocation is large but the next ones are probably not
|
|
|
|
// so increase by the minimum.
|
|
|
|
delta = delta + min_delta;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
assert_is_size_aligned(delta, Metaspace::commit_alignment());
|
|
|
|
|
|
|
|
return delta;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t MetaspaceGC::capacity_until_GC() {
|
|
|
|
size_t value = (size_t)OrderAccess::load_ptr_acquire(&_capacity_until_GC);
|
|
|
|
assert(value >= MetaspaceSize, "Not initialied properly?");
|
|
|
|
return value;
|
|
|
|
}
|
2013-02-12 14:15:45 -08:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t MetaspaceGC::inc_capacity_until_GC(size_t v) {
|
|
|
|
assert_is_size_aligned(v, Metaspace::commit_alignment());
|
|
|
|
|
|
|
|
return (size_t)Atomic::add_ptr(v, &_capacity_until_GC);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t MetaspaceGC::dec_capacity_until_GC(size_t v) {
|
|
|
|
assert_is_size_aligned(v, Metaspace::commit_alignment());
|
|
|
|
|
|
|
|
return (size_t)Atomic::add_ptr(-(intptr_t)v, &_capacity_until_GC);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MetaspaceGC::can_expand(size_t word_size, bool is_class) {
|
|
|
|
// Check if the compressed class space is full.
|
|
|
|
if (is_class && Metaspace::using_class_space()) {
|
|
|
|
size_t class_committed = MetaspaceAux::committed_bytes(Metaspace::ClassType);
|
|
|
|
if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) {
|
2013-07-02 08:42:37 -04:00
|
|
|
return false;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// Check if the user has imposed a limit on the metaspace memory.
|
|
|
|
size_t committed_bytes = MetaspaceAux::committed_bytes();
|
|
|
|
if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-03-21 09:07:43 +01:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t MetaspaceGC::allowed_expansion() {
|
|
|
|
size_t committed_bytes = MetaspaceAux::committed_bytes();
|
|
|
|
|
|
|
|
size_t left_until_max = MaxMetaspaceSize - committed_bytes;
|
|
|
|
|
|
|
|
// Always grant expansion if we are initiating the JVM,
|
|
|
|
// or if the GC_locker is preventing GCs.
|
|
|
|
if (!is_init_completed() || GC_locker::is_active_and_needs_gc()) {
|
|
|
|
return left_until_max / BytesPerWord;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t capacity_until_gc = capacity_until_GC();
|
2013-02-12 14:15:45 -08:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
if (capacity_until_gc <= committed_bytes) {
|
|
|
|
return 0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t left_until_GC = capacity_until_gc - committed_bytes;
|
|
|
|
size_t left_to_commit = MIN2(left_until_GC, left_until_max);
|
2013-02-12 14:15:45 -08:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
return left_to_commit / BytesPerWord;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
void MetaspaceGC::compute_new_size() {
|
|
|
|
assert(_shrink_factor <= 100, "invalid shrink factor");
|
|
|
|
uint current_shrink_factor = _shrink_factor;
|
|
|
|
_shrink_factor = 0;
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
const size_t used_after_gc = MetaspaceAux::allocated_capacity_bytes();
|
|
|
|
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-01-23 19:08:04 -08:00
|
|
|
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
const double maximum_used_percentage = 1.0 - minimum_free_percentage;
|
|
|
|
|
|
|
|
const double min_tmp = used_after_gc / maximum_used_percentage;
|
|
|
|
size_t minimum_desired_capacity =
|
|
|
|
(size_t)MIN2(min_tmp, double(max_uintx));
|
|
|
|
// Don't shrink less than the initial generation size
|
|
|
|
minimum_desired_capacity = MAX2(minimum_desired_capacity,
|
|
|
|
MetaspaceSize);
|
|
|
|
|
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("\nMetaspaceGC::compute_new_size: ");
|
|
|
|
gclog_or_tty->print_cr(" "
|
|
|
|
" minimum_free_percentage: %6.2f"
|
|
|
|
" maximum_used_percentage: %6.2f",
|
|
|
|
minimum_free_percentage,
|
|
|
|
maximum_used_percentage);
|
|
|
|
gclog_or_tty->print_cr(" "
|
2013-02-12 14:15:45 -08:00
|
|
|
" used_after_gc : %6.1fKB",
|
|
|
|
used_after_gc / (double) K);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t shrink_bytes = 0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (capacity_until_GC < minimum_desired_capacity) {
|
|
|
|
// If we have less capacity below the metaspace HWM, then
|
|
|
|
// increment the HWM.
|
|
|
|
size_t expand_bytes = minimum_desired_capacity - capacity_until_GC;
|
2013-10-07 15:51:08 +02:00
|
|
|
expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Don't expand unless it's significant
|
|
|
|
if (expand_bytes >= MinMetaspaceExpansion) {
|
2013-10-07 15:51:08 +02:00
|
|
|
MetaspaceGC::inc_capacity_until_GC(expand_bytes);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
if (PrintGCDetails && Verbose) {
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t new_capacity_until_GC = capacity_until_GC;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
gclog_or_tty->print_cr(" expanding:"
|
2013-02-12 14:15:45 -08:00
|
|
|
" minimum_desired_capacity: %6.1fKB"
|
|
|
|
" expand_bytes: %6.1fKB"
|
|
|
|
" MinMetaspaceExpansion: %6.1fKB"
|
|
|
|
" new metaspace HWM: %6.1fKB",
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
minimum_desired_capacity / (double) K,
|
|
|
|
expand_bytes / (double) K,
|
|
|
|
MinMetaspaceExpansion / (double) K,
|
|
|
|
new_capacity_until_GC / (double) K);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No expansion, now see if we want to shrink
|
|
|
|
// We would never want to shrink more than this
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t max_shrink_bytes = capacity_until_GC - minimum_desired_capacity;
|
|
|
|
assert(max_shrink_bytes >= 0, err_msg("max_shrink_bytes " SIZE_FORMAT,
|
|
|
|
max_shrink_bytes));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Should shrinking be considered?
|
2013-01-23 19:08:04 -08:00
|
|
|
if (MaxMetaspaceFreeRatio < 100) {
|
|
|
|
const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
const double minimum_used_percentage = 1.0 - maximum_free_percentage;
|
|
|
|
const double max_tmp = used_after_gc / minimum_used_percentage;
|
|
|
|
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
|
|
|
|
maximum_desired_capacity = MAX2(maximum_desired_capacity,
|
|
|
|
MetaspaceSize);
|
2013-02-12 14:15:45 -08:00
|
|
|
if (PrintGCDetails && Verbose) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
gclog_or_tty->print_cr(" "
|
|
|
|
" maximum_free_percentage: %6.2f"
|
|
|
|
" minimum_used_percentage: %6.2f",
|
|
|
|
maximum_free_percentage,
|
|
|
|
minimum_used_percentage);
|
|
|
|
gclog_or_tty->print_cr(" "
|
2013-02-12 14:15:45 -08:00
|
|
|
" minimum_desired_capacity: %6.1fKB"
|
|
|
|
" maximum_desired_capacity: %6.1fKB",
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
minimum_desired_capacity / (double) K,
|
|
|
|
maximum_desired_capacity / (double) K);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(minimum_desired_capacity <= maximum_desired_capacity,
|
|
|
|
"sanity check");
|
|
|
|
|
|
|
|
if (capacity_until_GC > maximum_desired_capacity) {
|
|
|
|
// Capacity too large, compute shrinking size
|
2013-02-12 14:15:45 -08:00
|
|
|
shrink_bytes = capacity_until_GC - maximum_desired_capacity;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// We don't want shrink all the way back to initSize if people call
|
|
|
|
// System.gc(), because some programs do that between "phases" and then
|
|
|
|
// we'd just have to grow the heap up again for the next phase. So we
|
|
|
|
// damp the shrinking: 0% on the first call, 10% on the second call, 40%
|
|
|
|
// on the third call, and 100% by the fourth call. But if we recompute
|
|
|
|
// size without shrinking, it goes back to 0%.
|
2013-02-12 14:15:45 -08:00
|
|
|
shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
shrink_bytes = align_size_down(shrink_bytes, Metaspace::commit_alignment());
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
assert(shrink_bytes <= max_shrink_bytes,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
err_msg("invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT,
|
2013-02-12 14:15:45 -08:00
|
|
|
shrink_bytes, max_shrink_bytes));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (current_shrink_factor == 0) {
|
|
|
|
_shrink_factor = 10;
|
|
|
|
} else {
|
|
|
|
_shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100);
|
|
|
|
}
|
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
gclog_or_tty->print_cr(" "
|
|
|
|
" shrinking:"
|
|
|
|
" initSize: %.1fK"
|
|
|
|
" maximum_desired_capacity: %.1fK",
|
|
|
|
MetaspaceSize / (double) K,
|
|
|
|
maximum_desired_capacity / (double) K);
|
|
|
|
gclog_or_tty->print_cr(" "
|
2013-02-12 14:15:45 -08:00
|
|
|
" shrink_bytes: %.1fK"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
" current_shrink_factor: %d"
|
|
|
|
" new shrink factor: %d"
|
|
|
|
" MinMetaspaceExpansion: %.1fK",
|
2013-02-12 14:15:45 -08:00
|
|
|
shrink_bytes / (double) K,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
current_shrink_factor,
|
|
|
|
_shrink_factor,
|
|
|
|
MinMetaspaceExpansion / (double) K);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't shrink unless it's significant
|
2013-02-12 14:15:45 -08:00
|
|
|
if (shrink_bytes >= MinMetaspaceExpansion &&
|
|
|
|
((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
|
2013-10-07 15:51:08 +02:00
|
|
|
MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Metadebug methods
|
|
|
|
|
|
|
|
void Metadebug::deallocate_chunk_a_lot(SpaceManager* sm,
|
|
|
|
size_t chunk_word_size){
|
|
|
|
#ifdef ASSERT
|
|
|
|
VirtualSpaceList* vsl = sm->vs_list();
|
|
|
|
if (MetaDataDeallocateALot &&
|
|
|
|
Metadebug::deallocate_chunk_a_lot_count() % MetaDataDeallocateALotInterval == 0 ) {
|
|
|
|
Metadebug::reset_deallocate_chunk_a_lot_count();
|
|
|
|
for (uint i = 0; i < metadata_deallocate_a_lock_chunk; i++) {
|
|
|
|
Metachunk* dummy_chunk = vsl->current_virtual_space()->take_from_committed(chunk_word_size);
|
|
|
|
if (dummy_chunk == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2013-09-21 10:09:42 +02:00
|
|
|
sm->chunk_manager()->chunk_freelist_deallocate(dummy_chunk);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print("Metadebug::deallocate_chunk_a_lot: %d) ",
|
|
|
|
sm->sum_count_in_chunks_in_use());
|
|
|
|
dummy_chunk->print_on(gclog_or_tty);
|
|
|
|
gclog_or_tty->print_cr(" Free chunks total %d count %d",
|
2013-09-21 10:09:42 +02:00
|
|
|
sm->chunk_manager()->free_chunks_total_words(),
|
|
|
|
sm->chunk_manager()->free_chunks_count());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Metadebug::inc_deallocate_chunk_a_lot_count();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void Metadebug::deallocate_block_a_lot(SpaceManager* sm,
|
|
|
|
size_t raw_word_size){
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (MetaDataDeallocateALot &&
|
|
|
|
Metadebug::deallocate_block_a_lot_count() % MetaDataDeallocateALotInterval == 0 ) {
|
|
|
|
Metadebug::set_deallocate_block_a_lot_count(0);
|
|
|
|
for (uint i = 0; i < metadata_deallocate_a_lot_block; i++) {
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* dummy_block = sm->allocate_work(raw_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (dummy_block == 0) {
|
|
|
|
break;
|
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
sm->deallocate(dummy_block, raw_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Metadebug::inc_deallocate_block_a_lot_count();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void Metadebug::init_allocation_fail_alot_count() {
|
|
|
|
if (MetadataAllocationFailALot) {
|
|
|
|
_allocation_fail_alot_count =
|
|
|
|
1+(long)((double)MetadataAllocationFailALotInterval*os::random()/(max_jint+1.0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
bool Metadebug::test_metadata_failure() {
|
|
|
|
if (MetadataAllocationFailALot &&
|
|
|
|
Threads::is_vm_complete()) {
|
|
|
|
if (_allocation_fail_alot_count > 0) {
|
|
|
|
_allocation_fail_alot_count--;
|
|
|
|
} else {
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("Metadata allocation failing for "
|
|
|
|
"MetadataAllocationFailALot");
|
|
|
|
}
|
|
|
|
init_allocation_fail_alot_count();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ChunkManager methods
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t ChunkManager::free_chunks_total_words() {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return _free_chunks_total;
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t ChunkManager::free_chunks_total_bytes() {
|
|
|
|
return free_chunks_total_words() * BytesPerWord;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t ChunkManager::free_chunks_count() {
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) {
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
|
|
|
// This lock is only needed in debug because the verification
|
|
|
|
// of the _free_chunks_totals walks the list of free chunks
|
2012-11-09 00:38:31 +01:00
|
|
|
slow_locked_verify_free_chunks_count();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
#endif
|
2012-11-09 00:38:31 +01:00
|
|
|
return _free_chunks_count;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::locked_verify_free_chunks_total() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
assert(sum_free_chunks() == _free_chunks_total,
|
|
|
|
err_msg("_free_chunks_total " SIZE_FORMAT " is not the"
|
|
|
|
" same as sum " SIZE_FORMAT, _free_chunks_total,
|
|
|
|
sum_free_chunks()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::verify_free_chunks_total() {
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
|
|
|
locked_verify_free_chunks_total();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::locked_verify_free_chunks_count() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
assert(sum_free_chunks_count() == _free_chunks_count,
|
|
|
|
err_msg("_free_chunks_count " SIZE_FORMAT " is not the"
|
|
|
|
" same as sum " SIZE_FORMAT, _free_chunks_count,
|
|
|
|
sum_free_chunks_count()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::verify_free_chunks_count() {
|
|
|
|
#ifdef ASSERT
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
|
|
|
locked_verify_free_chunks_count();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::verify() {
|
2012-11-09 00:38:31 +01:00
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
|
|
|
locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::locked_verify() {
|
|
|
|
locked_verify_free_chunks_count();
|
2012-09-18 23:35:42 -07:00
|
|
|
locked_verify_free_chunks_total();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::locked_print_free_chunks(outputStream* st) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2012-12-03 15:09:39 -08:00
|
|
|
st->print_cr("Free chunk total " SIZE_FORMAT " count " SIZE_FORMAT,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_free_chunks_total, _free_chunks_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::locked_print_sum_free_chunks(outputStream* st) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2012-12-03 15:09:39 -08:00
|
|
|
st->print_cr("Sum free chunk total " SIZE_FORMAT " count " SIZE_FORMAT,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
sum_free_chunks(), sum_free_chunks_count());
|
|
|
|
}
|
|
|
|
ChunkList* ChunkManager::free_chunks(ChunkIndex index) {
|
|
|
|
return &_free_chunks[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
// These methods that sum the free chunk lists are used in printing
|
|
|
|
// methods that are used in product builds.
|
|
|
|
size_t ChunkManager::sum_free_chunks() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
size_t result = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ChunkList* list = free_chunks(i);
|
|
|
|
|
|
|
|
if (list == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-04-01 10:50:30 -07:00
|
|
|
result = result + list->count() * list->size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
result = result + humongous_dictionary()->total_size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t ChunkManager::sum_free_chunks_count() {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
size_t count = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ChunkList* list = free_chunks(i);
|
|
|
|
if (list == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-04-01 10:50:30 -07:00
|
|
|
count = count + list->count();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
count = count + humongous_dictionary()->total_free_blocks();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChunkList* ChunkManager::find_free_chunks_list(size_t word_size) {
|
2012-12-03 15:09:39 -08:00
|
|
|
ChunkIndex index = list_index(word_size);
|
|
|
|
assert(index < HumongousIndex, "No humongous list");
|
|
|
|
return free_chunks(index);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::free_chunks_put(Metachunk* chunk) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
ChunkList* free_list = find_free_chunks_list(chunk->word_size());
|
|
|
|
chunk->set_next(free_list->head());
|
|
|
|
free_list->set_head(chunk);
|
|
|
|
// chunk is being returned to the chunk free list
|
|
|
|
inc_free_chunks_total(chunk->capacity_word_size());
|
2012-11-09 00:38:31 +01:00
|
|
|
slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) {
|
|
|
|
// The deallocation of a chunk originates in the freelist
|
|
|
|
// manangement code for a Metaspace and does not hold the
|
|
|
|
// lock.
|
|
|
|
assert(chunk != NULL, "Deallocating NULL");
|
2012-11-09 00:38:31 +01:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (TraceMetadataChunkAllocation) {
|
2013-09-13 22:25:27 +02:00
|
|
|
gclog_or_tty->print_cr("ChunkManager::chunk_freelist_deallocate: chunk "
|
|
|
|
PTR_FORMAT " size " SIZE_FORMAT,
|
|
|
|
chunk, chunk->word_size());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
free_chunks_put(chunk);
|
|
|
|
}
|
|
|
|
|
|
|
|
Metachunk* ChunkManager::free_chunks_get(size_t word_size) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
|
2012-11-09 00:38:31 +01:00
|
|
|
slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
Metachunk* chunk = NULL;
|
2012-12-03 15:09:39 -08:00
|
|
|
if (list_index(word_size) != HumongousIndex) {
|
2012-09-18 23:35:42 -07:00
|
|
|
ChunkList* free_list = find_free_chunks_list(word_size);
|
|
|
|
assert(free_list != NULL, "Sanity check");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
chunk = free_list->head();
|
|
|
|
|
|
|
|
if (chunk == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Remove the chunk as the head of the list.
|
2013-04-01 10:50:30 -07:00
|
|
|
free_list->remove_chunk(chunk);
|
2012-12-03 15:09:39 -08:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
2013-09-13 22:25:27 +02:00
|
|
|
gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list "
|
|
|
|
PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
|
|
|
|
free_list, chunk, chunk->word_size());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
} else {
|
2012-09-18 23:35:42 -07:00
|
|
|
chunk = humongous_dictionary()->get_chunk(
|
|
|
|
word_size,
|
|
|
|
FreeBlockDictionary<Metachunk>::atLeast);
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
if (chunk == NULL) {
|
2012-12-03 15:09:39 -08:00
|
|
|
return NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
if (TraceMetadataHumongousAllocation) {
|
|
|
|
size_t waste = chunk->word_size() - word_size;
|
|
|
|
gclog_or_tty->print_cr("Free list allocate humongous chunk size "
|
|
|
|
SIZE_FORMAT " for requested size " SIZE_FORMAT
|
|
|
|
" waste " SIZE_FORMAT,
|
|
|
|
chunk->word_size(), word_size, waste);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-12-03 15:09:39 -08:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// Chunk is being removed from the chunks free list.
|
|
|
|
dec_free_chunks_total(chunk->capacity_word_size());
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// Remove it from the links to this freelist
|
|
|
|
chunk->set_next(NULL);
|
|
|
|
chunk->set_prev(NULL);
|
2013-03-01 10:19:29 -08:00
|
|
|
#ifdef ASSERT
|
|
|
|
// Chunk is no longer on any freelist. Setting to false make container_count_slow()
|
|
|
|
// work.
|
|
|
|
chunk->set_is_free(false);
|
|
|
|
#endif
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk->container()->inc_container_count();
|
|
|
|
|
2012-11-09 00:38:31 +01:00
|
|
|
slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return chunk;
|
|
|
|
}
|
|
|
|
|
|
|
|
Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2012-11-09 00:38:31 +01:00
|
|
|
slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Take from the beginning of the list
|
|
|
|
Metachunk* chunk = free_chunks_get(word_size);
|
|
|
|
if (chunk == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
assert((word_size <= chunk->word_size()) ||
|
|
|
|
list_index(chunk->word_size() == HumongousIndex),
|
|
|
|
"Non-humongous variable sized chunk");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (TraceMetadataChunkAllocation) {
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t list_count;
|
|
|
|
if (list_index(word_size) < HumongousIndex) {
|
|
|
|
ChunkList* list = find_free_chunks_list(word_size);
|
2013-04-01 10:50:30 -07:00
|
|
|
list_count = list->count();
|
2012-12-03 15:09:39 -08:00
|
|
|
} else {
|
|
|
|
list_count = humongous_dictionary()->total_count();
|
|
|
|
}
|
2013-09-13 22:25:27 +02:00
|
|
|
gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk "
|
|
|
|
PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ",
|
|
|
|
this, chunk, chunk->word_size(), list_count);
|
|
|
|
locked_print_free_chunks(gclog_or_tty);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return chunk;
|
|
|
|
}
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
void ChunkManager::print_on(outputStream* out) const {
|
2012-09-18 23:35:42 -07:00
|
|
|
if (PrintFLSStatistics != 0) {
|
2013-09-21 10:09:42 +02:00
|
|
|
const_cast<ChunkManager *>(this)->humongous_dictionary()->report_statistics();
|
2012-09-18 23:35:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// SpaceManager methods
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
void SpaceManager::get_initial_chunk_sizes(Metaspace::MetaspaceType type,
|
|
|
|
size_t* chunk_word_size,
|
|
|
|
size_t* class_chunk_word_size) {
|
|
|
|
switch (type) {
|
|
|
|
case Metaspace::BootMetaspaceType:
|
|
|
|
*chunk_word_size = Metaspace::first_chunk_word_size();
|
|
|
|
*class_chunk_word_size = Metaspace::first_class_chunk_word_size();
|
|
|
|
break;
|
|
|
|
case Metaspace::ROMetaspaceType:
|
|
|
|
*chunk_word_size = SharedReadOnlySize / wordSize;
|
|
|
|
*class_chunk_word_size = ClassSpecializedChunk;
|
|
|
|
break;
|
|
|
|
case Metaspace::ReadWriteMetaspaceType:
|
|
|
|
*chunk_word_size = SharedReadWriteSize / wordSize;
|
|
|
|
*class_chunk_word_size = ClassSpecializedChunk;
|
|
|
|
break;
|
|
|
|
case Metaspace::AnonymousMetaspaceType:
|
|
|
|
case Metaspace::ReflectionMetaspaceType:
|
|
|
|
*chunk_word_size = SpecializedChunk;
|
|
|
|
*class_chunk_word_size = ClassSpecializedChunk;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*chunk_word_size = SmallChunk;
|
|
|
|
*class_chunk_word_size = ClassSmallChunk;
|
|
|
|
break;
|
|
|
|
}
|
2013-02-01 17:21:53 -08:00
|
|
|
assert(*chunk_word_size != 0 && *class_chunk_word_size != 0,
|
2012-12-03 15:09:39 -08:00
|
|
|
err_msg("Initial chunks sizes bad: data " SIZE_FORMAT
|
|
|
|
" class " SIZE_FORMAT,
|
2013-02-01 17:21:53 -08:00
|
|
|
*chunk_word_size, *class_chunk_word_size));
|
2012-12-03 15:09:39 -08:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
size_t SpaceManager::sum_free_in_chunks_in_use() const {
|
|
|
|
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
size_t free = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metachunk* chunk = chunks_in_use(i);
|
|
|
|
while (chunk != NULL) {
|
|
|
|
free += chunk->free_word_size();
|
|
|
|
chunk = chunk->next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return free;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SpaceManager::sum_waste_in_chunks_in_use() const {
|
|
|
|
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
size_t result = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
result += sum_waste_in_chunks_in_use(i);
|
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SpaceManager::sum_waste_in_chunks_in_use(ChunkIndex index) const {
|
|
|
|
size_t result = 0;
|
|
|
|
Metachunk* chunk = chunks_in_use(index);
|
|
|
|
// Count the free space in all the chunk but not the
|
|
|
|
// current chunk from which allocations are still being done.
|
2013-07-02 08:42:37 -04:00
|
|
|
while (chunk != NULL) {
|
|
|
|
if (chunk != current_chunk()) {
|
2012-09-18 23:35:42 -07:00
|
|
|
result += chunk->free_word_size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-07-02 08:42:37 -04:00
|
|
|
chunk = chunk->next();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SpaceManager::sum_capacity_in_chunks_in_use() const {
|
2013-02-12 14:15:45 -08:00
|
|
|
// For CMS use "allocated_chunks_words()" which does not need the
|
|
|
|
// Metaspace lock. For the other collectors sum over the
|
|
|
|
// lists. Use both methods as a check that "allocated_chunks_words()"
|
|
|
|
// is correct. That is, sum_capacity_in_chunks() is too expensive
|
|
|
|
// to use in the product and allocated_chunks_words() should be used
|
|
|
|
// but allow for checking that allocated_chunks_words() returns the same
|
|
|
|
// value as sum_capacity_in_chunks_in_use() which is the definitive
|
|
|
|
// answer.
|
|
|
|
if (UseConcMarkSweepGC) {
|
|
|
|
return allocated_chunks_words();
|
|
|
|
} else {
|
|
|
|
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
size_t sum = 0;
|
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
|
|
|
Metachunk* chunk = chunks_in_use(i);
|
|
|
|
while (chunk != NULL) {
|
|
|
|
sum += chunk->capacity_word_size();
|
|
|
|
chunk = chunk->next();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
return sum;
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t SpaceManager::sum_count_in_chunks_in_use() {
|
|
|
|
size_t count = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
count = count + sum_count_in_chunks_in_use(i);
|
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SpaceManager::sum_count_in_chunks_in_use(ChunkIndex i) {
|
|
|
|
size_t count = 0;
|
|
|
|
Metachunk* chunk = chunks_in_use(i);
|
|
|
|
while (chunk != NULL) {
|
|
|
|
count++;
|
|
|
|
chunk = chunk->next();
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t SpaceManager::sum_used_in_chunks_in_use() const {
|
|
|
|
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
size_t used = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metachunk* chunk = chunks_in_use(i);
|
|
|
|
while (chunk != NULL) {
|
|
|
|
used += chunk->used_word_size();
|
|
|
|
chunk = chunk->next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return used;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const {
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
|
|
|
Metachunk* chunk = chunks_in_use(i);
|
|
|
|
st->print("SpaceManager: %s " PTR_FORMAT,
|
|
|
|
chunk_size_name(i), chunk);
|
|
|
|
if (chunk != NULL) {
|
|
|
|
st->print_cr(" free " SIZE_FORMAT,
|
|
|
|
chunk->free_word_size());
|
|
|
|
} else {
|
|
|
|
st->print_cr("");
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->locked_print_free_chunks(st);
|
|
|
|
chunk_manager()->locked_print_sum_free_chunks(st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t SpaceManager::calc_chunk_size(size_t word_size) {
|
|
|
|
|
|
|
|
// Decide between a small chunk and a medium chunk. Up to
|
|
|
|
// _small_chunk_limit small chunks can be allocated but
|
|
|
|
// once a medium chunk has been allocated, no more small
|
|
|
|
// chunks will be allocated.
|
|
|
|
size_t chunk_word_size;
|
|
|
|
if (chunks_in_use(MediumIndex) == NULL &&
|
2013-07-02 08:42:37 -04:00
|
|
|
sum_count_in_chunks_in_use(SmallIndex) < _small_chunk_limit) {
|
2012-12-03 15:09:39 -08:00
|
|
|
chunk_word_size = (size_t) small_chunk_size();
|
|
|
|
if (word_size + Metachunk::overhead() > small_chunk_size()) {
|
|
|
|
chunk_word_size = medium_chunk_size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
} else {
|
2012-12-03 15:09:39 -08:00
|
|
|
chunk_word_size = medium_chunk_size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// Might still need a humongous chunk. Enforce an
|
|
|
|
// eight word granularity to facilitate reuse (some
|
|
|
|
// wastage but better chance of reuse).
|
|
|
|
size_t if_humongous_sized_chunk =
|
|
|
|
align_size_up(word_size + Metachunk::overhead(),
|
|
|
|
HumongousChunkGranularity);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
chunk_word_size =
|
2012-12-03 15:09:39 -08:00
|
|
|
MAX2((size_t) chunk_word_size, if_humongous_sized_chunk);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
assert(!SpaceManager::is_humongous(word_size) ||
|
|
|
|
chunk_word_size == if_humongous_sized_chunk,
|
|
|
|
err_msg("Size calculation is wrong, word_size " SIZE_FORMAT
|
|
|
|
" chunk_word_size " SIZE_FORMAT,
|
|
|
|
word_size, chunk_word_size));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (TraceMetadataHumongousAllocation &&
|
|
|
|
SpaceManager::is_humongous(word_size)) {
|
|
|
|
gclog_or_tty->print_cr("Metadata humongous allocation:");
|
|
|
|
gclog_or_tty->print_cr(" word_size " PTR_FORMAT, word_size);
|
|
|
|
gclog_or_tty->print_cr(" chunk_word_size " PTR_FORMAT,
|
|
|
|
chunk_word_size);
|
2012-09-18 23:35:42 -07:00
|
|
|
gclog_or_tty->print_cr(" chunk overhead " PTR_FORMAT,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metachunk::overhead());
|
|
|
|
}
|
|
|
|
return chunk_word_size;
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:17 +02:00
|
|
|
void SpaceManager::track_metaspace_memory_usage() {
|
|
|
|
if (is_init_completed()) {
|
|
|
|
if (is_class()) {
|
|
|
|
MemoryService::track_compressed_class_memory_usage();
|
|
|
|
}
|
|
|
|
MemoryService::track_metaspace_memory_usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* SpaceManager::grow_and_allocate(size_t word_size) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
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(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t words_left = 0;
|
|
|
|
size_t words_used = 0;
|
|
|
|
if (current_chunk() != NULL) {
|
|
|
|
words_left = current_chunk()->free_word_size();
|
|
|
|
words_used = current_chunk()->used_word_size();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
gclog_or_tty->print_cr("SpaceManager::grow_and_allocate for " SIZE_FORMAT
|
2012-12-03 15:09:39 -08:00
|
|
|
" words " SIZE_FORMAT " words used " SIZE_FORMAT
|
|
|
|
" words left",
|
|
|
|
word_size, words_used, words_left);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get another chunk out of the virtual space
|
|
|
|
size_t grow_chunks_by_words = calc_chunk_size(word_size);
|
2012-12-03 15:09:39 -08:00
|
|
|
Metachunk* next = get_new_chunk(word_size, grow_chunks_by_words);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
if (next != NULL) {
|
|
|
|
Metadebug::deallocate_chunk_a_lot(this, grow_chunks_by_words);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaWord* mem = NULL;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// If a chunk was available, add it to the in-use chunk list
|
|
|
|
// and do an allocation from it.
|
|
|
|
if (next != NULL) {
|
|
|
|
// Add to this manager's list of chunks in use.
|
|
|
|
add_chunk(next, false);
|
2013-10-07 15:51:08 +02:00
|
|
|
mem = next->allocate(word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
2013-10-07 15:51:17 +02:00
|
|
|
// Track metaspace memory usage statistic.
|
|
|
|
track_metaspace_memory_usage();
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
return mem;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpaceManager::print_on(outputStream* st) const {
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex;
|
2012-09-18 23:35:42 -07:00
|
|
|
i < NumberOfInUseLists ;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
i = next_chunk_index(i) ) {
|
|
|
|
st->print_cr(" chunks_in_use " PTR_FORMAT " chunk size " PTR_FORMAT,
|
|
|
|
chunks_in_use(i),
|
|
|
|
chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size());
|
|
|
|
}
|
|
|
|
st->print_cr(" waste: Small " SIZE_FORMAT " Medium " SIZE_FORMAT
|
|
|
|
" Humongous " SIZE_FORMAT,
|
|
|
|
sum_waste_in_chunks_in_use(SmallIndex),
|
|
|
|
sum_waste_in_chunks_in_use(MediumIndex),
|
|
|
|
sum_waste_in_chunks_in_use(HumongousIndex));
|
2012-09-18 23:35:42 -07:00
|
|
|
// block free lists
|
|
|
|
if (block_freelists() != NULL) {
|
|
|
|
st->print_cr("total in block free lists " SIZE_FORMAT,
|
|
|
|
block_freelists()->total_size());
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
SpaceManager::SpaceManager(Metaspace::MetadataType mdtype,
|
2013-09-21 10:09:42 +02:00
|
|
|
Mutex* lock) :
|
2013-05-20 22:34:24 -07:00
|
|
|
_mdtype(mdtype),
|
2013-02-12 14:15:45 -08:00
|
|
|
_allocated_blocks_words(0),
|
|
|
|
_allocated_chunks_words(0),
|
|
|
|
_allocated_chunks_count(0),
|
2012-12-03 15:09:39 -08:00
|
|
|
_lock(lock)
|
|
|
|
{
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
void SpaceManager::inc_size_metrics(size_t words) {
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
// Total of allocated Metachunks and allocated Metachunks count
|
|
|
|
// for each SpaceManager
|
|
|
|
_allocated_chunks_words = _allocated_chunks_words + words;
|
|
|
|
_allocated_chunks_count++;
|
|
|
|
// Global total of capacity in allocated Metachunks
|
2013-05-20 22:34:24 -07:00
|
|
|
MetaspaceAux::inc_capacity(mdtype(), words);
|
2013-02-12 14:15:45 -08:00
|
|
|
// Global total of allocated Metablocks.
|
|
|
|
// used_words_slow() includes the overhead in each
|
|
|
|
// Metachunk so include it in the used when the
|
|
|
|
// Metachunk is first added (so only added once per
|
|
|
|
// Metachunk).
|
2013-05-20 22:34:24 -07:00
|
|
|
MetaspaceAux::inc_used(mdtype(), Metachunk::overhead());
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpaceManager::inc_used_metrics(size_t words) {
|
|
|
|
// Add to the per SpaceManager total
|
|
|
|
Atomic::add_ptr(words, &_allocated_blocks_words);
|
|
|
|
// Add to the global total
|
2013-05-20 22:34:24 -07:00
|
|
|
MetaspaceAux::inc_used(mdtype(), words);
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpaceManager::dec_total_from_size_metrics() {
|
2013-05-20 22:34:24 -07:00
|
|
|
MetaspaceAux::dec_capacity(mdtype(), allocated_chunks_words());
|
|
|
|
MetaspaceAux::dec_used(mdtype(), allocated_blocks_words());
|
2013-02-12 14:15:45 -08:00
|
|
|
// Also deduct the overhead per Metachunk
|
2013-05-20 22:34:24 -07:00
|
|
|
MetaspaceAux::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead());
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
void SpaceManager::initialize() {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metadebug::init_allocation_fail_alot_count();
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_chunks_in_use[i] = NULL;
|
|
|
|
}
|
|
|
|
_current_chunk = NULL;
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-01 10:50:30 -07:00
|
|
|
void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) {
|
|
|
|
if (chunks == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ChunkList* list = free_chunks(index);
|
|
|
|
assert(list->size() == chunks->word_size(), "Mismatch in chunk sizes");
|
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
Metachunk* cur = chunks;
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
// This returns chunks one at a time. If a new
|
2013-04-01 10:50:30 -07:00
|
|
|
// class List can be created that is a base class
|
|
|
|
// of FreeList then something like FreeList::prepend()
|
|
|
|
// can be used in place of this loop
|
|
|
|
while (cur != NULL) {
|
2013-03-01 10:19:29 -08:00
|
|
|
assert(cur->container() != NULL, "Container should have been set");
|
|
|
|
cur->container()->dec_container_count();
|
2013-04-01 10:50:30 -07:00
|
|
|
// Capture the next link before it is changed
|
|
|
|
// by the call to return_chunk_at_head();
|
|
|
|
Metachunk* next = cur->next();
|
|
|
|
cur->set_is_free(true);
|
|
|
|
list->return_chunk_at_head(cur);
|
|
|
|
cur = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
SpaceManager::~SpaceManager() {
|
2013-03-14 10:54:44 +01:00
|
|
|
// This call this->_lock which can't be done while holding expand_lock()
|
2013-02-12 14:15:45 -08:00
|
|
|
assert(sum_capacity_in_chunks_in_use() == allocated_chunks_words(),
|
|
|
|
err_msg("sum_capacity_in_chunks_in_use() " SIZE_FORMAT
|
|
|
|
" allocated_chunks_words() " SIZE_FORMAT,
|
|
|
|
sum_capacity_in_chunks_in_use(), allocated_chunks_words()));
|
2013-03-14 10:54:44 +01:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MutexLockerEx fcl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
dec_total_from_size_metrics();
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this);
|
|
|
|
locked_print_chunks_in_use_on(gclog_or_tty);
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
// Do not mangle freed Metachunks. The chunk size inside Metachunks
|
|
|
|
// is during the freeing of a VirtualSpaceNodes.
|
2012-11-29 16:50:29 -05:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Have to update before the chunks_in_use lists are emptied
|
|
|
|
// below.
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->inc_free_chunks_total(allocated_chunks_words(),
|
|
|
|
sum_count_in_chunks_in_use());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Add all the chunks in use by this space manager
|
|
|
|
// to the global list of free chunks.
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// Follow each list of chunks-in-use and add them to the
|
|
|
|
// free lists. Each list is NULL terminated.
|
|
|
|
|
|
|
|
for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("returned %d %s chunks to freelist",
|
|
|
|
sum_count_in_chunks_in_use(i),
|
|
|
|
chunk_size_name(i));
|
|
|
|
}
|
|
|
|
Metachunk* chunks = chunks_in_use(i);
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->return_chunks(i, chunks);
|
2012-12-03 15:09:39 -08:00
|
|
|
set_chunks_in_use(i, NULL);
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("updated freelist count %d %s",
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->free_chunks(i)->count(),
|
2012-12-03 15:09:39 -08:00
|
|
|
chunk_size_name(i));
|
|
|
|
}
|
|
|
|
assert(i != HumongousIndex, "Humongous chunks are handled explicitly later");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// The medium chunk case may be optimized by passing the head and
|
|
|
|
// tail of the medium chunk list to add_at_head(). The tail is often
|
|
|
|
// the current chunk but there are probably exceptions.
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Humongous chunks
|
2012-12-03 15:09:39 -08:00
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("returned %d %s humongous chunks to dictionary",
|
|
|
|
sum_count_in_chunks_in_use(HumongousIndex),
|
|
|
|
chunk_size_name(HumongousIndex));
|
|
|
|
gclog_or_tty->print("Humongous chunk dictionary: ");
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Humongous chunks are never the current chunk.
|
|
|
|
Metachunk* humongous_chunks = chunks_in_use(HumongousIndex);
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
while (humongous_chunks != NULL) {
|
|
|
|
#ifdef ASSERT
|
|
|
|
humongous_chunks->set_is_free(true);
|
|
|
|
#endif
|
2012-12-03 15:09:39 -08:00
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
|
|
|
|
humongous_chunks,
|
|
|
|
humongous_chunks->word_size());
|
|
|
|
}
|
|
|
|
assert(humongous_chunks->word_size() == (size_t)
|
|
|
|
align_size_up(humongous_chunks->word_size(),
|
|
|
|
HumongousChunkGranularity),
|
|
|
|
err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
|
2013-02-01 17:21:53 -08:00
|
|
|
" granularity %d",
|
2012-12-03 15:09:39 -08:00
|
|
|
humongous_chunks->word_size(), HumongousChunkGranularity));
|
2012-09-18 23:35:42 -07:00
|
|
|
Metachunk* next_humongous_chunks = humongous_chunks->next();
|
2013-03-01 10:19:29 -08:00
|
|
|
humongous_chunks->container()->dec_container_count();
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks);
|
2012-09-18 23:35:42 -07:00
|
|
|
humongous_chunks = next_humongous_chunks;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-12-03 15:09:39 -08:00
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("");
|
|
|
|
gclog_or_tty->print_cr("updated dictionary count %d %s",
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->humongous_dictionary()->total_count(),
|
2012-12-03 15:09:39 -08:00
|
|
|
chunk_size_name(HumongousIndex));
|
|
|
|
}
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->slow_locked_verify();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
|
|
|
|
switch (index) {
|
|
|
|
case SpecializedIndex:
|
|
|
|
return "Specialized";
|
|
|
|
case SmallIndex:
|
|
|
|
return "Small";
|
|
|
|
case MediumIndex:
|
|
|
|
return "Medium";
|
|
|
|
case HumongousIndex:
|
|
|
|
return "Humongous";
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ChunkIndex ChunkManager::list_index(size_t size) {
|
|
|
|
switch (size) {
|
|
|
|
case SpecializedChunk:
|
|
|
|
assert(SpecializedChunk == ClassSpecializedChunk,
|
|
|
|
"Need branch for ClassSpecializedChunk");
|
|
|
|
return SpecializedIndex;
|
|
|
|
case SmallChunk:
|
|
|
|
case ClassSmallChunk:
|
|
|
|
return SmallIndex;
|
|
|
|
case MediumChunk:
|
|
|
|
case ClassMediumChunk:
|
|
|
|
return MediumIndex;
|
|
|
|
default:
|
2012-12-26 15:05:30 -08:00
|
|
|
assert(size > MediumChunk || size > ClassMediumChunk,
|
2012-12-03 15:09:39 -08:00
|
|
|
"Not a humongous chunk");
|
|
|
|
return HumongousIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert_lock_strong(_lock);
|
2013-07-26 15:24:32 +00:00
|
|
|
size_t raw_word_size = get_raw_word_size(word_size);
|
2012-09-18 23:35:42 -07:00
|
|
|
size_t min_size = TreeChunk<Metablock, FreeList>::min_size();
|
2013-07-26 15:24:32 +00:00
|
|
|
assert(raw_word_size >= min_size,
|
2013-08-15 20:04:10 -04:00
|
|
|
err_msg("Should not deallocate dark matter " SIZE_FORMAT "<" SIZE_FORMAT, word_size, min_size));
|
2013-07-26 15:24:32 +00:00
|
|
|
block_freelists()->return_block(p, raw_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Adds a chunk to the list of chunks in use.
|
|
|
|
void SpaceManager::add_chunk(Metachunk* new_chunk, bool make_current) {
|
|
|
|
|
|
|
|
assert(new_chunk != NULL, "Should not be NULL");
|
|
|
|
assert(new_chunk->next() == NULL, "Should not be on a list");
|
|
|
|
|
|
|
|
new_chunk->reset_empty();
|
|
|
|
|
|
|
|
// Find the correct list and and set the current
|
|
|
|
// chunk for that list.
|
2012-12-03 15:09:39 -08:00
|
|
|
ChunkIndex index = ChunkManager::list_index(new_chunk->word_size());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
if (index != HumongousIndex) {
|
2013-09-11 09:37:14 +02:00
|
|
|
retire_current_chunk();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_current_chunk(new_chunk);
|
2012-12-03 15:09:39 -08:00
|
|
|
new_chunk->set_next(chunks_in_use(index));
|
|
|
|
set_chunks_in_use(index, new_chunk);
|
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// For null class loader data and DumpSharedSpaces, the first chunk isn't
|
|
|
|
// small, so small will be null. Link this first chunk as the current
|
|
|
|
// chunk.
|
|
|
|
if (make_current) {
|
|
|
|
// Set as the current chunk but otherwise treat as a humongous chunk.
|
|
|
|
set_current_chunk(new_chunk);
|
|
|
|
}
|
|
|
|
// Link at head. The _current_chunk only points to a humongous chunk for
|
|
|
|
// the null class loader metaspace (class and data virtual space managers)
|
|
|
|
// any humongous chunks so will not point to the tail
|
|
|
|
// of the humongous chunks list.
|
|
|
|
new_chunk->set_next(chunks_in_use(HumongousIndex));
|
|
|
|
set_chunks_in_use(HumongousIndex, new_chunk);
|
|
|
|
|
2012-12-26 15:05:30 -08:00
|
|
|
assert(new_chunk->word_size() > medium_chunk_size(), "List inconsistency");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
// Add to the running sum of capacity
|
|
|
|
inc_size_metrics(new_chunk->word_size());
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(new_chunk->is_empty(), "Not ready for reuse");
|
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print("SpaceManager::add_chunk: %d) ",
|
|
|
|
sum_count_in_chunks_in_use());
|
|
|
|
new_chunk->print_on(gclog_or_tty);
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager()->locked_print_free_chunks(gclog_or_tty);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 09:37:14 +02:00
|
|
|
void SpaceManager::retire_current_chunk() {
|
|
|
|
if (current_chunk() != NULL) {
|
|
|
|
size_t remaining_words = current_chunk()->free_word_size();
|
|
|
|
if (remaining_words >= TreeChunk<Metablock, FreeList>::min_size()) {
|
|
|
|
block_freelists()->return_block(current_chunk()->allocate(remaining_words), remaining_words);
|
|
|
|
inc_used_metrics(remaining_words);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
Metachunk* SpaceManager::get_new_chunk(size_t word_size,
|
|
|
|
size_t grow_chunks_by_words) {
|
2013-09-21 10:09:42 +02:00
|
|
|
// Get a chunk from the chunk freelist
|
|
|
|
Metachunk* next = chunk_manager()->chunk_freelist_allocate(grow_chunks_by_words);
|
2012-12-03 15:09:39 -08:00
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
if (next == NULL) {
|
|
|
|
next = vs_list()->get_new_chunk(word_size,
|
|
|
|
grow_chunks_by_words,
|
|
|
|
medium_chunk_bunch());
|
|
|
|
}
|
2012-12-03 15:09:39 -08:00
|
|
|
|
2013-09-13 22:23:48 +02:00
|
|
|
if (TraceMetadataHumongousAllocation && next != NULL &&
|
2012-12-03 15:09:39 -08:00
|
|
|
SpaceManager::is_humongous(next->word_size())) {
|
2013-09-13 22:23:48 +02:00
|
|
|
gclog_or_tty->print_cr(" new humongous chunk word size "
|
|
|
|
PTR_FORMAT, next->word_size());
|
2012-12-03 15:09:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MetaWord* SpaceManager::allocate(size_t word_size) {
|
|
|
|
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
|
2013-05-28 16:36:19 -07:00
|
|
|
size_t raw_word_size = get_raw_word_size(word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
BlockFreelist* fl = block_freelists();
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* p = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Allocation from the dictionary is expensive in the sense that
|
|
|
|
// the dictionary has to be searched for a size. Don't allocate
|
|
|
|
// from the dictionary until it starts to get fat. Is this
|
|
|
|
// a reasonable policy? Maybe an skinny dictionary is fast enough
|
|
|
|
// for allocations. Do some profiling. JJJ
|
2012-09-18 23:35:42 -07:00
|
|
|
if (fl->total_size() > allocation_from_dictionary_limit) {
|
|
|
|
p = fl->get_block(raw_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
if (p == NULL) {
|
|
|
|
p = allocate_work(raw_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
Metadebug::deallocate_block_a_lot(this, raw_word_size);
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
return p;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the address of spaced allocated for "word_size".
|
|
|
|
// This methods does not know about blocks (Metablocks)
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* SpaceManager::allocate_work(size_t word_size) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert_lock_strong(_lock);
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (Metadebug::test_metadata_failure()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// Is there space in the current chunk?
|
2012-09-18 23:35:42 -07:00
|
|
|
MetaWord* result = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// For DumpSharedSpaces, only allocate out of the current chunk which is
|
|
|
|
// never null because we gave it the size we wanted. Caller reports out
|
|
|
|
// of memory if this returns null.
|
|
|
|
if (DumpSharedSpaces) {
|
|
|
|
assert(current_chunk() != NULL, "should never happen");
|
2013-02-12 14:15:45 -08:00
|
|
|
inc_used_metrics(word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return current_chunk()->allocate(word_size); // caller handles null result
|
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (current_chunk() != NULL) {
|
|
|
|
result = current_chunk()->allocate(word_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == NULL) {
|
|
|
|
result = grow_and_allocate(word_size);
|
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
if (result != NULL) {
|
2013-02-12 14:15:45 -08:00
|
|
|
inc_used_metrics(word_size);
|
2012-09-18 23:35:42 -07:00
|
|
|
assert(result != (MetaWord*) chunks_in_use(MediumIndex),
|
|
|
|
"Head of the list is being allocated");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpaceManager::verify() {
|
|
|
|
// If there are blocks in the dictionary, then
|
|
|
|
// verfication of chunks does not work since
|
|
|
|
// being in the dictionary alters a chunk.
|
2012-09-18 23:35:42 -07:00
|
|
|
if (block_freelists()->total_size() == 0) {
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Metachunk* curr = chunks_in_use(i);
|
|
|
|
while (curr != NULL) {
|
|
|
|
curr->verify();
|
2012-11-29 10:09:04 -08:00
|
|
|
verify_chunk_size(curr);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
curr = curr->next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-29 10:09:04 -08:00
|
|
|
void SpaceManager::verify_chunk_size(Metachunk* chunk) {
|
|
|
|
assert(is_humongous(chunk->word_size()) ||
|
2012-12-03 15:09:39 -08:00
|
|
|
chunk->word_size() == medium_chunk_size() ||
|
|
|
|
chunk->word_size() == small_chunk_size() ||
|
|
|
|
chunk->word_size() == specialized_chunk_size(),
|
2012-11-29 10:09:04 -08:00
|
|
|
"Chunk size is wrong");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#ifdef ASSERT
|
2013-02-12 14:15:45 -08:00
|
|
|
void SpaceManager::verify_allocated_blocks_words() {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Verification is only guaranteed at a safepoint.
|
2013-02-12 14:15:45 -08:00
|
|
|
assert(SafepointSynchronize::is_at_safepoint() || !Universe::is_fully_initialized(),
|
|
|
|
"Verification can fail if the applications is running");
|
|
|
|
assert(allocated_blocks_words() == sum_used_in_chunks_in_use(),
|
2013-02-01 17:21:53 -08:00
|
|
|
err_msg("allocation total is not consistent " SIZE_FORMAT
|
|
|
|
" vs " SIZE_FORMAT,
|
2013-02-12 14:15:45 -08:00
|
|
|
allocated_blocks_words(), sum_used_in_chunks_in_use()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void SpaceManager::dump(outputStream* const out) const {
|
|
|
|
size_t curr_total = 0;
|
|
|
|
size_t waste = 0;
|
|
|
|
uint i = 0;
|
|
|
|
size_t used = 0;
|
|
|
|
size_t capacity = 0;
|
|
|
|
|
|
|
|
// Add up statistics for all chunks in this SpaceManager.
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex index = ZeroIndex;
|
2012-09-18 23:35:42 -07:00
|
|
|
index < NumberOfInUseLists;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
index = next_chunk_index(index)) {
|
|
|
|
for (Metachunk* curr = chunks_in_use(index);
|
|
|
|
curr != NULL;
|
|
|
|
curr = curr->next()) {
|
|
|
|
out->print("%d) ", i++);
|
|
|
|
curr->print_on(out);
|
|
|
|
curr_total += curr->word_size();
|
|
|
|
used += curr->used_word_size();
|
|
|
|
capacity += curr->capacity_word_size();
|
|
|
|
waste += curr->free_word_size() + curr->overhead();;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 22:23:48 +02:00
|
|
|
if (TraceMetadataChunkAllocation && Verbose) {
|
|
|
|
block_freelists()->print_on(out);
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Free space isn't wasted.
|
|
|
|
waste -= free;
|
|
|
|
|
|
|
|
out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT
|
|
|
|
" free " SIZE_FORMAT " capacity " SIZE_FORMAT
|
|
|
|
" waste " SIZE_FORMAT, curr_total, used, free, capacity, waste);
|
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
#ifndef PRODUCT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void SpaceManager::mangle_freed_chunks() {
|
2012-12-03 15:09:39 -08:00
|
|
|
for (ChunkIndex index = ZeroIndex;
|
2012-09-18 23:35:42 -07:00
|
|
|
index < NumberOfInUseLists;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
index = next_chunk_index(index)) {
|
|
|
|
for (Metachunk* curr = chunks_in_use(index);
|
|
|
|
curr != NULL;
|
|
|
|
curr = curr->next()) {
|
|
|
|
curr->mangle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-29 16:50:29 -05:00
|
|
|
#endif // PRODUCT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// MetaspaceAux
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
size_t MetaspaceAux::_allocated_capacity_words[] = {0, 0};
|
|
|
|
size_t MetaspaceAux::_allocated_used_words[] = {0, 0};
|
2013-02-12 14:15:45 -08:00
|
|
|
|
2013-08-07 16:47:32 +02:00
|
|
|
size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) {
|
|
|
|
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
|
|
|
|
return list == NULL ? 0 : list->free_bytes();
|
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t MetaspaceAux::free_bytes() {
|
2013-08-07 16:47:32 +02:00
|
|
|
return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType);
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
|
2013-02-12 14:15:45 -08:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
2013-05-20 22:34:24 -07:00
|
|
|
assert(words <= allocated_capacity_words(mdtype),
|
2013-02-12 14:15:45 -08:00
|
|
|
err_msg("About to decrement below 0: words " SIZE_FORMAT
|
2013-05-20 22:34:24 -07:00
|
|
|
" is greater than _allocated_capacity_words[%u] " SIZE_FORMAT,
|
|
|
|
words, mdtype, allocated_capacity_words(mdtype)));
|
|
|
|
_allocated_capacity_words[mdtype] -= words;
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
|
2013-02-12 14:15:45 -08:00
|
|
|
assert_lock_strong(SpaceManager::expand_lock());
|
|
|
|
// Needs to be atomic
|
2013-05-20 22:34:24 -07:00
|
|
|
_allocated_capacity_words[mdtype] += words;
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) {
|
|
|
|
assert(words <= allocated_used_words(mdtype),
|
2013-02-12 14:15:45 -08:00
|
|
|
err_msg("About to decrement below 0: words " SIZE_FORMAT
|
2013-05-20 22:34:24 -07:00
|
|
|
" is greater than _allocated_used_words[%u] " SIZE_FORMAT,
|
|
|
|
words, mdtype, allocated_used_words(mdtype)));
|
2013-02-12 14:15:45 -08:00
|
|
|
// For CMS deallocation of the Metaspaces occurs during the
|
|
|
|
// sweep which is a concurrent phase. Protection by the expand_lock()
|
|
|
|
// is not enough since allocation is on a per Metaspace basis
|
|
|
|
// and protected by the Metaspace lock.
|
|
|
|
jlong minus_words = (jlong) - (jlong) words;
|
2013-05-20 22:34:24 -07:00
|
|
|
Atomic::add_ptr(minus_words, &_allocated_used_words[mdtype]);
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
2013-05-20 22:34:24 -07:00
|
|
|
void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) {
|
2013-02-12 14:15:45 -08:00
|
|
|
// _allocated_used_words tracks allocations for
|
|
|
|
// each piece of metadata. Those allocations are
|
|
|
|
// generally done concurrently by different application
|
|
|
|
// threads so must be done atomically.
|
2013-05-20 22:34:24 -07:00
|
|
|
Atomic::add_ptr(words, &_allocated_used_words[mdtype]);
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
size_t used = 0;
|
|
|
|
ClassLoaderDataGraphMetaspaceIterator iter;
|
|
|
|
while (iter.repeat()) {
|
|
|
|
Metaspace* msp = iter.get_next();
|
2013-02-12 14:15:45 -08:00
|
|
|
// Sum allocated_blocks_words for each metaspace
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (msp != NULL) {
|
2013-02-12 14:15:45 -08:00
|
|
|
used += msp->used_words_slow(mdtype);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return used * BytesPerWord;
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::free_bytes_slow(Metaspace::MetadataType mdtype) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
size_t free = 0;
|
|
|
|
ClassLoaderDataGraphMetaspaceIterator iter;
|
|
|
|
while (iter.repeat()) {
|
|
|
|
Metaspace* msp = iter.get_next();
|
|
|
|
if (msp != NULL) {
|
2013-09-12 10:15:30 +02:00
|
|
|
free += msp->free_words_slow(mdtype);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return free * BytesPerWord;
|
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t MetaspaceAux::capacity_bytes_slow(Metaspace::MetadataType mdtype) {
|
2013-08-15 20:04:10 -04:00
|
|
|
if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-02-12 14:15:45 -08:00
|
|
|
// Don't count the space in the freelists. That space will be
|
|
|
|
// added to the capacity calculation as needed.
|
|
|
|
size_t capacity = 0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ClassLoaderDataGraphMetaspaceIterator iter;
|
|
|
|
while (iter.repeat()) {
|
|
|
|
Metaspace* msp = iter.get_next();
|
|
|
|
if (msp != NULL) {
|
2013-02-12 14:15:45 -08:00
|
|
|
capacity += msp->capacity_words_slow(mdtype);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return capacity * BytesPerWord;
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::capacity_bytes_slow() {
|
|
|
|
#ifdef PRODUCT
|
|
|
|
// Use allocated_capacity_bytes() in PRODUCT instead of this function.
|
|
|
|
guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
|
|
|
|
#endif
|
|
|
|
size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
|
|
|
|
size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType);
|
|
|
|
assert(allocated_capacity_bytes() == class_capacity + non_class_capacity,
|
|
|
|
err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT
|
|
|
|
" class_capacity + non_class_capacity " SIZE_FORMAT
|
|
|
|
" class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT,
|
|
|
|
allocated_capacity_bytes(), class_capacity + non_class_capacity,
|
|
|
|
class_capacity, non_class_capacity));
|
|
|
|
|
|
|
|
return class_capacity + non_class_capacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) {
|
2013-08-07 16:47:32 +02:00
|
|
|
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
|
2013-09-12 10:15:54 +02:00
|
|
|
return list == NULL ? 0 : list->reserved_bytes();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t MetaspaceAux::committed_bytes(Metaspace::MetadataType mdtype) {
|
|
|
|
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
|
|
|
|
return list == NULL ? 0 : list->committed_bytes();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) {
|
2013-09-21 10:09:42 +02:00
|
|
|
ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype);
|
|
|
|
if (chunk_manager == NULL) {
|
2013-08-15 20:04:10 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2013-09-21 10:09:42 +02:00
|
|
|
chunk_manager->slow_verify();
|
|
|
|
return chunk_manager->free_chunks_total_words();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) {
|
|
|
|
return free_chunks_total_words(mdtype) * BytesPerWord;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::free_chunks_total_words() {
|
|
|
|
return free_chunks_total_words(Metaspace::ClassType) +
|
|
|
|
free_chunks_total_words(Metaspace::NonClassType);
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t MetaspaceAux::free_chunks_total_bytes() {
|
|
|
|
return free_chunks_total_words() * BytesPerWord;
|
2013-02-12 14:15:45 -08:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
|
|
|
|
gclog_or_tty->print(", [Metaspace:");
|
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
gclog_or_tty->print(" " SIZE_FORMAT
|
|
|
|
"->" SIZE_FORMAT
|
2013-02-12 14:15:45 -08:00
|
|
|
"(" SIZE_FORMAT ")",
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
prev_metadata_used,
|
2013-06-25 09:58:26 -07:00
|
|
|
allocated_used_bytes(),
|
2013-09-12 10:15:30 +02:00
|
|
|
reserved_bytes());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
|
|
|
gclog_or_tty->print(" " SIZE_FORMAT "K"
|
|
|
|
"->" SIZE_FORMAT "K"
|
2013-02-12 14:15:45 -08:00
|
|
|
"(" SIZE_FORMAT "K)",
|
2013-09-12 10:15:30 +02:00
|
|
|
prev_metadata_used/K,
|
|
|
|
allocated_used_bytes()/K,
|
|
|
|
reserved_bytes()/K);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gclog_or_tty->print("]");
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is printed when PrintGCDetails
|
|
|
|
void MetaspaceAux::print_on(outputStream* out) {
|
|
|
|
Metaspace::MetadataType nct = Metaspace::NonClassType;
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
out->print_cr(" Metaspace "
|
|
|
|
"used " SIZE_FORMAT "K, "
|
|
|
|
"capacity " SIZE_FORMAT "K, "
|
|
|
|
"committed " SIZE_FORMAT "K, "
|
|
|
|
"reserved " SIZE_FORMAT "K",
|
|
|
|
allocated_used_bytes()/K,
|
|
|
|
allocated_capacity_bytes()/K,
|
|
|
|
committed_bytes()/K,
|
|
|
|
reserved_bytes()/K);
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
if (Metaspace::using_class_space()) {
|
|
|
|
Metaspace::MetadataType ct = Metaspace::ClassType;
|
|
|
|
out->print_cr(" class space "
|
2013-10-07 15:51:08 +02:00
|
|
|
"used " SIZE_FORMAT "K, "
|
|
|
|
"capacity " SIZE_FORMAT "K, "
|
|
|
|
"committed " SIZE_FORMAT "K, "
|
|
|
|
"reserved " SIZE_FORMAT "K",
|
2013-08-15 20:04:10 -04:00
|
|
|
allocated_used_bytes(ct)/K,
|
2013-10-07 15:51:08 +02:00
|
|
|
allocated_capacity_bytes(ct)/K,
|
|
|
|
committed_bytes(ct)/K,
|
2013-09-12 10:15:30 +02:00
|
|
|
reserved_bytes(ct)/K);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print information for class space and data space separately.
|
|
|
|
// This is almost the same as above.
|
|
|
|
void MetaspaceAux::print_on(outputStream* out, Metaspace::MetadataType mdtype) {
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype);
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t capacity_bytes = capacity_bytes_slow(mdtype);
|
|
|
|
size_t used_bytes = used_bytes_slow(mdtype);
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t free_bytes = free_bytes_slow(mdtype);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
size_t used_and_free = used_bytes + free_bytes +
|
|
|
|
free_chunks_capacity_bytes;
|
|
|
|
out->print_cr(" Chunk accounting: used in chunks " SIZE_FORMAT
|
|
|
|
"K + unused in chunks " SIZE_FORMAT "K + "
|
|
|
|
" capacity in free chunks " SIZE_FORMAT "K = " SIZE_FORMAT
|
|
|
|
"K capacity in allocated chunks " SIZE_FORMAT "K",
|
|
|
|
used_bytes / K,
|
|
|
|
free_bytes / K,
|
|
|
|
free_chunks_capacity_bytes / K,
|
|
|
|
used_and_free / K,
|
|
|
|
capacity_bytes / K);
|
2013-03-12 09:42:24 +01:00
|
|
|
// Accounting can only be correct if we got the values during a safepoint
|
|
|
|
assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
// Print total fragmentation for class metaspaces
|
|
|
|
void MetaspaceAux::print_class_waste(outputStream* out) {
|
|
|
|
assert(Metaspace::using_class_space(), "class metaspace not used");
|
|
|
|
size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0;
|
|
|
|
size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0;
|
|
|
|
ClassLoaderDataGraphMetaspaceIterator iter;
|
|
|
|
while (iter.repeat()) {
|
|
|
|
Metaspace* msp = iter.get_next();
|
|
|
|
if (msp != NULL) {
|
|
|
|
cls_specialized_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SpecializedIndex);
|
|
|
|
cls_specialized_count += msp->class_vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
|
|
|
|
cls_small_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SmallIndex);
|
|
|
|
cls_small_count += msp->class_vsm()->sum_count_in_chunks_in_use(SmallIndex);
|
|
|
|
cls_medium_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(MediumIndex);
|
|
|
|
cls_medium_count += msp->class_vsm()->sum_count_in_chunks_in_use(MediumIndex);
|
|
|
|
cls_humongous_count += msp->class_vsm()->sum_count_in_chunks_in_use(HumongousIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out->print_cr(" class: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
|
|
|
|
SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
|
|
|
|
SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
|
|
|
|
"large count " SIZE_FORMAT,
|
|
|
|
cls_specialized_count, cls_specialized_waste,
|
|
|
|
cls_small_count, cls_small_waste,
|
|
|
|
cls_medium_count, cls_medium_waste, cls_humongous_count);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
// Print total fragmentation for data and class metaspaces separately
|
|
|
|
void MetaspaceAux::print_waste(outputStream* out) {
|
2013-07-02 08:42:37 -04:00
|
|
|
size_t specialized_waste = 0, small_waste = 0, medium_waste = 0;
|
|
|
|
size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
ClassLoaderDataGraphMetaspaceIterator iter;
|
|
|
|
while (iter.repeat()) {
|
|
|
|
Metaspace* msp = iter.get_next();
|
|
|
|
if (msp != NULL) {
|
2012-12-03 15:09:39 -08:00
|
|
|
specialized_waste += msp->vsm()->sum_waste_in_chunks_in_use(SpecializedIndex);
|
|
|
|
specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex);
|
2012-12-03 15:09:39 -08:00
|
|
|
small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex);
|
2012-12-03 15:09:39 -08:00
|
|
|
medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex);
|
2013-07-02 08:42:37 -04:00
|
|
|
humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
out->print_cr("Total fragmentation waste (words) doesn't count free space");
|
2012-12-03 15:09:39 -08:00
|
|
|
out->print_cr(" data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
|
|
|
|
SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
|
2013-07-02 08:42:37 -04:00
|
|
|
SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
|
|
|
|
"large count " SIZE_FORMAT,
|
2012-12-03 15:09:39 -08:00
|
|
|
specialized_count, specialized_waste, small_count,
|
2013-07-02 08:42:37 -04:00
|
|
|
small_waste, medium_count, medium_waste, humongous_count);
|
2013-08-15 20:04:10 -04:00
|
|
|
if (Metaspace::using_class_space()) {
|
|
|
|
print_class_waste(out);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dump global metaspace things from the end of ClassLoaderDataGraph
|
|
|
|
void MetaspaceAux::dump(outputStream* out) {
|
|
|
|
out->print_cr("All Metaspace:");
|
|
|
|
out->print("data space: "); print_on(out, Metaspace::NonClassType);
|
|
|
|
out->print("class space: "); print_on(out, Metaspace::ClassType);
|
|
|
|
print_waste(out);
|
|
|
|
}
|
|
|
|
|
2012-11-09 00:38:31 +01:00
|
|
|
void MetaspaceAux::verify_free_chunks() {
|
2013-09-21 10:09:42 +02:00
|
|
|
Metaspace::chunk_manager_metadata()->verify();
|
2013-08-15 20:04:10 -04:00
|
|
|
if (Metaspace::using_class_space()) {
|
2013-09-21 10:09:42 +02:00
|
|
|
Metaspace::chunk_manager_class()->verify();
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
2012-11-09 00:38:31 +01:00
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
void MetaspaceAux::verify_capacity() {
|
|
|
|
#ifdef ASSERT
|
|
|
|
size_t running_sum_capacity_bytes = allocated_capacity_bytes();
|
2013-05-20 22:34:24 -07:00
|
|
|
// For purposes of the running sum of capacity, verify against capacity
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t capacity_in_use_bytes = capacity_bytes_slow();
|
|
|
|
assert(running_sum_capacity_bytes == capacity_in_use_bytes,
|
|
|
|
err_msg("allocated_capacity_words() * BytesPerWord " SIZE_FORMAT
|
|
|
|
" capacity_bytes_slow()" SIZE_FORMAT,
|
|
|
|
running_sum_capacity_bytes, capacity_in_use_bytes));
|
2013-05-20 22:34:24 -07:00
|
|
|
for (Metaspace::MetadataType i = Metaspace::ClassType;
|
|
|
|
i < Metaspace:: MetadataTypeCount;
|
|
|
|
i = (Metaspace::MetadataType)(i + 1)) {
|
|
|
|
size_t capacity_in_use_bytes = capacity_bytes_slow(i);
|
|
|
|
assert(allocated_capacity_bytes(i) == capacity_in_use_bytes,
|
|
|
|
err_msg("allocated_capacity_bytes(%u) " SIZE_FORMAT
|
|
|
|
" capacity_bytes_slow(%u)" SIZE_FORMAT,
|
|
|
|
i, allocated_capacity_bytes(i), i, capacity_in_use_bytes));
|
|
|
|
}
|
2013-02-12 14:15:45 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaspaceAux::verify_used() {
|
|
|
|
#ifdef ASSERT
|
|
|
|
size_t running_sum_used_bytes = allocated_used_bytes();
|
2013-05-20 22:34:24 -07:00
|
|
|
// For purposes of the running sum of used, verify against used
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t used_in_use_bytes = used_bytes_slow();
|
|
|
|
assert(allocated_used_bytes() == used_in_use_bytes,
|
|
|
|
err_msg("allocated_used_bytes() " SIZE_FORMAT
|
2013-05-20 22:34:24 -07:00
|
|
|
" used_bytes_slow()" SIZE_FORMAT,
|
2013-02-12 14:15:45 -08:00
|
|
|
allocated_used_bytes(), used_in_use_bytes));
|
2013-05-20 22:34:24 -07:00
|
|
|
for (Metaspace::MetadataType i = Metaspace::ClassType;
|
|
|
|
i < Metaspace:: MetadataTypeCount;
|
|
|
|
i = (Metaspace::MetadataType)(i + 1)) {
|
|
|
|
size_t used_in_use_bytes = used_bytes_slow(i);
|
|
|
|
assert(allocated_used_bytes(i) == used_in_use_bytes,
|
|
|
|
err_msg("allocated_used_bytes(%u) " SIZE_FORMAT
|
|
|
|
" used_bytes_slow(%u)" SIZE_FORMAT,
|
|
|
|
i, allocated_used_bytes(i), i, used_in_use_bytes));
|
|
|
|
}
|
2013-02-12 14:15:45 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaspaceAux::verify_metrics() {
|
|
|
|
verify_capacity();
|
|
|
|
verify_used();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Metaspace methods
|
|
|
|
|
|
|
|
size_t Metaspace::_first_chunk_word_size = 0;
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t Metaspace::_first_class_chunk_word_size = 0;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t Metaspace::_commit_alignment = 0;
|
|
|
|
size_t Metaspace::_reserve_alignment = 0;
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
Metaspace::Metaspace(Mutex* lock, MetaspaceType type) {
|
|
|
|
initialize(lock, type);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Metaspace::~Metaspace() {
|
|
|
|
delete _vsm;
|
2013-08-15 20:04:10 -04:00
|
|
|
if (using_class_space()) {
|
|
|
|
delete _class_vsm;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VirtualSpaceList* Metaspace::_space_list = NULL;
|
|
|
|
VirtualSpaceList* Metaspace::_class_space_list = NULL;
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
ChunkManager* Metaspace::_chunk_manager_metadata = NULL;
|
|
|
|
ChunkManager* Metaspace::_chunk_manager_class = NULL;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#define VIRTUALSPACEMULTIPLIER 2
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
#ifdef _LP64
|
|
|
|
void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) {
|
|
|
|
// Figure out the narrow_klass_base and the narrow_klass_shift. The
|
|
|
|
// narrow_klass_base is the lower of the metaspace base and the cds base
|
|
|
|
// (if cds is enabled). The narrow_klass_shift depends on the distance
|
|
|
|
// between the lower base and higher address.
|
|
|
|
address lower_base;
|
|
|
|
address higher_address;
|
|
|
|
if (UseSharedSpaces) {
|
|
|
|
higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()),
|
|
|
|
(address)(metaspace_base + class_metaspace_size()));
|
|
|
|
lower_base = MIN2(metaspace_base, cds_base);
|
|
|
|
} else {
|
|
|
|
higher_address = metaspace_base + class_metaspace_size();
|
|
|
|
lower_base = metaspace_base;
|
|
|
|
}
|
|
|
|
Universe::set_narrow_klass_base(lower_base);
|
|
|
|
if ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint) {
|
|
|
|
Universe::set_narrow_klass_shift(0);
|
|
|
|
} else {
|
|
|
|
assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces");
|
|
|
|
Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return TRUE if the specified metaspace_base and cds_base are close enough
|
|
|
|
// to work with compressed klass pointers.
|
|
|
|
bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) {
|
|
|
|
assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS");
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
|
2013-08-15 20:04:10 -04:00
|
|
|
address lower_base = MIN2((address)metaspace_base, cds_base);
|
|
|
|
address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()),
|
|
|
|
(address)(metaspace_base + class_metaspace_size()));
|
|
|
|
return ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to allocate the metaspace at the requested addr.
|
|
|
|
void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) {
|
|
|
|
assert(using_class_space(), "called improperly");
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
|
2013-08-15 20:04:10 -04:00
|
|
|
assert(class_metaspace_size() < KlassEncodingMetaspaceMax,
|
|
|
|
"Metaspace size is too big");
|
2013-10-07 15:51:08 +02:00
|
|
|
assert_is_ptr_aligned(requested_addr, _reserve_alignment);
|
|
|
|
assert_is_ptr_aligned(cds_base, _reserve_alignment);
|
|
|
|
assert_is_size_aligned(class_metaspace_size(), _reserve_alignment);
|
|
|
|
|
|
|
|
// Don't use large pages for the class space.
|
|
|
|
bool large_pages = false;
|
2013-08-15 20:04:10 -04:00
|
|
|
|
|
|
|
ReservedSpace metaspace_rs = ReservedSpace(class_metaspace_size(),
|
2013-10-07 15:51:08 +02:00
|
|
|
_reserve_alignment,
|
|
|
|
large_pages,
|
|
|
|
requested_addr, 0);
|
2013-08-15 20:04:10 -04:00
|
|
|
if (!metaspace_rs.is_reserved()) {
|
|
|
|
if (UseSharedSpaces) {
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t increment = align_size_up(1*G, _reserve_alignment);
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
// Keep trying to allocate the metaspace, increasing the requested_addr
|
|
|
|
// by 1GB each time, until we reach an address that will no longer allow
|
|
|
|
// use of CDS with compressed klass pointers.
|
|
|
|
char *addr = requested_addr;
|
2013-10-07 15:51:08 +02:00
|
|
|
while (!metaspace_rs.is_reserved() && (addr + increment > addr) &&
|
|
|
|
can_use_cds_with_metaspace_addr(addr + increment, cds_base)) {
|
|
|
|
addr = addr + increment;
|
2013-08-15 20:04:10 -04:00
|
|
|
metaspace_rs = ReservedSpace(class_metaspace_size(),
|
2013-10-07 15:51:08 +02:00
|
|
|
_reserve_alignment, large_pages, addr, 0);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If no successful allocation then try to allocate the space anywhere. If
|
|
|
|
// that fails then OOM doom. At this point we cannot try allocating the
|
2013-08-12 17:37:02 +02:00
|
|
|
// metaspace as if UseCompressedClassPointers is off because too much
|
|
|
|
// initialization has happened that depends on UseCompressedClassPointers.
|
|
|
|
// So, UseCompressedClassPointers cannot be turned off at this point.
|
2013-08-15 20:04:10 -04:00
|
|
|
if (!metaspace_rs.is_reserved()) {
|
|
|
|
metaspace_rs = ReservedSpace(class_metaspace_size(),
|
2013-10-07 15:51:08 +02:00
|
|
|
_reserve_alignment, large_pages);
|
2013-08-15 20:04:10 -04:00
|
|
|
if (!metaspace_rs.is_reserved()) {
|
|
|
|
vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes",
|
|
|
|
class_metaspace_size()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we got here then the metaspace got allocated.
|
|
|
|
MemTracker::record_virtual_memory_type((address)metaspace_rs.base(), mtClass);
|
|
|
|
|
|
|
|
// Verify that we can use shared spaces. Otherwise, turn off CDS.
|
|
|
|
if (UseSharedSpaces && !can_use_cds_with_metaspace_addr(metaspace_rs.base(), cds_base)) {
|
|
|
|
FileMapInfo::stop_sharing_and_unmap(
|
|
|
|
"Could not allocate metaspace at a compatible address");
|
|
|
|
}
|
|
|
|
|
|
|
|
set_narrow_klass_base_and_shift((address)metaspace_rs.base(),
|
|
|
|
UseSharedSpaces ? (address)cds_base : 0);
|
|
|
|
|
|
|
|
initialize_class_space(metaspace_rs);
|
|
|
|
|
|
|
|
if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
|
|
|
|
gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: " SIZE_FORMAT,
|
|
|
|
Universe::narrow_klass_base(), Universe::narrow_klass_shift());
|
|
|
|
gclog_or_tty->print_cr("Metaspace Size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT,
|
|
|
|
class_metaspace_size(), metaspace_rs.base(), requested_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-12 17:37:02 +02:00
|
|
|
// For UseCompressedClassPointers the class space is reserved above the top of
|
2013-08-15 20:04:10 -04:00
|
|
|
// the Java heap. The argument passed in is at the base of the compressed space.
|
|
|
|
void Metaspace::initialize_class_space(ReservedSpace rs) {
|
|
|
|
// The reserved space size may be bigger because of alignment, esp with UseLargePages
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(rs.size() >= CompressedClassSpaceSize,
|
|
|
|
err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), CompressedClassSpaceSize));
|
2013-08-15 20:04:10 -04:00
|
|
|
assert(using_class_space(), "Must be using class space");
|
|
|
|
_class_space_list = new VirtualSpaceList(rs);
|
2013-09-21 10:09:42 +02:00
|
|
|
_chunk_manager_class = new ChunkManager(SpecializedChunk, ClassSmallChunk, ClassMediumChunk);
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
if (!_class_space_list->initialization_succeeded()) {
|
|
|
|
vm_exit_during_initialization("Failed to setup compressed class space virtual space list.");
|
|
|
|
}
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// Align down. If the aligning result in 0, return 'alignment'.
|
|
|
|
static size_t restricted_align_down(size_t size, size_t alignment) {
|
|
|
|
return MAX2(alignment, align_size_down_(size, alignment));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Metaspace::ergo_initialize() {
|
|
|
|
if (DumpSharedSpaces) {
|
|
|
|
// Using large pages when dumping the shared archive is currently not implemented.
|
|
|
|
FLAG_SET_ERGO(bool, UseLargePagesInMetaspace, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t page_size = os::vm_page_size();
|
|
|
|
if (UseLargePages && UseLargePagesInMetaspace) {
|
|
|
|
page_size = os::large_page_size();
|
|
|
|
}
|
|
|
|
|
|
|
|
_commit_alignment = page_size;
|
|
|
|
_reserve_alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity());
|
|
|
|
|
|
|
|
// Do not use FLAG_SET_ERGO to update MaxMetaspaceSize, since this will
|
|
|
|
// override if MaxMetaspaceSize was set on the command line or not.
|
|
|
|
// This information is needed later to conform to the specification of the
|
|
|
|
// java.lang.management.MemoryUsage API.
|
|
|
|
//
|
|
|
|
// Ideally, we would be able to set the default value of MaxMetaspaceSize in
|
|
|
|
// globals.hpp to the aligned value, but this is not possible, since the
|
|
|
|
// alignment depends on other flags being parsed.
|
|
|
|
MaxMetaspaceSize = restricted_align_down(MaxMetaspaceSize, _reserve_alignment);
|
|
|
|
|
|
|
|
if (MetaspaceSize > MaxMetaspaceSize) {
|
|
|
|
MetaspaceSize = MaxMetaspaceSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaspaceSize = restricted_align_down(MetaspaceSize, _commit_alignment);
|
|
|
|
|
|
|
|
assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize");
|
|
|
|
|
|
|
|
if (MetaspaceSize < 256*K) {
|
|
|
|
vm_exit_during_initialization("Too small initial Metaspace size");
|
|
|
|
}
|
|
|
|
|
|
|
|
MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, _commit_alignment);
|
|
|
|
MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _commit_alignment);
|
|
|
|
|
|
|
|
CompressedClassSpaceSize = restricted_align_down(CompressedClassSpaceSize, _reserve_alignment);
|
|
|
|
set_class_metaspace_size(CompressedClassSpaceSize);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Metaspace::global_initialize() {
|
|
|
|
// Initialize the alignment for shared spaces.
|
|
|
|
int max_alignment = os::vm_page_size();
|
2013-08-15 20:04:10 -04:00
|
|
|
size_t cds_total = 0;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MetaspaceShared::set_max_alignment(max_alignment);
|
|
|
|
|
|
|
|
if (DumpSharedSpaces) {
|
2013-10-07 15:51:08 +02:00
|
|
|
SharedReadOnlySize = align_size_up(SharedReadOnlySize, max_alignment);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
SharedReadWriteSize = align_size_up(SharedReadWriteSize, max_alignment);
|
2013-10-07 15:51:08 +02:00
|
|
|
SharedMiscDataSize = align_size_up(SharedMiscDataSize, max_alignment);
|
|
|
|
SharedMiscCodeSize = align_size_up(SharedMiscCodeSize, max_alignment);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Initialize with the sum of the shared space sizes. The read-only
|
|
|
|
// and read write metaspace chunks will be allocated out of this and the
|
|
|
|
// remainder is the misc code and data chunks.
|
2013-08-15 20:04:10 -04:00
|
|
|
cds_total = FileMapInfo::shared_spaces_size();
|
2013-10-07 15:51:08 +02:00
|
|
|
cds_total = align_size_up(cds_total, _reserve_alignment);
|
2013-08-15 20:04:10 -04:00
|
|
|
_space_list = new VirtualSpaceList(cds_total/wordSize);
|
2013-09-21 10:09:42 +02:00
|
|
|
_chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk);
|
2013-08-15 20:04:10 -04:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
if (!_space_list->initialization_succeeded()) {
|
|
|
|
vm_exit_during_initialization("Unable to dump shared archive.", NULL);
|
|
|
|
}
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
#ifdef _LP64
|
2013-10-07 15:51:08 +02:00
|
|
|
if (cds_total + class_metaspace_size() > (uint64_t)max_juint) {
|
|
|
|
vm_exit_during_initialization("Unable to dump shared archive.",
|
|
|
|
err_msg("Size of archive (" SIZE_FORMAT ") + compressed class space ("
|
|
|
|
SIZE_FORMAT ") == total (" SIZE_FORMAT ") is larger than compressed "
|
|
|
|
"klass limit: " SIZE_FORMAT, cds_total, class_metaspace_size(),
|
|
|
|
cds_total + class_metaspace_size(), (size_t)max_juint));
|
|
|
|
}
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
// Set the compressed klass pointer base so that decoding of these pointers works
|
|
|
|
// properly when creating the shared archive.
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(UseCompressedOops && UseCompressedClassPointers,
|
|
|
|
"UseCompressedOops and UseCompressedClassPointers must be set");
|
2013-08-15 20:04:10 -04:00
|
|
|
Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
|
|
|
|
if (TraceMetavirtualspaceAllocation && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT,
|
|
|
|
_space_list->current_virtual_space()->bottom());
|
|
|
|
}
|
|
|
|
|
|
|
|
Universe::set_narrow_klass_shift(0);
|
|
|
|
#endif
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
|
|
|
// If using shared space, open the file that contains the shared space
|
|
|
|
// and map in the memory before initializing the rest of metaspace (so
|
|
|
|
// the addresses don't conflict)
|
2013-08-15 20:04:10 -04:00
|
|
|
address cds_address = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (UseSharedSpaces) {
|
|
|
|
FileMapInfo* mapinfo = new FileMapInfo();
|
|
|
|
memset(mapinfo, 0, sizeof(FileMapInfo));
|
|
|
|
|
|
|
|
// Open the shared archive file, read and validate the header. If
|
|
|
|
// initialization fails, shared spaces [UseSharedSpaces] are
|
|
|
|
// disabled and the file is closed.
|
|
|
|
// Map in spaces now also
|
|
|
|
if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) {
|
|
|
|
FileMapInfo::set_current_info(mapinfo);
|
2013-10-07 15:51:08 +02:00
|
|
|
cds_total = FileMapInfo::shared_spaces_size();
|
|
|
|
cds_address = (address)mapinfo->region_base(0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
|
|
|
assert(!mapinfo->is_open() && !UseSharedSpaces,
|
|
|
|
"archive file not closed or shared spaces not disabled.");
|
|
|
|
}
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _LP64
|
2013-08-12 17:37:02 +02:00
|
|
|
// If UseCompressedClassPointers is set then allocate the metaspace area
|
2013-08-15 20:04:10 -04:00
|
|
|
// above the heap and above the CDS area (if it exists).
|
|
|
|
if (using_class_space()) {
|
|
|
|
if (UseSharedSpaces) {
|
2013-10-07 15:51:08 +02:00
|
|
|
char* cds_end = (char*)(cds_address + cds_total);
|
|
|
|
cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment);
|
|
|
|
allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
|
2013-08-15 20:04:10 -04:00
|
|
|
} else {
|
|
|
|
allocate_metaspace_compressed_klass_ptrs((char *)CompressedKlassPointersBase, 0);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-08-15 20:04:10 -04:00
|
|
|
#endif
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
// Initialize these before initializing the VirtualSpaceList
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
|
2012-12-03 15:09:39 -08:00
|
|
|
_first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
|
|
|
|
// Make the first class chunk bigger than a medium chunk so it's not put
|
|
|
|
// on the medium chunk list. The next chunk will be small and progress
|
|
|
|
// from there. This size calculated by -version.
|
|
|
|
_first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
|
2013-08-12 17:37:02 +02:00
|
|
|
(CompressedClassSpaceSize/BytesPerWord)*2);
|
2012-12-03 15:09:39 -08:00
|
|
|
_first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Arbitrarily set the initial virtual space to a multiple
|
|
|
|
// of the boot class loader size.
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size;
|
|
|
|
word_size = align_size_up(word_size, Metaspace::reserve_alignment_words());
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Initialize the list of virtual spaces.
|
|
|
|
_space_list = new VirtualSpaceList(word_size);
|
2013-09-21 10:09:42 +02:00
|
|
|
_chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk);
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
if (!_space_list->initialization_succeeded()) {
|
|
|
|
vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL);
|
|
|
|
}
|
2013-09-21 10:09:42 +02:00
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
MetaspaceGC::initialize();
|
2013-09-21 10:09:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype,
|
|
|
|
size_t chunk_word_size,
|
|
|
|
size_t chunk_bunch) {
|
|
|
|
// Get a chunk from the chunk freelist
|
|
|
|
Metachunk* chunk = get_chunk_manager(mdtype)->chunk_freelist_allocate(chunk_word_size);
|
|
|
|
if (chunk != NULL) {
|
|
|
|
return chunk;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-09-21 10:09:42 +02:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
return get_space_list(mdtype)->get_new_chunk(chunk_word_size, chunk_word_size, chunk_bunch);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
void Metaspace::initialize(Mutex* lock, MetaspaceType type) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
assert(space_list() != NULL,
|
|
|
|
"Metadata VirtualSpaceList has not been initialized");
|
2013-09-21 10:09:42 +02:00
|
|
|
assert(chunk_manager_metadata() != NULL,
|
|
|
|
"Metadata ChunkManager has not been initialized");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
_vsm = new SpaceManager(NonClassType, lock);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (_vsm == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t word_size;
|
|
|
|
size_t class_word_size;
|
2013-08-15 20:04:10 -04:00
|
|
|
vsm()->get_initial_chunk_sizes(type, &word_size, &class_word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
if (using_class_space()) {
|
2013-09-21 10:09:42 +02:00
|
|
|
assert(class_space_list() != NULL,
|
|
|
|
"Class VirtualSpaceList has not been initialized");
|
|
|
|
assert(chunk_manager_class() != NULL,
|
|
|
|
"Class ChunkManager has not been initialized");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-08-15 20:04:10 -04:00
|
|
|
// Allocate SpaceManager for classes.
|
2013-09-21 10:09:42 +02:00
|
|
|
_class_vsm = new SpaceManager(ClassType, lock);
|
2013-08-15 20:04:10 -04:00
|
|
|
if (_class_vsm == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
|
|
|
|
// Allocate chunk for metadata objects
|
2013-09-21 10:09:42 +02:00
|
|
|
Metachunk* new_chunk = get_initialization_chunk(NonClassType,
|
|
|
|
word_size,
|
|
|
|
vsm()->medium_chunk_bunch());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(!DumpSharedSpaces || new_chunk != NULL, "should have enough space for both chunks");
|
|
|
|
if (new_chunk != NULL) {
|
|
|
|
// Add to this manager's list of chunks in use and current_chunk().
|
|
|
|
vsm()->add_chunk(new_chunk, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allocate chunk for class metadata objects
|
2013-08-15 20:04:10 -04:00
|
|
|
if (using_class_space()) {
|
2013-09-21 10:09:42 +02:00
|
|
|
Metachunk* class_chunk = get_initialization_chunk(ClassType,
|
|
|
|
class_word_size,
|
|
|
|
class_vsm()->medium_chunk_bunch());
|
2013-08-15 20:04:10 -04:00
|
|
|
if (class_chunk != NULL) {
|
|
|
|
class_vsm()->add_chunk(class_chunk, true);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-05-28 16:36:19 -07:00
|
|
|
|
|
|
|
_alloc_record_head = NULL;
|
|
|
|
_alloc_record_tail = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:09:39 -08:00
|
|
|
size_t Metaspace::align_word_size_up(size_t word_size) {
|
|
|
|
size_t byte_size = word_size * wordSize;
|
|
|
|
return ReservedSpace::allocation_align_size_up(byte_size) / wordSize;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) {
|
|
|
|
// DumpSharedSpaces doesn't use class metadata area (yet)
|
2013-08-12 17:37:02 +02:00
|
|
|
// Also, don't use class_vsm() unless UseCompressedClassPointers is true.
|
2013-09-27 10:23:12 +02:00
|
|
|
if (is_class_space_allocation(mdtype)) {
|
2012-09-18 23:35:42 -07:00
|
|
|
return class_vsm()->allocate(word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2012-09-18 23:35:42 -07:00
|
|
|
return vsm()->allocate(word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-18 14:15:06 -07:00
|
|
|
MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) {
|
2013-10-07 15:51:08 +02:00
|
|
|
size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord);
|
|
|
|
assert(delta_bytes > 0, "Must be");
|
|
|
|
|
|
|
|
size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes);
|
|
|
|
size_t before_inc = after_inc - delta_bytes;
|
|
|
|
|
2012-09-18 14:15:06 -07:00
|
|
|
if (PrintGCDetails && Verbose) {
|
|
|
|
gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
|
2013-10-07 15:51:08 +02:00
|
|
|
" to " SIZE_FORMAT, before_inc, after_inc);
|
2012-09-18 14:15:06 -07:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
return allocate(word_size, mdtype);
|
2012-09-18 14:15:06 -07:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Space allocated in the Metaspace. This may
|
|
|
|
// be across several metadata virtual spaces.
|
|
|
|
char* Metaspace::bottom() const {
|
|
|
|
assert(DumpSharedSpaces, "only useful and valid for dumping shared spaces");
|
|
|
|
return (char*)vsm()->current_chunk()->bottom();
|
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t Metaspace::used_words_slow(MetadataType mdtype) const {
|
2013-08-15 20:04:10 -04:00
|
|
|
if (mdtype == ClassType) {
|
|
|
|
return using_class_space() ? class_vsm()->sum_used_in_chunks_in_use() : 0;
|
|
|
|
} else {
|
|
|
|
return vsm()->sum_used_in_chunks_in_use(); // includes overhead!
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:30 +02:00
|
|
|
size_t Metaspace::free_words_slow(MetadataType mdtype) const {
|
2013-08-15 20:04:10 -04:00
|
|
|
if (mdtype == ClassType) {
|
|
|
|
return using_class_space() ? class_vsm()->sum_free_in_chunks_in_use() : 0;
|
|
|
|
} else {
|
|
|
|
return vsm()->sum_free_in_chunks_in_use();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Space capacity in the Metaspace. It includes
|
|
|
|
// space in the list of chunks from which allocations
|
|
|
|
// have been made. Don't include space in the global freelist and
|
|
|
|
// in the space available in the dictionary which
|
|
|
|
// is already counted in some chunk.
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t Metaspace::capacity_words_slow(MetadataType mdtype) const {
|
2013-08-15 20:04:10 -04:00
|
|
|
if (mdtype == ClassType) {
|
|
|
|
return using_class_space() ? class_vsm()->sum_capacity_in_chunks_in_use() : 0;
|
|
|
|
} else {
|
|
|
|
return vsm()->sum_capacity_in_chunks_in_use();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-02-12 14:15:45 -08:00
|
|
|
size_t Metaspace::used_bytes_slow(MetadataType mdtype) const {
|
|
|
|
return used_words_slow(mdtype) * BytesPerWord;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t Metaspace::capacity_bytes_slow(MetadataType mdtype) const {
|
|
|
|
return capacity_words_slow(mdtype) * BytesPerWord;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
|
|
|
|
if (SafepointSynchronize::is_at_safepoint()) {
|
|
|
|
assert(Thread::current()->is_VM_thread(), "should be the VM thread");
|
2012-09-18 23:35:42 -07:00
|
|
|
// Don't take Heap_lock
|
2013-04-29 13:07:27 +02:00
|
|
|
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
|
2012-09-18 23:35:42 -07:00
|
|
|
if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
|
|
|
|
// Dark matter. Too small for dictionary.
|
|
|
|
#ifdef ASSERT
|
|
|
|
Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2013-08-15 20:04:10 -04:00
|
|
|
if (is_class && using_class_space()) {
|
|
|
|
class_vsm()->deallocate(ptr, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2012-09-18 23:35:42 -07:00
|
|
|
vsm()->deallocate(ptr, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
} else {
|
2013-04-29 13:07:27 +02:00
|
|
|
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
|
|
|
|
// Dark matter. Too small for dictionary.
|
|
|
|
#ifdef ASSERT
|
|
|
|
Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2013-08-15 20:04:10 -04:00
|
|
|
if (is_class && using_class_space()) {
|
2012-09-18 23:35:42 -07:00
|
|
|
class_vsm()->deallocate(ptr, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2012-09-18 23:35:42 -07:00
|
|
|
vsm()->deallocate(ptr, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
|
2013-05-28 16:36:19 -07:00
|
|
|
bool read_only, MetaspaceObj::Type type, TRAPS) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
assert(false, "Should not allocate with exception pending");
|
|
|
|
return NULL; // caller does a CHECK_NULL too
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(loader_data != NULL, "Should never pass around a NULL loader_data. "
|
|
|
|
"ClassLoaderData::the_null_class_loader_data() should have been used.");
|
2013-10-07 15:51:08 +02:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Allocate in metaspaces without taking out a lock, because it deadlocks
|
|
|
|
// with the SymbolTable_lock. Dumping is single threaded for now. We'll have
|
|
|
|
// to revisit this for application class data sharing.
|
|
|
|
if (DumpSharedSpaces) {
|
2013-05-28 16:36:19 -07:00
|
|
|
assert(type > MetaspaceObj::UnknownType && type < MetaspaceObj::_number_of_types, "sanity");
|
|
|
|
Metaspace* space = read_only ? loader_data->ro_metaspace() : loader_data->rw_metaspace();
|
2013-10-07 15:51:08 +02:00
|
|
|
MetaWord* result = space->allocate(word_size, NonClassType);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (result == NULL) {
|
|
|
|
report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite);
|
2013-05-28 16:36:19 -07:00
|
|
|
} else {
|
|
|
|
space->record_allocation(result, type, space->vsm()->get_raw_word_size(word_size));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-09-18 23:35:42 -07:00
|
|
|
return Metablock::initialize(result, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
|
|
|
|
|
|
|
|
// Try to allocate metadata.
|
|
|
|
MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
if (result == NULL) {
|
2013-10-07 15:51:08 +02:00
|
|
|
// Allocation failed.
|
|
|
|
if (is_init_completed()) {
|
|
|
|
// Only start a GC if the bootstrapping has completed.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
// Try to clean out some memory and retry.
|
|
|
|
result = Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation(
|
|
|
|
loader_data, word_size, mdtype);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
2013-10-07 15:51:08 +02:00
|
|
|
|
|
|
|
if (result == NULL) {
|
|
|
|
report_metadata_oome(loader_data, word_size, mdtype, THREAD);
|
|
|
|
// Will not reach here.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-18 23:35:42 -07:00
|
|
|
return Metablock::initialize(result, word_size);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:51:08 +02:00
|
|
|
void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetadataType mdtype, TRAPS) {
|
|
|
|
// If result is still null, we are out of memory.
|
|
|
|
if (Verbose && TraceMetadataChunkAllocation) {
|
|
|
|
gclog_or_tty->print_cr("Metaspace allocation failed for size "
|
|
|
|
SIZE_FORMAT, word_size);
|
|
|
|
if (loader_data->metaspace_or_null() != NULL) {
|
|
|
|
loader_data->dump(gclog_or_tty);
|
|
|
|
}
|
|
|
|
MetaspaceAux::dump(gclog_or_tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
|
|
|
|
const char* space_string = is_class_space_allocation(mdtype) ? "Compressed class space" :
|
|
|
|
"Metadata space";
|
|
|
|
report_java_out_of_memory(space_string);
|
|
|
|
|
|
|
|
if (JvmtiExport::should_post_resource_exhausted()) {
|
|
|
|
JvmtiExport::post_resource_exhausted(
|
|
|
|
JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
|
|
|
|
space_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_init_completed()) {
|
|
|
|
vm_exit_during_initialization("OutOfMemoryError", space_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_class_space_allocation(mdtype)) {
|
|
|
|
THROW_OOP(Universe::out_of_memory_error_class_metaspace());
|
|
|
|
} else {
|
|
|
|
THROW_OOP(Universe::out_of_memory_error_metaspace());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-28 16:36:19 -07:00
|
|
|
void Metaspace::record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size) {
|
|
|
|
assert(DumpSharedSpaces, "sanity");
|
|
|
|
|
|
|
|
AllocRecord *rec = new AllocRecord((address)ptr, type, (int)word_size * HeapWordSize);
|
|
|
|
if (_alloc_record_head == NULL) {
|
|
|
|
_alloc_record_head = _alloc_record_tail = rec;
|
|
|
|
} else {
|
|
|
|
_alloc_record_tail->_next = rec;
|
|
|
|
_alloc_record_tail = rec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Metaspace::iterate(Metaspace::AllocRecordClosure *closure) {
|
|
|
|
assert(DumpSharedSpaces, "unimplemented for !DumpSharedSpaces");
|
|
|
|
|
|
|
|
address last_addr = (address)bottom();
|
|
|
|
|
|
|
|
for (AllocRecord *rec = _alloc_record_head; rec; rec = rec->_next) {
|
|
|
|
address ptr = rec->_ptr;
|
|
|
|
if (last_addr < ptr) {
|
|
|
|
closure->doit(last_addr, MetaspaceObj::UnknownType, ptr - last_addr);
|
|
|
|
}
|
|
|
|
closure->doit(ptr, rec->_type, rec->_byte_size);
|
|
|
|
last_addr = ptr + rec->_byte_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
address top = ((address)bottom()) + used_bytes_slow(Metaspace::NonClassType);
|
|
|
|
if (last_addr < top) {
|
|
|
|
closure->doit(last_addr, MetaspaceObj::UnknownType, top - last_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-21 10:09:42 +02:00
|
|
|
void Metaspace::purge(MetadataType mdtype) {
|
|
|
|
get_space_list(mdtype)->purge(get_chunk_manager(mdtype));
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:19:29 -08:00
|
|
|
void Metaspace::purge() {
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(),
|
|
|
|
Mutex::_no_safepoint_check_flag);
|
2013-09-21 10:09:42 +02:00
|
|
|
purge(NonClassType);
|
2013-08-15 20:04:10 -04:00
|
|
|
if (using_class_space()) {
|
2013-09-21 10:09:42 +02:00
|
|
|
purge(ClassType);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
2013-03-01 10:19:29 -08:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Metaspace::print_on(outputStream* out) const {
|
|
|
|
// Print both class virtual space counts and metaspace.
|
|
|
|
if (Verbose) {
|
2013-08-15 20:04:10 -04:00
|
|
|
vsm()->print_on(out);
|
|
|
|
if (using_class_space()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
class_vsm()->print_on(out);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 17:50:21 -05:00
|
|
|
bool Metaspace::contains(const void * ptr) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (MetaspaceShared::is_in_shared_space(ptr)) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 17:50:21 -05:00
|
|
|
// This is checked while unlocked. As long as the virtualspaces are added
|
|
|
|
// at the end, the pointer will be in one of them. The virtual spaces
|
|
|
|
// aren't deleted presently. When they are, some sort of locking might
|
|
|
|
// be needed. Note, locking this can cause inversion problems with the
|
|
|
|
// caller in MetaspaceObj::is_metadata() function.
|
2013-03-01 10:19:29 -08:00
|
|
|
return space_list()->contains(ptr) ||
|
2013-08-15 20:04:10 -04:00
|
|
|
(using_class_space() && class_space_list()->contains(ptr));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Metaspace::verify() {
|
|
|
|
vsm()->verify();
|
2013-08-15 20:04:10 -04:00
|
|
|
if (using_class_space()) {
|
|
|
|
class_vsm()->verify();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Metaspace::dump(outputStream* const out) const {
|
|
|
|
out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, vsm());
|
|
|
|
vsm()->dump(out);
|
2013-08-15 20:04:10 -04:00
|
|
|
if (using_class_space()) {
|
|
|
|
out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm());
|
|
|
|
class_vsm()->dump(out);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2013-09-12 10:15:54 +02:00
|
|
|
|
|
|
|
/////////////// Unit tests ///////////////
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2013-09-25 17:23:41 +02:00
|
|
|
class TestMetaspaceAuxTest : AllStatic {
|
2013-09-12 10:15:54 +02:00
|
|
|
public:
|
|
|
|
static void test_reserved() {
|
|
|
|
size_t reserved = MetaspaceAux::reserved_bytes();
|
|
|
|
|
|
|
|
assert(reserved > 0, "assert");
|
|
|
|
|
|
|
|
size_t committed = MetaspaceAux::committed_bytes();
|
|
|
|
assert(committed <= reserved, "assert");
|
|
|
|
|
|
|
|
size_t reserved_metadata = MetaspaceAux::reserved_bytes(Metaspace::NonClassType);
|
|
|
|
assert(reserved_metadata > 0, "assert");
|
|
|
|
assert(reserved_metadata <= reserved, "assert");
|
|
|
|
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
size_t reserved_class = MetaspaceAux::reserved_bytes(Metaspace::ClassType);
|
|
|
|
assert(reserved_class > 0, "assert");
|
|
|
|
assert(reserved_class < reserved, "assert");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_committed() {
|
|
|
|
size_t committed = MetaspaceAux::committed_bytes();
|
|
|
|
|
|
|
|
assert(committed > 0, "assert");
|
|
|
|
|
|
|
|
size_t reserved = MetaspaceAux::reserved_bytes();
|
|
|
|
assert(committed <= reserved, "assert");
|
|
|
|
|
|
|
|
size_t committed_metadata = MetaspaceAux::committed_bytes(Metaspace::NonClassType);
|
|
|
|
assert(committed_metadata > 0, "assert");
|
|
|
|
assert(committed_metadata <= committed, "assert");
|
|
|
|
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
size_t committed_class = MetaspaceAux::committed_bytes(Metaspace::ClassType);
|
|
|
|
assert(committed_class > 0, "assert");
|
|
|
|
assert(committed_class < committed, "assert");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 17:23:41 +02:00
|
|
|
static void test_virtual_space_list_large_chunk() {
|
|
|
|
VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity());
|
|
|
|
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
// A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be
|
|
|
|
// vm_allocation_granularity aligned on Windows.
|
|
|
|
size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord));
|
|
|
|
large_size += (os::vm_page_size()/BytesPerWord);
|
|
|
|
vs_list->get_new_chunk(large_size, large_size, 0);
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:15:54 +02:00
|
|
|
static void test() {
|
|
|
|
test_reserved();
|
|
|
|
test_committed();
|
2013-09-25 17:23:41 +02:00
|
|
|
test_virtual_space_list_large_chunk();
|
2013-09-12 10:15:54 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-25 17:23:41 +02:00
|
|
|
void TestMetaspaceAux_test() {
|
|
|
|
TestMetaspaceAuxTest::test();
|
2013-09-12 10:15:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|