8292329: Enable CDS shared heap for zero builds

Reviewed-by: shade, erikj, ihse
This commit is contained in:
Ioi Lam 2022-08-24 22:39:52 +00:00
parent 14623c6087
commit 76ee5495cd

View File

@ -114,6 +114,12 @@ $(eval $(call SetupExecute, jlink_jre, \
JLINK_JRE_TARGETS := $(jlink_jre)
# Optimize CDS shared heap for small heap sizes, which are typically used
# for small cloud-based apps that have the most critical start-up requirement.
# The trade-off is that when larger heap sizes are used, the shared heap
# may need to be relocated at runtime.
CDS_DUMP_FLAGS = -Xmx128M -Xms128M
# Helper function for creating the CDS archives for the JDK and JRE
#
# Param1 - VM variant (e.g., server, client, zero, ...)
@ -122,6 +128,9 @@ define CreateCDSArchive
$1_$2_DUMP_EXTRA_ARG := $(if $(filter _nocoops, $2),-XX:-UseCompressedOops,)
$1_$2_DUMP_TYPE := $(if $(filter _nocoops, $2),-NOCOOPS,)
# Only G1 supports dumping the shared heap, so explicitly use G1 if the JVM supports it.
$1_$2_CDS_DUMP_FLAGS := $(CDS_DUMP_FLAGS) $(if $(filter g1gc, $(JVM_FEATURES_$1)),-XX:+UseG1GC)
ifeq ($(OPENJDK_TARGET_OS), windows)
$1_$2_CDS_ARCHIVE := bin/$1/classes$2.jsa
else
@ -130,24 +139,26 @@ define CreateCDSArchive
$$(eval $$(call SetupExecute, $1_$2_gen_cds_archive_jdk, \
WARN := Creating CDS$$($1_$2_DUMP_TYPE) archive for jdk image for $1, \
INFO := Using CDS flags for $1: $$($1_$2_CDS_DUMP_FLAGS), \
DEPS := $$(jlink_jdk), \
OUTPUT_FILE := $$(JDK_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE), \
SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/images/jdk, \
COMMAND := $$(FIXPATH) $$(JDK_IMAGE_DIR)/bin/java -Xshare:dump \
-XX:SharedArchiveFile=$$(JDK_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE) \
-$1 $$($1_$2_DUMP_EXTRA_ARG) -Xmx128M -Xms128M $$(LOG_INFO), \
-$1 $$($1_$2_DUMP_EXTRA_ARG) $$($1_$2_CDS_DUMP_FLAGS) $$(LOG_INFO), \
))
JDK_TARGETS += $$($1_$2_gen_cds_archive_jdk)
$$(eval $$(call SetupExecute, $1_$2_gen_cds_archive_jre, \
WARN := Creating CDS$$($1_$2_DUMP_TYPE) archive for jre image for $1, \
INFO := Using CDS flags for $1: $$($1_$2_CDS_DUMP_FLAGS), \
DEPS := $$(jlink_jre), \
OUTPUT_FILE := $$(JRE_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE), \
SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/images/jre, \
COMMAND := $$(FIXPATH) $$(JRE_IMAGE_DIR)/bin/java -Xshare:dump \
-XX:SharedArchiveFile=$$(JRE_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE) \
-$1 $$($1_$2_DUMP_EXTRA_ARG) -Xmx128M -Xms128M $$(LOG_INFO), \
-$1 $$($1_$2_DUMP_EXTRA_ARG) $$($1_$2_CDS_DUMP_FLAGS) $$(LOG_INFO), \
))
JRE_TARGETS += $$($1_$2_gen_cds_archive_jre)