8202951: Implementation of JEP 341: Default CDS Archives
8210592: Convert CDS-mode test sets in tier5 and tier6 to non-CDS-mode tests 8209739: [TESTBUG] javax/imageio/plugins/png/ItxtUtf8Test.java fails with OutOfMemoryError when running in CDS mode Generate the default CDS archive at JDK build time. Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com> Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com> Reviewed-by: erikj, ihse, dholmes, iklam, ccheung, mseledtsov
This commit is contained in:
parent
ec0cbd58f4
commit
57b516dd0e
@ -90,24 +90,32 @@ endif
|
||||
|
||||
$(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
|
||||
$(call DependOnVariable, JDK_MODULES_LIST) $(BASE_RELEASE_FILE)
|
||||
$(ECHO) Creating jdk image
|
||||
$(call LogWarn, Creating jdk image)
|
||||
$(RM) -r $(JDK_IMAGE_DIR)
|
||||
$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jdk, \
|
||||
$(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
|
||||
$(JLINK_JDK_EXTRA_OPTS) \
|
||||
--output $(JDK_IMAGE_DIR) \
|
||||
)
|
||||
ifeq ($(BUILD_CDS_ARCHIVE), true)
|
||||
$(call LogWarn, Creating CDS archive for jdk image)
|
||||
$(JDK_IMAGE_DIR)/bin/java -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO)
|
||||
endif
|
||||
$(TOUCH) $@
|
||||
|
||||
$(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
|
||||
$(call DependOnVariable, JRE_MODULES_LIST) $(BASE_RELEASE_FILE)
|
||||
$(ECHO) Creating legacy jre image
|
||||
$(call LogWarn, Creating legacy jre image)
|
||||
$(RM) -r $(JRE_IMAGE_DIR)
|
||||
$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre, \
|
||||
$(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
|
||||
$(JLINK_JRE_EXTRA_OPTS) \
|
||||
--output $(JRE_IMAGE_DIR) \
|
||||
)
|
||||
ifeq ($(BUILD_CDS_ARCHIVE), true)
|
||||
$(call LogWarn, Creating CDS archive for jre image)
|
||||
$(JRE_IMAGE_DIR)/bin/java -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO)
|
||||
endif
|
||||
$(TOUCH) $@
|
||||
|
||||
TOOL_JRE_TARGETS := $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
|
||||
|
@ -233,6 +233,7 @@ JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
|
||||
JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
|
||||
JDKOPT_EXCLUDE_TRANSLATIONS
|
||||
JDKOPT_ENABLE_DISABLE_MANPAGES
|
||||
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
|
@ -605,3 +605,38 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_MANPAGES],
|
||||
|
||||
AC_SUBST(BUILD_MANPAGES)
|
||||
])
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Disable the default CDS archive generation
|
||||
# cross compilation - disabled
|
||||
# zero - off by default (not a tested configuration)
|
||||
#
|
||||
AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
|
||||
[
|
||||
AC_ARG_ENABLE([cds-archive], [AS_HELP_STRING([--disable-cds-archive],
|
||||
[Set to disable generation of a default CDS archive in the product image @<:@enabled@:>@])])
|
||||
|
||||
AC_MSG_CHECKING([if a default CDS archive should be generated])
|
||||
if test "x$COMPILE_TYPE" = "xcross"; then
|
||||
AC_MSG_RESULT([no, not possible with cross compilation])
|
||||
BUILD_CDS_ARCHIVE="false"
|
||||
elif test "x$enable_cds_archive" = "xyes"; then
|
||||
AC_MSG_RESULT([yes, forced])
|
||||
BUILD_CDS_ARCHIVE="true"
|
||||
elif HOTSPOT_CHECK_JVM_VARIANT(zero); then
|
||||
AC_MSG_RESULT([no])
|
||||
BUILD_CDS_ARCHIVE="false"
|
||||
elif test "x$enable_cds_archive" = "x"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
BUILD_CDS_ARCHIVE="true"
|
||||
elif test "x$enable_cds_archive" = "xno"; then
|
||||
AC_MSG_RESULT([no, forced])
|
||||
BUILD_CDS_ARCHIVE="false"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([--enable-cds_archive can only be yes/no or empty])
|
||||
fi
|
||||
|
||||
AC_SUBST(BUILD_CDS_ARCHIVE)
|
||||
])
|
||||
|
@ -309,6 +309,8 @@ EXCLUDE_TRANSLATIONS := @EXCLUDE_TRANSLATIONS@
|
||||
|
||||
BUILD_MANPAGES := @BUILD_MANPAGES@
|
||||
|
||||
BUILD_CDS_ARCHIVE := @BUILD_CDS_ARCHIVE@
|
||||
|
||||
# The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
|
||||
# it in sync.
|
||||
BOOT_JDK:=@BOOT_JDK@
|
||||
|
@ -385,6 +385,7 @@ compare_general_files() {
|
||||
! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
|
||||
! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \
|
||||
! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \
|
||||
! -name "classes.jsa" \
|
||||
| $GREP -v "./bin/" | $SORT | $FILTER)
|
||||
|
||||
echo Other files with binary differences...
|
||||
|
@ -1749,6 +1749,20 @@ WB_ENTRY(jobject, WB_GetMethodStringOption(JNIEnv* env, jobject wb, jobject meth
|
||||
return NULL;
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jobject, WB_GetDefaultArchivePath(JNIEnv* env, jobject wb))
|
||||
const char* p = Arguments::get_default_shared_archive_path();
|
||||
ThreadToNativeFromVM ttn(thread);
|
||||
jstring path_string = env->NewStringUTF(p);
|
||||
|
||||
CHECK_JNI_EXCEPTION_(env, NULL);
|
||||
|
||||
return path_string;
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsSharingEnabled(JNIEnv* env, jobject wb))
|
||||
return UseSharedSpaces;
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsShared(JNIEnv* env, jobject wb, jobject obj))
|
||||
oop obj_oop = JNIHandles::resolve(obj);
|
||||
return MetaspaceShared::is_archive_object(obj_oop);
|
||||
@ -2185,6 +2199,9 @@ static JNINativeMethod methods[] = {
|
||||
{CC"getMethodStringOption",
|
||||
CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/String;",
|
||||
(void*)&WB_GetMethodStringOption},
|
||||
{CC"getDefaultArchivePath", CC"()Ljava/lang/String;",
|
||||
(void*)&WB_GetDefaultArchivePath},
|
||||
{CC"isSharingEnabled", CC"()Z", (void*)&WB_IsSharingEnabled},
|
||||
{CC"isShared", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
|
||||
{CC"isSharedClass", CC"(Ljava/lang/Class;)Z", (void*)&WB_IsSharedClass },
|
||||
{CC"areSharedStringsIgnored", CC"()Z", (void*)&WB_AreSharedStringsIgnored },
|
||||
|
@ -3450,9 +3450,8 @@ void Arguments::set_shared_spaces_flags() {
|
||||
|
||||
// Sharing support
|
||||
// Construct the path to the archive
|
||||
static char* get_shared_archive_path() {
|
||||
char *shared_archive_path;
|
||||
if (SharedArchiveFile == NULL) {
|
||||
char* Arguments::get_default_shared_archive_path() {
|
||||
char *default_archive_path;
|
||||
char jvm_path[JVM_MAXPATHLEN];
|
||||
os::jvm_path(jvm_path, sizeof(jvm_path));
|
||||
char *end = strrchr(jvm_path, *os::file_separator());
|
||||
@ -3460,11 +3459,18 @@ static char* get_shared_archive_path() {
|
||||
size_t jvm_path_len = strlen(jvm_path);
|
||||
size_t file_sep_len = strlen(os::file_separator());
|
||||
const size_t len = jvm_path_len + file_sep_len + 20;
|
||||
shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
|
||||
if (shared_archive_path != NULL) {
|
||||
jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa",
|
||||
default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
|
||||
if (default_archive_path != NULL) {
|
||||
jio_snprintf(default_archive_path, len, "%s%sclasses.jsa",
|
||||
jvm_path, os::file_separator());
|
||||
}
|
||||
return default_archive_path;
|
||||
}
|
||||
|
||||
static char* get_shared_archive_path() {
|
||||
char *shared_archive_path;
|
||||
if (SharedArchiveFile == NULL) {
|
||||
shared_archive_path = Arguments::get_default_shared_archive_path();
|
||||
} else {
|
||||
shared_archive_path = os::strdup_check_oom(SharedArchiveFile, mtArguments);
|
||||
}
|
||||
|
@ -633,6 +633,7 @@ class Arguments : AllStatic {
|
||||
static char* get_appclasspath() { return _java_class_path->value(); }
|
||||
static void fix_appclasspath();
|
||||
|
||||
static char* get_default_shared_archive_path();
|
||||
|
||||
// Operation modi
|
||||
static Mode mode() { return _mode; }
|
||||
|
@ -178,20 +178,6 @@ ifeq ($(USE_FAILURE_HANDLER), true)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# Optionally create a CDS archive before running tests
|
||||
ifeq ($(GENERATE_CDS_ARCHIVE), true)
|
||||
CDS_ARCHIVE_FILE := $(ABS_TEST_OUTPUT_DIR)/cds_archive.jsa
|
||||
|
||||
$(CDS_ARCHIVE_FILE): $(PRODUCT_HOME)
|
||||
$(PRODUCT_HOME)/bin/java -XX:+UnlockDiagnosticVMOptions \
|
||||
-XX:SharedArchiveFile=$(shell $(GETMIXEDPATH) "$(CDS_ARCHIVE_FILE)") -Xshare:dump
|
||||
|
||||
CDS_VM_ARGS := -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=$(shell $(GETMIXEDPATH) "$(CDS_ARCHIVE_FILE)")
|
||||
JTREG_TEST_OPTIONS += $(addprefix -vmoption:, $(CDS_VM_ARGS))
|
||||
TEST_PREREQS += $(CDS_ARCHIVE_FILE)
|
||||
endif
|
||||
|
||||
# How to create the test bundle (pass or fail, we want to create this)
|
||||
# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
|
||||
ifneq ($(ARCHIVE_BUNDLE), )
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Additional list of quarantined tests when CDS mode enabled.
|
||||
# Additional list of quarantined tests when non-CDS mode enabled.
|
||||
#
|
||||
#############################################################################
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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 Default CDS archive file
|
||||
* @summary JDK platforms/binaries do not support default CDS archive should
|
||||
* not contain classes.jsa in the default location.
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI CheckDefaultArchiveFile
|
||||
*/
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.cds.CDSTestUtils;
|
||||
import jtreg.SkippedException;
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
public class CheckDefaultArchiveFile {
|
||||
public static void main(String[] args) throws Exception {
|
||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||
String osArch = Platform.getOsArch();
|
||||
String vmName = System.getProperty("java.vm.name");
|
||||
String vmString = vmName + "(" + osArch + ")";
|
||||
String jsaString = wb.getDefaultArchivePath();
|
||||
Path jsa = Paths.get(jsaString);
|
||||
if (Platform.isDefaultCDSArchiveSupported()) {
|
||||
if (Files.exists(jsa)) {
|
||||
System.out.println("Passed. " + vmString +
|
||||
": has default classes.jsa file");
|
||||
} else {
|
||||
throw new RuntimeException(vmString + "has no " + jsaString);
|
||||
}
|
||||
} else {
|
||||
throw new SkippedException("Default CDS archive is not supported");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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 Default CDS archive
|
||||
* @summary Sharing should be enabled by default on supported platform/binaries.
|
||||
* No -Xshare:dump is needed. No -Xshare:auto or -Xshare:on in needed.
|
||||
* Verify a set of well-known shared classes.
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI CheckSharingWithDefaultArchive -showversion
|
||||
*/
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
public class CheckSharingWithDefaultArchive {
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!Platform.isDefaultCDSArchiveSupported()) {
|
||||
throw new SkippedException("Supported platform");
|
||||
}
|
||||
|
||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||
String classes[] = {"java.lang.Object",
|
||||
"java.lang.String",
|
||||
"java.lang.Class"};
|
||||
// If maping fails, sharing is disabled
|
||||
if (wb.isSharingEnabled()) {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
Class c = Class.forName(classes[i]);
|
||||
if (wb.isSharedClass(c)) {
|
||||
System.out.println(classes[i] + " is shared.");
|
||||
} else {
|
||||
throw new RuntimeException(classes[i] + " is not shared");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new SkippedException("Sharing is not enabled.");
|
||||
}
|
||||
}
|
||||
}
|
@ -50,8 +50,9 @@ public class TestMutuallyExclusivePlatformPredicates {
|
||||
OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"),
|
||||
VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"),
|
||||
MODE("isInt", "isMixed", "isComp"),
|
||||
IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild",
|
||||
"hasSA", "shouldSAAttach", "isTieredSupported", "areCustomLoadersSupportedForCDS");
|
||||
IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild",
|
||||
"isSlowDebugBuild", "hasSA", "shouldSAAttach", "isTieredSupported",
|
||||
"areCustomLoadersSupportedForCDS", "isDefaultCDSArchiveSupported");
|
||||
|
||||
public final List<String> methodNames;
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @run main ItxtUtf8Test
|
||||
*
|
||||
* @run main/othervm/timeout=10 -Xmx4m ItxtUtf8Test truncate
|
||||
* @run main/othervm/timeout=10 -Xmx6m ItxtUtf8Test truncate
|
||||
*/
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -325,6 +325,19 @@ public class Platform {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDefaultCDSArchiveSupported() {
|
||||
return (is64bit() &&
|
||||
isServer() &&
|
||||
(isLinux() ||
|
||||
isOSX() ||
|
||||
isSolaris() ||
|
||||
isWindows()) &&
|
||||
!isZero() &&
|
||||
!isMinimal() &&
|
||||
!isAArch64() &&
|
||||
!isARM());
|
||||
}
|
||||
|
||||
/*
|
||||
* This should match the #if condition in ClassListParser::load_class_from_source().
|
||||
*/
|
||||
|
@ -512,6 +512,8 @@ public class WhiteBox {
|
||||
public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
|
||||
|
||||
// Sharing & archiving
|
||||
public native String getDefaultArchivePath();
|
||||
public native boolean isSharingEnabled();
|
||||
public native boolean isShared(Object o);
|
||||
public native boolean isSharedClass(Class<?> c);
|
||||
public native boolean areSharedStringsIgnored();
|
||||
|
Loading…
Reference in New Issue
Block a user