mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8261868: Reduce inclusion of metaspace.hpp
Reviewed-by: stuefe, ccheung
This commit is contained in:
parent
3a0d6a64bc
commit
0f8be6e433
52 changed files with 253 additions and 161 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "runtime/frame.inline.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2019 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "runtime/frame.inline.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,8 +26,6 @@
|
|||
#define SHARE_CLASSFILE_CLASSLOADERDATA_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/memRegion.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "oops/oopHandle.hpp"
|
||||
#include "oops/weakHandle.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "oops/array.hpp"
|
||||
#include "oops/symbol.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "gc/shared/locationPrinter.inline.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
#include "memory/allocation.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/heapInspection.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,7 +27,7 @@
|
|||
#include "gc/g1/g1HeapTransition.hpp"
|
||||
#include "gc/g1/g1Policy.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
|
||||
G1HeapTransition::Data::Data(G1CollectedHeap* g1_heap) :
|
||||
_eden_length(g1_heap->eden_regions_count()),
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "logging/log.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceCounters.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "gc/shared/strongRootsScope.hpp"
|
||||
#include "gc/shared/workgroup.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -62,6 +62,7 @@
|
|||
#include "gc/shared/workgroup.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/iterator.inline.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,6 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "gc/serial/cSpaceCounters.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
|
||||
CSpaceCounters::CSpaceCounters(const char* name, int ordinal, size_t max_size,
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/classLoaderMetaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/instanceMirrorKlass.hpp"
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "gc/shared/gcWhen.hpp"
|
||||
#include "gc/shared/verifyOption.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "runtime/handles.hpp"
|
||||
#include "runtime/perfDataTypes.hpp"
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
|
||||
#include "memory/metaspaceCounters.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/virtualspace.hpp"
|
||||
#include "gc/shenandoah/shenandoahHeap.hpp"
|
||||
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
|
||||
#include "gc/shenandoah/shenandoahPadding.hpp"
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "gc/shenandoah/shenandoahWorkerPolicy.hpp"
|
||||
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "gc/shenandoah/shenandoahVerifier.hpp"
|
||||
#include "gc/shenandoah/shenandoahVMOperations.hpp"
|
||||
#include "gc/shenandoah/shenandoahWorkerPolicy.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/compressedOops.inline.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "memory/classLoaderMetaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "oops/compressedOops.inline.hpp"
|
||||
#include "prims/jvmtiTagMap.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "gc/shenandoah/shenandoahUnload.hpp"
|
||||
#include "gc/shenandoah/shenandoahVerifier.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "gc/z/zWorkers.inline.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "prims/jvmtiTagMap.hpp"
|
||||
#include "runtime/handshake.hpp"
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "gc/z/zStat.hpp"
|
||||
#include "gc/z/zTracer.inline.hpp"
|
||||
#include "gc/z/zUtils.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -34,6 +34,7 @@
|
|||
#include "gc/z/zNMethod.hpp"
|
||||
#include "gc/z/zStat.hpp"
|
||||
#include "gc/z/zUnload.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
|
||||
static const ZStatSubPhase ZSubPhaseConcurrentClassesUnlink("Concurrent Classes Unlink");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -42,6 +42,7 @@
|
|||
#include "jfr/utilities/jfrThreadIterator.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/referenceType.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
#include "memory/dynamicArchive.hpp"
|
||||
#include "memory/filemap.hpp"
|
||||
#include "memory/heapShared.inline.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "oops/compressedOops.inline.hpp"
|
||||
#include "utilities/bitMap.inline.hpp"
|
||||
|
@ -236,8 +236,7 @@ void DumpRegion::print_out_of_space_msg(const char* failing_region, size_t neede
|
|||
void DumpRegion::init(ReservedSpace* rs, VirtualSpace* vs) {
|
||||
_rs = rs;
|
||||
_vs = vs;
|
||||
// Start with 0 committed bytes. The memory will be committed as needed by
|
||||
// MetaspaceShared::commit_to().
|
||||
// Start with 0 committed bytes. The memory will be committed as needed.
|
||||
if (!_vs->initialize(*_rs, 0)) {
|
||||
fatal("Unable to allocate memory for shared space");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -27,6 +27,7 @@
|
|||
#include "logging/log.hpp"
|
||||
#include "memory/classLoaderMetaspace.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/metaspace/chunkManager.hpp"
|
||||
#include "memory/metaspace/internalStats.hpp"
|
||||
#include "memory/metaspace/metaspaceArena.hpp"
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "include/cds.h"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "classfile/classLoaderData.hpp"
|
||||
#include "memory/classLoaderMetaspace.hpp"
|
||||
#include "oops/array.hpp"
|
||||
#include "oops/array.inline.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "memory/metaspace/virtualSpaceList.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceTracer.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,9 +25,6 @@
|
|||
#define SHARE_MEMORY_METASPACE_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/memRegion.hpp"
|
||||
#include "memory/metaspaceChunkFreeListSummary.hpp"
|
||||
#include "memory/virtualspace.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
@ -37,6 +34,7 @@ class MetaspaceShared;
|
|||
class MetaspaceTracer;
|
||||
class Mutex;
|
||||
class outputStream;
|
||||
class ReservedSpace;
|
||||
|
||||
namespace metaspace {
|
||||
class MetaspaceSizesSnapshot;
|
||||
|
@ -152,115 +150,5 @@ public:
|
|||
|
||||
};
|
||||
|
||||
////////////////// MetaspaceGC ///////////////////////
|
||||
|
||||
// Metaspace are deallocated when their class loader are GC'ed.
|
||||
// This class implements a policy for inducing GC's to recover
|
||||
// Metaspaces.
|
||||
|
||||
class MetaspaceGCThresholdUpdater : public AllStatic {
|
||||
public:
|
||||
enum Type {
|
||||
ComputeNewSize,
|
||||
ExpandAndAllocate,
|
||||
Last
|
||||
};
|
||||
|
||||
static const char* to_string(MetaspaceGCThresholdUpdater::Type updater) {
|
||||
switch (updater) {
|
||||
case ComputeNewSize:
|
||||
return "compute_new_size";
|
||||
case ExpandAndAllocate:
|
||||
return "expand_and_allocate";
|
||||
default:
|
||||
assert(false, "Got bad updater: %d", (int) updater);
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class MetaspaceGC : public AllStatic {
|
||||
|
||||
// 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 size_t _capacity_until_GC;
|
||||
static uint _shrink_factor;
|
||||
|
||||
static size_t shrink_factor() { return _shrink_factor; }
|
||||
void set_shrink_factor(uint v) { _shrink_factor = v; }
|
||||
|
||||
public:
|
||||
|
||||
static void initialize();
|
||||
static void post_initialize();
|
||||
|
||||
static size_t capacity_until_GC();
|
||||
static bool inc_capacity_until_GC(size_t v,
|
||||
size_t* new_cap_until_GC = NULL,
|
||||
size_t* old_cap_until_GC = NULL,
|
||||
bool* can_retry = NULL);
|
||||
static size_t dec_capacity_until_GC(size_t v);
|
||||
|
||||
// The amount to increase the high-water-mark (_capacity_until_GC)
|
||||
static size_t delta_capacity_until_GC(size_t bytes);
|
||||
|
||||
// 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.
|
||||
static void compute_new_size();
|
||||
};
|
||||
|
||||
class MetaspaceUtils : AllStatic {
|
||||
public:
|
||||
|
||||
// Committed space actually in use by Metadata
|
||||
static size_t used_words();
|
||||
static size_t used_words(Metaspace::MetadataType mdtype);
|
||||
|
||||
// Space committed for Metaspace
|
||||
static size_t committed_words();
|
||||
static size_t committed_words(Metaspace::MetadataType mdtype);
|
||||
|
||||
// Space reserved for Metaspace
|
||||
static size_t reserved_words();
|
||||
static size_t reserved_words(Metaspace::MetadataType mdtype);
|
||||
|
||||
// _bytes() variants for convenience...
|
||||
static size_t used_bytes() { return used_words() * BytesPerWord; }
|
||||
static size_t used_bytes(Metaspace::MetadataType mdtype) { return used_words(mdtype) * BytesPerWord; }
|
||||
static size_t committed_bytes() { return committed_words() * BytesPerWord; }
|
||||
static size_t committed_bytes(Metaspace::MetadataType mdtype) { return committed_words(mdtype) * BytesPerWord; }
|
||||
static size_t reserved_bytes() { return reserved_words() * BytesPerWord; }
|
||||
static size_t reserved_bytes(Metaspace::MetadataType mdtype) { return reserved_words(mdtype) * BytesPerWord; }
|
||||
|
||||
// (See JDK-8251342). Implement or Consolidate.
|
||||
static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype) {
|
||||
return MetaspaceChunkFreeListSummary(0,0,0,0,0,0,0,0);
|
||||
}
|
||||
|
||||
// Log change in used metadata.
|
||||
static void print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values);
|
||||
|
||||
// This will print out a basic metaspace usage report but
|
||||
// unlike print_report() is guaranteed not to lock or to walk the CLDG.
|
||||
static void print_basic_report(outputStream* st, size_t scale = 0);
|
||||
|
||||
// Prints a report about the current metaspace state.
|
||||
// Function will walk the CLDG and will lock the expand lock; if that is not
|
||||
// convenient, use print_basic_report() instead.
|
||||
static void print_report(outputStream* out, size_t scale = 0);
|
||||
|
||||
static void print_on(outputStream * out);
|
||||
|
||||
DEBUG_ONLY(static void verify();)
|
||||
|
||||
};
|
||||
|
||||
#endif // SHARE_MEMORY_METASPACE_HPP
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspace/commitLimiter.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
|
|
|
@ -24,8 +24,10 @@
|
|||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspace/metaspaceDCmd.hpp"
|
||||
#include "memory/metaspace/metaspaceReporter.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "runtime/vmOperations.hpp"
|
||||
#include "services/diagnosticCommand.hpp"
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp"
|
||||
#include "memory/metaspace/runningCounters.hpp"
|
||||
#include "memory/metaspace/virtualSpaceList.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
|
||||
namespace metaspace {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, Twitter, Inc.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
|
||||
namespace metaspace {
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceCounters.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/perfData.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
|
||||
class ClassLoaderData;
|
||||
|
||||
|
|
141
src/hotspot/share/memory/metaspaceUtils.hpp
Normal file
141
src/hotspot/share/memory/metaspaceUtils.hpp
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef SHARE_MEMORY_METASPACEUTILS_HPP
|
||||
#define SHARE_MEMORY_METASPACEUTILS_HPP
|
||||
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceChunkFreeListSummary.hpp"
|
||||
|
||||
class outputStream;
|
||||
|
||||
// Metaspace are deallocated when their class loader are GC'ed.
|
||||
// This class implements a policy for inducing GC's to recover
|
||||
// Metaspaces.
|
||||
|
||||
class MetaspaceGCThresholdUpdater : public AllStatic {
|
||||
public:
|
||||
enum Type {
|
||||
ComputeNewSize,
|
||||
ExpandAndAllocate,
|
||||
Last
|
||||
};
|
||||
|
||||
static const char* to_string(MetaspaceGCThresholdUpdater::Type updater) {
|
||||
switch (updater) {
|
||||
case ComputeNewSize:
|
||||
return "compute_new_size";
|
||||
case ExpandAndAllocate:
|
||||
return "expand_and_allocate";
|
||||
default:
|
||||
assert(false, "Got bad updater: %d", (int) updater);
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class MetaspaceGC : public AllStatic {
|
||||
|
||||
// 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 size_t _capacity_until_GC;
|
||||
static uint _shrink_factor;
|
||||
|
||||
static size_t shrink_factor() { return _shrink_factor; }
|
||||
void set_shrink_factor(uint v) { _shrink_factor = v; }
|
||||
|
||||
public:
|
||||
|
||||
static void initialize();
|
||||
static void post_initialize();
|
||||
|
||||
static size_t capacity_until_GC();
|
||||
static bool inc_capacity_until_GC(size_t v,
|
||||
size_t* new_cap_until_GC = NULL,
|
||||
size_t* old_cap_until_GC = NULL,
|
||||
bool* can_retry = NULL);
|
||||
static size_t dec_capacity_until_GC(size_t v);
|
||||
|
||||
// The amount to increase the high-water-mark (_capacity_until_GC)
|
||||
static size_t delta_capacity_until_GC(size_t bytes);
|
||||
|
||||
// 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.
|
||||
static void compute_new_size();
|
||||
};
|
||||
|
||||
class MetaspaceUtils : AllStatic {
|
||||
public:
|
||||
|
||||
// Committed space actually in use by Metadata
|
||||
static size_t used_words();
|
||||
static size_t used_words(Metaspace::MetadataType mdtype);
|
||||
|
||||
// Space committed for Metaspace
|
||||
static size_t committed_words();
|
||||
static size_t committed_words(Metaspace::MetadataType mdtype);
|
||||
|
||||
// Space reserved for Metaspace
|
||||
static size_t reserved_words();
|
||||
static size_t reserved_words(Metaspace::MetadataType mdtype);
|
||||
|
||||
// _bytes() variants for convenience...
|
||||
static size_t used_bytes() { return used_words() * BytesPerWord; }
|
||||
static size_t used_bytes(Metaspace::MetadataType mdtype) { return used_words(mdtype) * BytesPerWord; }
|
||||
static size_t committed_bytes() { return committed_words() * BytesPerWord; }
|
||||
static size_t committed_bytes(Metaspace::MetadataType mdtype) { return committed_words(mdtype) * BytesPerWord; }
|
||||
static size_t reserved_bytes() { return reserved_words() * BytesPerWord; }
|
||||
static size_t reserved_bytes(Metaspace::MetadataType mdtype) { return reserved_words(mdtype) * BytesPerWord; }
|
||||
|
||||
// (See JDK-8251342). Implement or Consolidate.
|
||||
static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype) {
|
||||
return MetaspaceChunkFreeListSummary(0,0,0,0,0,0,0,0);
|
||||
}
|
||||
|
||||
// Log change in used metadata.
|
||||
static void print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values);
|
||||
|
||||
// This will print out a basic metaspace usage report but
|
||||
// unlike print_report() is guaranteed not to lock or to walk the CLDG.
|
||||
static void print_basic_report(outputStream* st, size_t scale = 0);
|
||||
|
||||
// Prints a report about the current metaspace state.
|
||||
// Function will walk the CLDG and will lock the expand lock; if that is not
|
||||
// convenient, use print_basic_report() instead.
|
||||
static void print_report(outputStream* out, size_t scale = 0);
|
||||
|
||||
static void print_on(outputStream * out);
|
||||
|
||||
DEBUG_ONLY(static void verify();)
|
||||
|
||||
};
|
||||
|
||||
#endif // SHARE_MEMORY_METASPACEUTILS_HPP
|
|
@ -48,6 +48,7 @@
|
|||
#include "memory/metaspaceClosure.hpp"
|
||||
#include "memory/metaspaceCounters.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
class CollectedHeap;
|
||||
class DeferredObjAllocEvent;
|
||||
class OopStorage;
|
||||
class ReservedHeapSpace;
|
||||
|
||||
// A helper class for caching a Method* when the user of the cache
|
||||
// only cares about the latest version of the Method*. This cache safely
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
#ifndef SHARE_OOPS_ARRAY_HPP
|
||||
#define SHARE_OOPS_ARRAY_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
// Array for metadata allocation
|
||||
|
||||
|
@ -52,11 +52,7 @@ protected:
|
|||
private:
|
||||
NONCOPYABLE(Array);
|
||||
|
||||
void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() {
|
||||
size_t word_size = Array::size(length);
|
||||
return (void*) Metaspace::allocate(loader_data, word_size,
|
||||
MetaspaceObj::array_type(sizeof(T)), THREAD);
|
||||
}
|
||||
inline void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw();
|
||||
|
||||
static size_t byte_sizeof(int length, size_t elm_byte_size) {
|
||||
return sizeof(Array<T>) + MAX2(length - 1, 0) * elm_byte_size;
|
||||
|
|
40
src/hotspot/share/oops/array.inline.hpp
Normal file
40
src/hotspot/share/oops/array.inline.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_OOPS_ARRAY_INLINE_HPP
|
||||
#define SHARE_OOPS_ARRAY_INLINE_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "oops/array.hpp"
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline void* Array<T>::operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() {
|
||||
size_t word_size = Array::size(length);
|
||||
return (void*) Metaspace::allocate(loader_data, word_size,
|
||||
MetaspaceObj::array_type(sizeof(T)), THREAD);
|
||||
}
|
||||
|
||||
#endif // SHARE_OOPS_ARRAY_INLINE_HPP
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -29,6 +29,7 @@
|
|||
#include "memory/memRegion.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "memory/virtualspace.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
#include "gc/shared/collectedHeap.hpp"
|
||||
#include "runtime/arguments.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include "precompiled.hpp"
|
||||
#include "oops/metadata.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "prims/jvmtiRedefineClasses.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,6 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceClosure.hpp"
|
||||
#include "oops/annotations.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "classfile/classLoaderDataGraph.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/modules.hpp"
|
||||
|
@ -47,13 +45,14 @@
|
|||
#include "logging/log.hpp"
|
||||
#include "memory/filemap.hpp"
|
||||
#include "memory/heapShared.inline.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
#include "memory/metaspace/testHelpers.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "oops/array.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
#include "oops/constantPool.inline.hpp"
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#endif
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/dynamicArchive.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -24,6 +24,7 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "services/mallocTracker.hpp"
|
||||
#include "services/memReporter.hpp"
|
||||
#include "services/threadStackTracker.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
#include "precompiled.hpp"
|
||||
#include "jvm.h"
|
||||
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "runtime/vmThread.hpp"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "oops/oopHandle.inline.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -22,9 +22,9 @@
|
|||
*
|
||||
*/
|
||||
#include "precompiled.hpp"
|
||||
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/threadCritical.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "logging/logConfiguration.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.inline.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "unittest.hpp"
|
||||
|
||||
TEST_VM(MetaspaceUtils, reserved) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue