Skip to content

Commit

Permalink
8261551: Remove special CDS handling in Metaspace::allocate
Browse files Browse the repository at this point in the history
Reviewed-by: minqi, dholmes, stuefe
  • Loading branch information
iklam committed Mar 26, 2021
1 parent fe8ef32 commit 41657b1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
7 changes: 0 additions & 7 deletions src/hotspot/share/memory/metaspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,13 +822,6 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
}

if (result == NULL) {
if (DumpSharedSpaces) {
// CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
// We should abort to avoid generating a potentially bad archive.
vm_exit_during_cds_dumping(err_msg("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
MetaspaceObj::type_name(type), word_size * BytesPerWord),
err_msg("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize));
}
report_metadata_oome(loader_data, word_size, type, mdtype, THREAD);
assert(HAS_PENDING_EXCEPTION, "sanity");
return NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/memory/metaspaceShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ void MetaspaceShared::prepare_for_dumping() {

// Preload classes from a list, populate the shared spaces and dump to a
// file.
void MetaspaceShared::preload_and_dump(TRAPS) {
void MetaspaceShared::preload_and_dump() {
EXCEPTION_MARK;
ResourceMark rm(THREAD);
preload_and_dump_impl(THREAD);
if (HAS_PENDING_EXCEPTION) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/memory/metaspaceShared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MetaspaceShared : AllStatic {
};

static void prepare_for_dumping() NOT_CDS_RETURN;
static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
static void preload_and_dump() NOT_CDS_RETURN;

private:
static void preload_and_dump_impl(TRAPS) NOT_CDS_RETURN;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
#endif

if (DumpSharedSpaces) {
MetaspaceShared::preload_and_dump(CHECK_JNI_ERR);
MetaspaceShared::preload_and_dump();
ShouldNotReachHere();
}

Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down Expand Up @@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception {
processArgs.add("-XX:MaxMetaspaceSize=1m");
}

String msg = "Failed allocating metaspace object";
String msg = "OutOfMemoryError: Metaspace";
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(processArgs);
CDSTestUtils.executeAndLog(pb, "dump").shouldContain(msg).shouldHaveExitValue(1);
}
Expand Down

1 comment on commit 41657b1

@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.