--- a/hotspot/src/share/vm/memory/metaspace.hpp Wed Oct 09 10:57:01 2013 +0200
+++ b/hotspot/src/share/vm/memory/metaspace.hpp Mon Oct 07 15:51:08 2013 +0200
@@ -87,9 +87,10 @@
friend class MetaspaceAux;
public:
- enum MetadataType {ClassType = 0,
- NonClassType = ClassType + 1,
- MetadataTypeCount = ClassType + 2
+ enum MetadataType {
+ ClassType,
+ NonClassType,
+ MetadataTypeCount
};
enum MetaspaceType {
StandardMetaspaceType,
@@ -103,6 +104,9 @@
private:
void initialize(Mutex* lock, MetaspaceType type);
+ // Get the first chunk for a Metaspace. Used for
+ // special cases such as the boot class loader, reflection
+ // class loader and anonymous class loader.
Metachunk* get_initialization_chunk(MetadataType mdtype,
size_t chunk_word_size,
size_t chunk_bunch);
@@ -123,6 +127,9 @@
static size_t _first_chunk_word_size;
static size_t _first_class_chunk_word_size;
+ static size_t _commit_alignment;
+ static size_t _reserve_alignment;
+
SpaceManager* _vsm;
SpaceManager* vsm() const { return _vsm; }
@@ -191,12 +198,17 @@
Metaspace(Mutex* lock, MetaspaceType type);
~Metaspace();
- // Initialize globals for Metaspace
+ static void ergo_initialize();
static void global_initialize();
static size_t first_chunk_word_size() { return _first_chunk_word_size; }
static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; }
+ static size_t reserve_alignment() { return _reserve_alignment; }
+ static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; }
+ static size_t commit_alignment() { return _commit_alignment; }
+ static size_t commit_alignment_words() { return _commit_alignment / BytesPerWord; }
+
char* bottom() const;
size_t used_words_slow(MetadataType mdtype) const;
size_t free_words_slow(MetadataType mdtype) const;
@@ -219,6 +231,9 @@
static void purge(MetadataType mdtype);
static void purge();
+ static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size,
+ MetadataType mdtype, TRAPS);
+
void print_on(outputStream* st) const;
// Debugging support
void verify();
@@ -352,17 +367,10 @@
class MetaspaceGC : AllStatic {
- // The current high-water-mark for inducing a GC. When
- // the capacity of all space in the virtual lists reaches this value,
- // a GC is induced and the value is increased. This should be changed
- // to the space actually used for allocations to avoid affects of
- // fragmentation losses to partially used chunks. Size is in words.
- static size_t _capacity_until_GC;
-
- // After a GC is done any allocation that fails should try to expand
- // the capacity of the Metaspaces. This flag is set during attempts
- // to allocate in the VMGCOperation that does the GC.
- static bool _expand_after_GC;
+ // The current high-water-mark for inducing a GC.
+ // When committed memory of all metaspaces reaches this value,
+ // a GC is induced and the value is increased. Size is in bytes.
+ static volatile intptr_t _capacity_until_GC;
// For a CMS collection, signal that a concurrent collection should
// be started.
@@ -370,20 +378,16 @@
static uint _shrink_factor;
- static void set_capacity_until_GC(size_t v) { _capacity_until_GC = v; }
-
static size_t shrink_factor() { return _shrink_factor; }
void set_shrink_factor(uint v) { _shrink_factor = v; }
public:
- static size_t capacity_until_GC() { return _capacity_until_GC; }
- static void inc_capacity_until_GC(size_t v) { _capacity_until_GC += v; }
- static void dec_capacity_until_GC(size_t v) {
- _capacity_until_GC = _capacity_until_GC > v ? _capacity_until_GC - v : 0;
- }
- static bool expand_after_GC() { return _expand_after_GC; }
- static void set_expand_after_GC(bool v) { _expand_after_GC = v; }
+ static void initialize() { _capacity_until_GC = MetaspaceSize; }
+
+ static size_t capacity_until_GC();
+ static size_t inc_capacity_until_GC(size_t v);
+ static size_t dec_capacity_until_GC(size_t v);
static bool should_concurrent_collect() { return _should_concurrent_collect; }
static void set_should_concurrent_collect(bool v) {
@@ -391,11 +395,14 @@
}
// The amount to increase the high-water-mark (_capacity_until_GC)
- static size_t delta_capacity_until_GC(size_t word_size);
+ static size_t delta_capacity_until_GC(size_t bytes);
- // It is expected that this will be called when the current capacity
- // has been used and a GC should be considered.
- static bool should_expand(VirtualSpaceList* vsl, size_t word_size);
+ // Tells if we have can expand metaspace without hitting set limits.
+ static bool can_expand(size_t words, bool is_class);
+
+ // Returns amount that we can expand without hitting a GC,
+ // measured in words.
+ static size_t allowed_expansion();
// Calculate the new high-water mark at which to induce
// a GC.