Skip to content

Commit

Permalink
8267879: ClassLoaderMetaspace destructor asserts on !_frozen
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, coleenp
  • Loading branch information
iklam committed Jun 2, 2021
1 parent ecf6112 commit a8835b9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 24 deletions.
7 changes: 0 additions & 7 deletions src/hotspot/share/cds/metaspaceShared.cpp
Expand Up @@ -478,13 +478,6 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables() {
void VM_PopulateDumpSharedSpace::doit() {
HeapShared::run_full_gc_in_vm_thread();

// We should no longer allocate anything from the metaspace, so that:
//
// (1) Metaspace::allocate might trigger GC if we have run out of
// committed metaspace, but we can't GC because we're running
// in the VM thread.
// (2) ArchiveBuilder needs to work with a stable set of MetaspaceObjs.
Metaspace::freeze();
DEBUG_ONLY(SystemDictionaryShared::NoClassLoadingMark nclm);

FileMapInfo::check_nonempty_dir_in_shared_path_table();
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/memory/classLoaderMetaspace.cpp
Expand Up @@ -81,8 +81,6 @@ ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType
}

ClassLoaderMetaspace::~ClassLoaderMetaspace() {
Metaspace::assert_not_frozen();

UL(debug, "dies.");

delete _non_class_space_arena;
Expand All @@ -92,7 +90,6 @@ ClassLoaderMetaspace::~ClassLoaderMetaspace() {

// Allocate word_size words from Metaspace.
MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdType) {
Metaspace::assert_not_frozen();
if (Metaspace::is_class_space_allocation(mdType)) {
return class_space_arena()->allocate(word_size);
} else {
Expand All @@ -103,7 +100,6 @@ MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataTy
// Attempt to expand the GC threshold to be good for at least another word_size words
// and allocate. Returns NULL if failure. Used during Metaspace GC.
MetaWord* ClassLoaderMetaspace::expand_and_allocate(size_t word_size, Metaspace::MetadataType mdType) {
Metaspace::assert_not_frozen();
size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord);
assert(delta_bytes > 0, "Must be");

Expand Down Expand Up @@ -135,7 +131,6 @@ MetaWord* ClassLoaderMetaspace::expand_and_allocate(size_t word_size, Metaspace:
// Prematurely returns a metaspace allocation to the _block_freelists
// because it is not needed anymore.
void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
Metaspace::assert_not_frozen();
if (Metaspace::using_class_space() && is_class) {
class_space_arena()->deallocate(ptr, word_size);
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/memory/metaspace.cpp
Expand Up @@ -535,8 +535,6 @@ void MetaspaceGC::compute_new_size() {

const MetaspaceTracer* Metaspace::_tracer = NULL;

DEBUG_ONLY(bool Metaspace::_frozen = false;)

bool Metaspace::initialized() {
return metaspace::MetaspaceContext::context_nonclass() != NULL
LP64_ONLY(&& (using_class_space() ? Metaspace::class_space_is_initialized() : true));
Expand Down Expand Up @@ -851,7 +849,6 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type) {
assert(word_size <= Metaspace::max_allocation_word_size(),
"allocation size too large (" SIZE_FORMAT ")", word_size);
assert(!_frozen, "sanity");

assert(loader_data != NULL, "Should never pass around a NULL loader_data. "
"ClassLoaderData::the_null_class_loader_data() should have been used.");
Expand Down
9 changes: 0 additions & 9 deletions src/hotspot/share/memory/metaspace.hpp
Expand Up @@ -62,22 +62,13 @@ class Metaspace : public AllStatic {

private:

DEBUG_ONLY(static bool _frozen;)

static const MetaspaceTracer* _tracer;

static bool _initialized;

public:

static const MetaspaceTracer* tracer() { return _tracer; }
static void freeze() {
assert(DumpSharedSpaces, "sanity");
DEBUG_ONLY(_frozen = true;)
}
static void assert_not_frozen() {
assert(!_frozen, "sanity");
}

private:

Expand Down

1 comment on commit a8835b9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.