8277481: Obsolete seldom used CDS flags
Reviewed-by: iklam, ccheung, dholmes
This commit is contained in:
parent
23fd9f15da
commit
14f7385a72
src
hotspot/share
java.base/share/classes/jdk/internal/misc
jdk.hotspot.agent/share
test/hotspot/jtreg/runtime/cds
@ -1514,7 +1514,7 @@ static void no_shared_spaces(const char* message) {
|
||||
vm_exit_during_initialization("Unable to use shared archive", message);
|
||||
} else {
|
||||
log_info(cds)("Unable to use shared archive: %s", message);
|
||||
FLAG_SET_DEFAULT(UseSharedSpaces, false);
|
||||
UseSharedSpaces = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2703,33 +2703,19 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
set_mode_flags(_comp);
|
||||
// -Xshare:dump
|
||||
} else if (match_option(option, "-Xshare:dump")) {
|
||||
if (FLAG_SET_CMDLINE(DumpSharedSpaces, true) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
DumpSharedSpaces = true;
|
||||
// -Xshare:on
|
||||
} else if (match_option(option, "-Xshare:on")) {
|
||||
if (FLAG_SET_CMDLINE(UseSharedSpaces, true) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
if (FLAG_SET_CMDLINE(RequireSharedSpaces, true) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
UseSharedSpaces = true;
|
||||
RequireSharedSpaces = true;
|
||||
// -Xshare:auto || -XX:ArchiveClassesAtExit=<archive file>
|
||||
} else if (match_option(option, "-Xshare:auto")) {
|
||||
if (FLAG_SET_CMDLINE(UseSharedSpaces, true) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
if (FLAG_SET_CMDLINE(RequireSharedSpaces, false) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
UseSharedSpaces = true;
|
||||
RequireSharedSpaces = false;
|
||||
// -Xshare:off
|
||||
} else if (match_option(option, "-Xshare:off")) {
|
||||
if (FLAG_SET_CMDLINE(UseSharedSpaces, false) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
if (FLAG_SET_CMDLINE(RequireSharedSpaces, false) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
UseSharedSpaces = false;
|
||||
RequireSharedSpaces = false;
|
||||
// -Xverify
|
||||
} else if (match_option(option, "-Xverify", &tail)) {
|
||||
if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) {
|
||||
@ -2983,12 +2969,8 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
// -Xshare:on
|
||||
// -Xlog:class+path=info
|
||||
if (PrintSharedArchiveAndExit) {
|
||||
if (FLAG_SET_CMDLINE(UseSharedSpaces, true) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
if (FLAG_SET_CMDLINE(RequireSharedSpaces, true) != JVMFlag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
UseSharedSpaces = true;
|
||||
RequireSharedSpaces = true;
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
|
||||
}
|
||||
|
||||
@ -3144,11 +3126,11 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
|
||||
#if INCLUDE_CDS
|
||||
if (DumpSharedSpaces) {
|
||||
// Compiler threads may concurrently update the class metadata (such as method entries), so it's
|
||||
// unsafe with DumpSharedSpaces (which modifies the class metadata in place). Let's disable
|
||||
// unsafe with -Xshare:dump (which modifies the class metadata in place). Let's disable
|
||||
// compiler just to be safe.
|
||||
//
|
||||
// Note: this is not a concern for DynamicDumpSharedSpaces, which makes a copy of the class metadata
|
||||
// instead of modifying them in place. The copy is inaccessible to the compiler.
|
||||
// Note: this is not a concern for dynamically dumping shared spaces, which makes a copy of the
|
||||
// class metadata instead of modifying them in place. The copy is inaccessible to the compiler.
|
||||
// TODO: revisit the following for the static archive case.
|
||||
set_mode_flags(_int);
|
||||
}
|
||||
@ -3161,16 +3143,16 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
|
||||
}
|
||||
|
||||
if (ArchiveClassesAtExit == NULL && !RecordDynamicDumpInfo) {
|
||||
FLAG_SET_DEFAULT(DynamicDumpSharedSpaces, false);
|
||||
DynamicDumpSharedSpaces = false;
|
||||
} else {
|
||||
FLAG_SET_DEFAULT(DynamicDumpSharedSpaces, true);
|
||||
DynamicDumpSharedSpaces = true;
|
||||
}
|
||||
|
||||
if (UseSharedSpaces && patch_mod_javabase) {
|
||||
no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
|
||||
}
|
||||
if (UseSharedSpaces && !DumpSharedSpaces && check_unsupported_cds_runtime_properties()) {
|
||||
FLAG_SET_DEFAULT(UseSharedSpaces, false);
|
||||
UseSharedSpaces = false;
|
||||
}
|
||||
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
@ -4013,7 +3995,7 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
|
||||
if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) ||
|
||||
log_is_enabled(Info, cds)) {
|
||||
warning("Shared spaces are not supported in this VM");
|
||||
FLAG_SET_DEFAULT(UseSharedSpaces, false);
|
||||
UseSharedSpaces = false;
|
||||
LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(cds));
|
||||
}
|
||||
no_shared_spaces("CDS Disabled");
|
||||
|
@ -1805,23 +1805,9 @@ const intx ObjectAlignmentInBytes = 8;
|
||||
\
|
||||
/* Shared spaces */ \
|
||||
\
|
||||
product(bool, UseSharedSpaces, true, \
|
||||
"(Deprecated) Use shared spaces for metadata") \
|
||||
\
|
||||
product(bool, VerifySharedSpaces, false, \
|
||||
"Verify integrity of shared spaces") \
|
||||
\
|
||||
product(bool, RequireSharedSpaces, false, \
|
||||
"(Deprecated) Require shared spaces for metadata") \
|
||||
\
|
||||
product(bool, DumpSharedSpaces, false, \
|
||||
"(Deprecated) Special mode: JVM reads a class list, loads " \
|
||||
"classes, builds shared spaces, and dumps the shared spaces to " \
|
||||
"a file to be used in future JVM runs") \
|
||||
\
|
||||
product(bool, DynamicDumpSharedSpaces, false, \
|
||||
"(Deprecated) Dynamic archive") \
|
||||
\
|
||||
product(bool, RecordDynamicDumpInfo, false, \
|
||||
"Record class info for jcmd VM.cds dynamic_dump") \
|
||||
\
|
||||
|
@ -39,6 +39,14 @@ int LogBitsPerHeapOop = 0;
|
||||
int BytesPerHeapOop = 0;
|
||||
int BitsPerHeapOop = 0;
|
||||
|
||||
// Old CDS options
|
||||
bool DumpSharedSpaces;
|
||||
bool DynamicDumpSharedSpaces;
|
||||
bool RequireSharedSpaces;
|
||||
extern "C" {
|
||||
JNIEXPORT jboolean UseSharedSpaces = true;
|
||||
}
|
||||
|
||||
// Object alignment, in units of HeapWords.
|
||||
// Defaults are -1 so things will break badly if incorrectly initialized.
|
||||
int MinObjAlignment = -1;
|
||||
|
@ -508,6 +508,16 @@ const jfloat max_jfloat = jfloat_cast(max_jintFloat);
|
||||
|
||||
const int max_method_code_size = 64*K - 1; // JVM spec, 2nd ed. section 4.8.1 (p.134)
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// old CDS options
|
||||
extern bool DumpSharedSpaces;
|
||||
extern bool DynamicDumpSharedSpaces;
|
||||
extern bool RequireSharedSpaces;
|
||||
extern "C" {
|
||||
// Make sure UseSharedSpaces is accessible to the serviceability agent.
|
||||
extern JNIEXPORT jboolean UseSharedSpaces;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Object alignment, in units of HeapWords.
|
||||
//
|
||||
|
@ -66,7 +66,7 @@ public class CDS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Is sharing enabled via the UseSharedSpaces flag.
|
||||
* Is sharing enabled.
|
||||
*/
|
||||
public static boolean isSharingEnabled() {
|
||||
return isSharingEnabled;
|
||||
@ -232,15 +232,11 @@ public class CDS {
|
||||
|
||||
private static String[] excludeFlags = {
|
||||
"-XX:DumpLoadedClassList=",
|
||||
"-XX:+DumpSharedSpaces",
|
||||
"-XX:+DynamicDumpSharedSpaces",
|
||||
"-XX:+RecordDynamicDumpInfo",
|
||||
"-Xshare:",
|
||||
"-XX:SharedClassListFile=",
|
||||
"-XX:SharedArchiveFile=",
|
||||
"-XX:ArchiveClassesAtExit=",
|
||||
"-XX:+UseSharedSpaces",
|
||||
"-XX:+RequireSharedSpaces"};
|
||||
"-XX:ArchiveClassesAtExit="};
|
||||
private static boolean containsExcludedFlags(String testStr) {
|
||||
for (String e : excludeFlags) {
|
||||
if (testStr.contains(e)) {
|
||||
|
@ -943,9 +943,13 @@ public class VM {
|
||||
|
||||
public boolean isSharingEnabled() {
|
||||
if (sharingEnabled == null) {
|
||||
Flag flag = getCommandLineFlag("UseSharedSpaces");
|
||||
sharingEnabled = (flag == null)? Boolean.FALSE :
|
||||
(flag.getBool()? Boolean.TRUE: Boolean.FALSE);
|
||||
Address address = VM.getVM().getDebugger().lookup(null, "UseSharedSpaces");
|
||||
if (address == null && getOS().equals("win32")) {
|
||||
// On Win32 symbols are prefixed with the dll name. So look for
|
||||
// UseSharedSpaces as a symbol in jvm.dll.
|
||||
address = VM.getVM().getDebugger().lookup(null, "jvm!UseSharedSpaces");
|
||||
}
|
||||
sharingEnabled = address.getJBooleanAt(0);
|
||||
}
|
||||
return sharingEnabled.booleanValue();
|
||||
}
|
||||
|
@ -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
|
||||
@ -300,7 +300,7 @@ bool init_classsharing_workaround(struct ps_prochandle* ph) {
|
||||
jvm_name = lib->name;
|
||||
useSharedSpacesAddr = lookup_symbol(ph, jvm_name, USE_SHARED_SPACES_SYM);
|
||||
if (useSharedSpacesAddr == 0) {
|
||||
print_debug("can't lookup 'UseSharedSpaces' flag\n");
|
||||
print_debug("can't lookup 'UseSharedSpaces' symbol\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ bool init_classsharing_workaround(struct ps_prochandle* ph) {
|
||||
// using equivalent type jboolean to read the value of
|
||||
// UseSharedSpaces which is same as hotspot type "bool".
|
||||
if (read_jboolean(ph, useSharedSpacesAddr, &useSharedSpaces) != true) {
|
||||
print_debug("can't read the value of 'UseSharedSpaces' flag\n");
|
||||
print_debug("can't read the value of 'UseSharedSpaces' symbol\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -45,12 +45,6 @@ public class SharedArchiveFile {
|
||||
.setArchiveName("./SharedArchiveFile.jsa");
|
||||
CDSTestUtils.createArchiveAndCheck(opts);
|
||||
|
||||
// -XX:+DumpSharedSpaces should behave the same as -Xshare:dump
|
||||
opts = (new CDSOptions())
|
||||
.addPrefix("-XX:+DumpSharedSpaces", "-Xlog:cds")
|
||||
.setArchiveName("./SharedArchiveFile.jsa");
|
||||
CDSTestUtils.createArchiveAndCheck(opts);
|
||||
|
||||
opts = (new CDSOptions())
|
||||
.setArchiveName("./SharedArchiveFile.jsa");
|
||||
CDSTestUtils.run(opts)
|
||||
|
@ -280,10 +280,10 @@ class DynamicArchiveTestBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the UseSharedSpaces flag has been disabled.
|
||||
* Return true if sharing has been disabled.
|
||||
* By default, the VM will be started with -Xshare:auto.
|
||||
* The UseSharedSpaces flag will be disabled by the VM if there's some
|
||||
* problem in using the default CDS archive. It could happen under some
|
||||
* Sharing will be disabled by the VM if there's some problem
|
||||
* in using the default CDS archive. It could happen under some
|
||||
* situations such as follows:
|
||||
* - the default CDS archive wasn't generated during build time because
|
||||
* the JDK was built via cross-compilation on a different platform;
|
||||
@ -294,6 +294,6 @@ class DynamicArchiveTestBase {
|
||||
* enabled when the default CDS archive was built.
|
||||
*/
|
||||
public static boolean isUseSharedSpacesDisabled() {
|
||||
return (WB.getBooleanVMFlag("UseSharedSpaces") == false);
|
||||
return !WB.isSharingEnabled();
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary The DynamicDumpShareSpaces flag is internal, setting it at the command line should have no effect.
|
||||
* @requires vm.cds
|
||||
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
||||
* @compile ../test-classes/Hello.java
|
||||
* @run driver DynamicFlag
|
||||
*/
|
||||
|
||||
public class DynamicFlag {
|
||||
public static void main(String[] args) throws Exception {
|
||||
TestCommon.test(JarBuilder.getOrCreateHelloJar(),
|
||||
TestCommon.list("Hello"), "-XX:+DynamicDumpSharedSpaces", "Hello");
|
||||
}
|
||||
}
|
@ -96,7 +96,7 @@ public abstract class JCmdTestDumpBase {
|
||||
}
|
||||
|
||||
private static void checkCDSEnabled() throws Exception {
|
||||
boolean cdsEnabled = WhiteBox.getWhiteBox().getBooleanVMFlag("UseSharedSpaces");
|
||||
boolean cdsEnabled = WhiteBox.getWhiteBox().isSharingEnabled();
|
||||
if (!cdsEnabled) {
|
||||
throw new SkippedException("CDS is not available for this JDK.");
|
||||
}
|
||||
|
@ -81,20 +81,13 @@ public class JCmdTestDynamicDump extends JCmdTestDumpBase {
|
||||
test(null, pid, noBoot, EXPECT_PASS, DYNAMIC_MESSAGES);
|
||||
app.stopApp();
|
||||
|
||||
// Test dynamic dump with flags -XX:+RecordDynamicDumpInfo -XX:-DynamicDumpSharedSpaces.
|
||||
print2ln(test_count++ + " Test dynamic dump with flags -XX:+RecordDynamicDumpInfo -XX:-DynamicDumpSharedSpaces.");
|
||||
app = createLingeredApp("-cp", allJars, "-XX:+RecordDynamicDumpInfo", "-XX:-DynamicDumpSharedSpaces");
|
||||
// Test dynamic dump with flag -XX:+RecordDynamicDumpInfo
|
||||
print2ln(test_count++ + " Test dynamic dump with flag -XX:+RecordDynamicDumpInfo.");
|
||||
app = createLingeredApp("-cp", allJars, "-XX:+RecordDynamicDumpInfo");
|
||||
pid = app.getPid();
|
||||
test(null, pid, noBoot, EXPECT_PASS, DYNAMIC_MESSAGES);
|
||||
app.stopApp();
|
||||
|
||||
// Test dynamic dump with flags -XX:-DynamicDumpSharedSpaces -XX:+RecordDynamicDumpInfo.
|
||||
print2ln(test_count++ + " Test dynamic dump with flags -XX:-DynamicDumpSharedSpaces -XX:+RecordDynamicDumpInfo.");
|
||||
app = createLingeredApp("-cp", allJars, "-XX:-DynamicDumpSharedSpaces", "-XX:+RecordDynamicDumpInfo");
|
||||
pid = app.getPid();
|
||||
test(null, pid, noBoot, EXPECT_PASS, DYNAMIC_MESSAGES);
|
||||
app.stopApp();
|
||||
|
||||
// Test dynamic with -Xbootclasspath/a:boot.jar
|
||||
print2ln(test_count++ + " Test dynamic with -Xbootclasspath/a:boot.jar");
|
||||
app = createLingeredApp("-cp", testJar, "-Xbootclasspath/a:" + bootJar, "-XX:+RecordDynamicDumpInfo");
|
||||
|
@ -45,25 +45,19 @@ public class JCmdTestStaticDump extends JCmdTestDumpBase {
|
||||
"LingeredApp source: shared objects file",
|
||||
"Hello source: shared objects file"};
|
||||
|
||||
// Those two flags will not create a successful LingeredApp.
|
||||
// This flag will not create a successful LingeredApp.
|
||||
private static String[] noDumpFlags =
|
||||
{"-XX:+DumpSharedSpaces",
|
||||
"-Xshare:dump"};
|
||||
{"-Xshare:dump"};
|
||||
// Those flags will be excluded in static dumping,
|
||||
// See src/java.base/share/classes/jdk/internal/misc/CDS.java
|
||||
private static String[] excludeFlags = {
|
||||
"-XX:DumpLoadedClassList=AnyFileName.classlist",
|
||||
// this flag just dump archive, won't run app normally.
|
||||
// "-XX:+DumpSharedSpaces",
|
||||
"-XX:+DynamicDumpSharedSpaces",
|
||||
"-XX:+RecordDynamicDumpInfo",
|
||||
"-Xshare:on",
|
||||
"-Xshare:auto",
|
||||
"-XX:SharedClassListFile=non-exist.classlist",
|
||||
"-XX:SharedArchiveFile=non-exist.jsa",
|
||||
"-XX:ArchiveClassesAtExit=tmp.jsa",
|
||||
"-XX:+UseSharedSpaces",
|
||||
"-XX:+RequireSharedSpaces"};
|
||||
"-XX:ArchiveClassesAtExit=tmp.jsa"};
|
||||
|
||||
// Times to dump cds against same process.
|
||||
private static final int ITERATION_TIMES = 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user