Skip to content

Commit

Permalink
Merge branch 'master' into fix-#8320144
Browse files Browse the repository at this point in the history
  • Loading branch information
biboudis committed Dec 6, 2023
2 parents 9922d38 + 7fbfb3b commit a79a847
Show file tree
Hide file tree
Showing 294 changed files with 9,764 additions and 22,225 deletions.

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion make/modules/jdk.compiler/Gendata.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ CT_MODULES_API_TARGETS := \
$(foreach m, $(CT_MODULES) $(CT_TRANSITIVE_MODULES), \
$(call SetupJavaCompilationApiTarget, $m, $(JDK_OUTPUTDIR)/modules/$m))

#undocumented modules which should also be included in ct.sym:
CT_EXTRA_MODULES := jdk.unsupported

SYMBOL_FILES := $(wildcard $(MODULE_SRC)/share/data/symbols/*)

CT_DATA_DESCRIPTION += $(MODULE_SRC)/share/data/symbols/symbols
Expand Down Expand Up @@ -72,6 +75,7 @@ $(SUPPORT_OUTPUTDIR)/symbols/ct.sym: $(COMPILE_CREATE_SYMBOLS) $(SYMBOL_FILES) \
$(RM) -r $(@D)
$(MKDIR) -p $(@D)
$(ECHO) Creating ct.sym classes
$(ECHO) $(CT_MODULES) $(CT_TRANSITIVE_MODULES) $(CT_EXTRA_MODULES) >$(SUPPORT_OUTPUTDIR)/symbols/included-modules
$(BUILD_JAVA_SMALL) \
$(COMPILECREATESYMBOLS_ADD_EXPORTS) \
-classpath $(BUILDTOOLS_OUTPUTDIR)/create_symbols_javac \
Expand All @@ -82,7 +86,8 @@ $(SUPPORT_OUTPUTDIR)/symbols/ct.sym: $(COMPILE_CREATE_SYMBOLS) $(SYMBOL_FILES) \
$(SOURCE_DATE_EPOCH) \
$(JDK_SOURCE_TARGET_VERSION) \
"$(VERSION_PRE)" \
$(JDK_OUTPUTDIR)/modules/
$(JDK_OUTPUTDIR)/modules/ \
$(SUPPORT_OUTPUTDIR)/symbols/included-modules
$(TOUCH) $@

# Copy ct.sym to the modules libs dir
Expand Down
12 changes: 9 additions & 3 deletions src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ void VM_Version::initialize() {
}
}

// Neoverse N1, N2, V1, V2
// Neoverse
// N1: 0xd0c
// N2: 0xd49
// V1: 0xd40
// V2: 0xd4f
if (_cpu == CPU_ARM && (model_is(0xd0c) || model_is(0xd49) ||
model_is(0xd40) || model_is(0xd4f))) {
if (FLAG_IS_DEFAULT(UseSIMDForMemoryOps)) {
Expand Down Expand Up @@ -235,8 +239,10 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(UseCRC32, false);
}

// Neoverse V1
if (_cpu == CPU_ARM && model_is(0xd40)) {
// Neoverse
// V1: 0xd40
// V2: 0xd4f
if (_cpu == CPU_ARM && (model_is(0xd40) || model_is(0xd4f))) {
if (FLAG_IS_DEFAULT(UseCryptoPmullForCRC32)) {
FLAG_SET_DEFAULT(UseCryptoPmullForCRC32, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/assembler_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class Address {
}

bool xmmindex_needs_rex() const {
return _xmmindex->is_valid() && _xmmindex->encoding() >= 8;
return _xmmindex->is_valid() && ((_xmmindex->encoding() & 8) == 8);
}

relocInfo::relocType reloc() const { return _rspec.type(); }
Expand Down
317 changes: 317 additions & 0 deletions src/hotspot/share/cds/cdsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
#include "cds/cdsConfig.hpp"
#include "cds/heapShared.hpp"
#include "classfile/classLoaderDataShared.hpp"
#include "classfile/moduleEntry.hpp"
#include "include/jvm_io.h"
#include "logging/log.hpp"
#include "runtime/arguments.hpp"
#include "runtime/java.hpp"
#include "utilities/defaultStream.hpp"

bool CDSConfig::_is_dumping_static_archive = false;
bool CDSConfig::_is_dumping_dynamic_archive = false;
Expand All @@ -38,6 +43,318 @@ bool CDSConfig::_is_dumping_dynamic_archive = false;
bool CDSConfig::_dumping_full_module_graph_disabled = false;
bool CDSConfig::_loading_full_module_graph_disabled = false;

char* CDSConfig::_default_archive_path = nullptr;
char* CDSConfig::_static_archive_path = nullptr;
char* CDSConfig::_dynamic_archive_path = nullptr;

void CDSConfig::initialize() {
if (is_dumping_static_archive()) {
if (RequireSharedSpaces) {
warning("Cannot dump shared archive while using shared archive");
}
UseSharedSpaces = false;
}

// Initialize shared archive paths which could include both base and dynamic archive paths
// This must be after set_ergonomics_flags() called so flag UseCompressedOops is set properly.
//
// UseSharedSpaces may be disabled if -XX:SharedArchiveFile is invalid.
if (is_dumping_static_archive() || UseSharedSpaces) {
init_shared_archive_paths();
}
}

char* CDSConfig::default_archive_path() {
if (_default_archive_path == nullptr) {
char jvm_path[JVM_MAXPATHLEN];
os::jvm_path(jvm_path, sizeof(jvm_path));
char *end = strrchr(jvm_path, *os::file_separator());
if (end != nullptr) *end = '\0';
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;
_default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
jio_snprintf(_default_archive_path, len,
LP64_ONLY(!UseCompressedOops ? "%s%sclasses_nocoops.jsa":) "%s%sclasses.jsa",
jvm_path, os::file_separator());
}
return _default_archive_path;
}

int CDSConfig::num_archives(const char* archive_path) {
if (archive_path == nullptr) {
return 0;
}
int npaths = 1;
char* p = (char*)archive_path;
while (*p != '\0') {
if (*p == os::path_separator()[0]) {
npaths++;
}
p++;
}
return npaths;
}

void CDSConfig::extract_shared_archive_paths(const char* archive_path,
char** base_archive_path,
char** top_archive_path) {
char* begin_ptr = (char*)archive_path;
char* end_ptr = strchr((char*)archive_path, os::path_separator()[0]);
if (end_ptr == nullptr || end_ptr == begin_ptr) {
vm_exit_during_initialization("Base archive was not specified", archive_path);
}
size_t len = end_ptr - begin_ptr;
char* cur_path = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
strncpy(cur_path, begin_ptr, len);
cur_path[len] = '\0';
*base_archive_path = cur_path;

begin_ptr = ++end_ptr;
if (*begin_ptr == '\0') {
vm_exit_during_initialization("Top archive was not specified", archive_path);
}
end_ptr = strchr(begin_ptr, '\0');
assert(end_ptr != nullptr, "sanity");
len = end_ptr - begin_ptr;
cur_path = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
strncpy(cur_path, begin_ptr, len + 1);
*top_archive_path = cur_path;
}

void CDSConfig::init_shared_archive_paths() {
if (ArchiveClassesAtExit != nullptr) {
assert(!RecordDynamicDumpInfo, "already checked");
if (is_dumping_static_archive()) {
vm_exit_during_initialization("-XX:ArchiveClassesAtExit cannot be used with -Xshare:dump");
}
check_unsupported_dumping_properties();

if (os::same_files(default_archive_path(), ArchiveClassesAtExit)) {
vm_exit_during_initialization(
"Cannot specify the default CDS archive for -XX:ArchiveClassesAtExit", default_archive_path());
}
}

if (SharedArchiveFile == nullptr) {
_static_archive_path = default_archive_path();
} else {
int archives = num_archives(SharedArchiveFile);
assert(archives > 0, "must be");

if (is_dumping_archive() && archives > 1) {
vm_exit_during_initialization(
"Cannot have more than 1 archive file specified in -XX:SharedArchiveFile during CDS dumping");
}

if (is_dumping_static_archive()) {
assert(archives == 1, "must be");
// Static dump is simple: only one archive is allowed in SharedArchiveFile. This file
// will be overwritten no matter regardless of its contents
_static_archive_path = os::strdup_check_oom(SharedArchiveFile, mtArguments);
} else {
// SharedArchiveFile may specify one or two files. In case (c), the path for base.jsa
// is read from top.jsa
// (a) 1 file: -XX:SharedArchiveFile=base.jsa
// (b) 2 files: -XX:SharedArchiveFile=base.jsa:top.jsa
// (c) 2 files: -XX:SharedArchiveFile=top.jsa
//
// However, if either RecordDynamicDumpInfo or ArchiveClassesAtExit is used, we do not
// allow cases (b) and (c). Case (b) is already checked above.

if (archives > 2) {
vm_exit_during_initialization(
"Cannot have more than 2 archive files specified in the -XX:SharedArchiveFile option");
}
if (archives == 1) {
char* base_archive_path = nullptr;
bool success =
FileMapInfo::get_base_archive_name_from_header(SharedArchiveFile, &base_archive_path);
if (!success) {
// If +AutoCreateSharedArchive and the specified shared archive does not exist,
// regenerate the dynamic archive base on default archive.
if (AutoCreateSharedArchive && !os::file_exists(SharedArchiveFile)) {
enable_dumping_dynamic_archive();
ArchiveClassesAtExit = const_cast<char *>(SharedArchiveFile);
_static_archive_path = default_archive_path();
SharedArchiveFile = nullptr;
} else {
if (AutoCreateSharedArchive) {
warning("-XX:+AutoCreateSharedArchive is unsupported when base CDS archive is not loaded. Run with -Xlog:cds for more info.");
AutoCreateSharedArchive = false;
}
Arguments::no_shared_spaces("invalid archive");
}
} else if (base_archive_path == nullptr) {
// User has specified a single archive, which is a static archive.
_static_archive_path = const_cast<char *>(SharedArchiveFile);
} else {
// User has specified a single archive, which is a dynamic archive.
_dynamic_archive_path = const_cast<char *>(SharedArchiveFile);
_static_archive_path = base_archive_path; // has been c-heap allocated.
}
} else {
extract_shared_archive_paths((const char*)SharedArchiveFile,
&_static_archive_path, &_dynamic_archive_path);
if (_static_archive_path == nullptr) {
assert(_dynamic_archive_path == nullptr, "must be");
Arguments::no_shared_spaces("invalid archive");
}
}

if (_dynamic_archive_path != nullptr) {
// Check for case (c)
if (RecordDynamicDumpInfo) {
vm_exit_during_initialization("-XX:+RecordDynamicDumpInfo is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile",
SharedArchiveFile);
}
if (ArchiveClassesAtExit != nullptr) {
vm_exit_during_initialization("-XX:ArchiveClassesAtExit is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile",
SharedArchiveFile);
}
}

if (ArchiveClassesAtExit != nullptr && os::same_files(SharedArchiveFile, ArchiveClassesAtExit)) {
vm_exit_during_initialization(
"Cannot have the same archive file specified for -XX:SharedArchiveFile and -XX:ArchiveClassesAtExit",
SharedArchiveFile);
}
}
}
}

void CDSConfig::check_system_property(const char* key, const char* value) {
if (Arguments::is_internal_module_property(key)) {
MetaspaceShared::disable_optimized_module_handling();
log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value);
}
if (strcmp(key, "jdk.module.showModuleResolution") == 0 ||
strcmp(key, "jdk.module.validation") == 0 ||
strcmp(key, "java.system.class.loader") == 0) {
disable_loading_full_module_graph();
disable_dumping_full_module_graph();
log_info(cds)("full module graph: disabled due to incompatible property: %s=%s", key, value);
}
}

static const char* unsupported_properties[] = {
"jdk.module.limitmods",
"jdk.module.upgrade.path",
"jdk.module.patch.0"
};
static const char* unsupported_options[] = {
"--limit-modules",
"--upgrade-module-path",
"--patch-module"
};

void CDSConfig::check_unsupported_dumping_properties() {
assert(is_dumping_archive(), "this function is only used with CDS dump time");
assert(ARRAY_SIZE(unsupported_properties) == ARRAY_SIZE(unsupported_options), "must be");
// If a vm option is found in the unsupported_options array, vm will exit with an error message.
SystemProperty* sp = Arguments::system_properties();
while (sp != nullptr) {
for (uint i = 0; i < ARRAY_SIZE(unsupported_properties); i++) {
if (strcmp(sp->key(), unsupported_properties[i]) == 0) {
vm_exit_during_initialization(
"Cannot use the following option when dumping the shared archive", unsupported_options[i]);
}
}
sp = sp->next();
}

// Check for an exploded module build in use with -Xshare:dump.
if (!Arguments::has_jimage()) {
vm_exit_during_initialization("Dumping the shared archive is not supported with an exploded module build");
}
}

bool CDSConfig::check_unsupported_cds_runtime_properties() {
assert(UseSharedSpaces, "this function is only used with -Xshare:{on,auto}");
assert(ARRAY_SIZE(unsupported_properties) == ARRAY_SIZE(unsupported_options), "must be");
if (ArchiveClassesAtExit != nullptr) {
// dynamic dumping, just return false for now.
// check_unsupported_dumping_properties() will be called later to check the same set of
// properties, and will exit the VM with the correct error message if the unsupported properties
// are used.
return false;
}
for (uint i = 0; i < ARRAY_SIZE(unsupported_properties); i++) {
if (Arguments::get_property(unsupported_properties[i]) != nullptr) {
if (RequireSharedSpaces) {
warning("CDS is disabled when the %s option is specified.", unsupported_options[i]);
} else {
log_info(cds)("CDS is disabled when the %s option is specified.", unsupported_options[i]);
}
return true;
}
}
return false;
}

bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) {
if (is_dumping_static_archive()) {
if (!mode_flag_cmd_line) {
// By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
//
// If your classlist is large and you don't care about deterministic dumping, you can use
// -Xshare:dump -Xmixed to improve dumping speed.
Arguments::set_mode_flags(Arguments::_int);
} else if (Arguments::mode() == Arguments::_comp) {
// -Xcomp may use excessive CPU for the test tiers. Also, -Xshare:dump runs a small and fixed set of
// Java code, so there's not much benefit in running -Xcomp.
log_info(cds)("reduced -Xcomp to -Xmixed for static dumping");
Arguments::set_mode_flags(Arguments::_mixed);
}

// String deduplication may cause CDS to iterate the strings in different order from one
// run to another which resulting in non-determinstic CDS archives.
// Disable UseStringDeduplication while dumping CDS archive.
UseStringDeduplication = false;
}

// RecordDynamicDumpInfo is not compatible with ArchiveClassesAtExit
if (ArchiveClassesAtExit != nullptr && RecordDynamicDumpInfo) {
jio_fprintf(defaultStream::output_stream(),
"-XX:+RecordDynamicDumpInfo cannot be used with -XX:ArchiveClassesAtExit.\n");
return false;
}

if (ArchiveClassesAtExit == nullptr && !RecordDynamicDumpInfo) {
disable_dumping_dynamic_archive();
} else {
enable_dumping_dynamic_archive();
}

if (AutoCreateSharedArchive) {
if (SharedArchiveFile == nullptr) {
log_warning(cds)("-XX:+AutoCreateSharedArchive requires -XX:SharedArchiveFile");
return false;
}
if (ArchiveClassesAtExit != nullptr) {
log_warning(cds)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
return false;
}
}

if (UseSharedSpaces && patch_mod_javabase) {
Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
}
if (UseSharedSpaces && check_unsupported_cds_runtime_properties()) {
UseSharedSpaces = false;
}

if (is_dumping_archive()) {
// Always verify non-system classes during CDS dump
if (!BytecodeVerificationRemote) {
BytecodeVerificationRemote = true;
log_info(cds)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
}
}

return true;
}

#if INCLUDE_CDS_JAVA_HEAP
bool CDSConfig::is_dumping_heap() {
// heap dump is not supported in dynamic dump
Expand Down
Loading

0 comments on commit a79a847

Please sign in to comment.