Skip to content
Permalink
Browse files
8272290: [lworld] Disable CDS if InlineTypePassFieldsAsArgs has changed
Reviewed-by: mchung, fparain
  • Loading branch information
iklam committed Aug 16, 2021
1 parent f85b10b commit a5516c19ad4973eebc1f0c38a6b48d067413a0a4
Showing with 109 additions and 2 deletions.
  1. +71 −0 src/hotspot/share/cds/filemap.cpp
  2. +34 −0 src/hotspot/share/cds/filemap.hpp
  3. +4 −2 src/hotspot/share/runtime/arguments.cpp
@@ -130,6 +130,71 @@ void FileMapInfo::fail_continue(const char *msg, ...) {
va_end(ap);
}

inline void CDSMustMatchFlags::do_print(outputStream* st, bool v) {
st->print("%s", v ? "true" : "false");
}

inline void CDSMustMatchFlags::do_print(outputStream* st, intx v) {
st->print(INTX_FORMAT, v);
}

inline void CDSMustMatchFlags::do_print(outputStream* st, uintx v) {
st->print(UINTX_FORMAT, v);
}

inline void CDSMustMatchFlags::do_print(outputStream* st, double v) {
st->print("%f", v);
}

void CDSMustMatchFlags::init() {
Arguments::assert_is_dumping_archive();
_max_name_width = 0;

#define INIT_CDS_MUST_MATCH_FLAG(n) \
_v_##n = n; \
_max_name_width = MAX2(_max_name_width,strlen(#n));
CDS_MUST_MATCH_FLAGS_DO(INIT_CDS_MUST_MATCH_FLAG);
#undef INIT_CDS_MUST_MATCH_FLAG
}

bool CDSMustMatchFlags::runtime_check() const {
#define CHECK_CDS_MUST_MATCH_FLAG(n) \
if (_v_##n != n) { \
ResourceMark rm; \
stringStream ss; \
ss.print("VM option %s is different between dumptime (", #n); \
do_print(&ss, _v_ ## n); \
ss.print(") and runtime ("); \
do_print(&ss, n); \
ss.print(")"); \
FileMapInfo::fail_continue("%s", ss.as_string()); \
return false; \
}
CDS_MUST_MATCH_FLAGS_DO(CHECK_CDS_MUST_MATCH_FLAG);
#undef CHECK_CDS_MUST_MATCH_FLAG

return true;
}

void CDSMustMatchFlags::print_info() const {
LogTarget(Info, cds) lt;
if (lt.is_enabled()) {
LogStream ls(lt);
ls.print_cr("Recorded VM flags during dumptime:");
print(&ls);
}
}

void CDSMustMatchFlags::print(outputStream* st) const {
#define PRINT_CDS_MUST_MATCH_FLAG(n) \
st->print("- %-s ", #n); \
st->sp(int(_max_name_width - strlen(#n))); \
do_print(st, _v_##n); \
st->cr();
CDS_MUST_MATCH_FLAGS_DO(PRINT_CDS_MUST_MATCH_FLAG);
#undef PRINT_CDS_MUST_MATCH_FLAG
}

// Fill in the fileMapInfo structure with data about this VM instance.

// This method copies the vm version info into header_version. If the version is too
@@ -248,6 +313,7 @@ void FileMapHeader::populate(FileMapInfo* mapinfo, size_t core_region_alignment)
// the following 2 fields will be set in write_header for dynamic archive header
_base_archive_name_size = 0;
_base_archive_is_default = false;
_must_match.init();

if (!DynamicDumpSharedSpaces) {
set_shared_path_table(mapinfo->_shared_path_table);
@@ -302,6 +368,7 @@ void FileMapHeader::print(outputStream* st) {
st->print_cr("- use_optimized_module_handling: %d", _use_optimized_module_handling);
st->print_cr("- use_full_module_graph %d", _use_full_module_graph);
st->print_cr("- ptrmap_size_in_bits: " SIZE_FORMAT, _ptrmap_size_in_bits);
_must_match.print(st);
}

void SharedClassPathEntry::init_as_non_existent(const char* path, TRAPS) {
@@ -1183,6 +1250,10 @@ bool FileMapInfo::init_from_file(int fd) {
}
}

if (!header()->check_must_match_flags()) {
return false;
}

return true;
}

@@ -29,6 +29,7 @@
#include "include/cds.h"
#include "oops/array.hpp"
#include "oops/compressedOops.hpp"
#include "runtime/globals.hpp"
#include "utilities/align.hpp"

// To understand the layout of the CDS archive file:
@@ -179,6 +180,34 @@ class FileMapRegion: private CDSFileMapRegion {
void print(outputStream* st, int region_index);
};

#define CDS_MUST_MATCH_FLAGS_DO(f) \
f(EnableValhalla) \
f(FlatArrayElementMaxOops) \
f(FlatArrayElementMaxSize) \
f(InlineFieldMaxFlatSize) \
f(InlineTypePassFieldsAsArgs) \
f(InlineTypeReturnedAsFields)

class CDSMustMatchFlags {
private:
size_t _max_name_width;
#define DECLARE_CDS_MUST_MATCH_FLAG(n) \
decltype(n) _v_##n;
CDS_MUST_MATCH_FLAGS_DO(DECLARE_CDS_MUST_MATCH_FLAG);
#undef DECLARE_CDS_MUST_MATCH_FLAG

inline static void do_print(outputStream* st, bool v);
inline static void do_print(outputStream* st, intx v);
inline static void do_print(outputStream* st, uintx v);
inline static void do_print(outputStream* st, double v);
void print_info() const;

public:
void init();
bool runtime_check() const;
void print(outputStream* st) const;
};

class FileMapHeader: private CDSFileMapHeaderBase {
friend class CDSOffsets;
friend class VMStructs;
@@ -238,6 +267,7 @@ class FileMapHeader: private CDSFileMapHeaderBase {
bool _use_full_module_graph; // Can we use the full archived module graph?
size_t _ptrmap_size_in_bits; // Size of pointer relocation bitmap
narrowOop _heap_obj_roots; // An objArray that stores all the roots of archived heap objects
CDSMustMatchFlags _must_match; // These flags must be the same between dumptime and runtime
char* from_mapped_offset(size_t offset) const {
return mapped_base_address() + offset;
}
@@ -323,6 +353,10 @@ class FileMapHeader: private CDSFileMapHeaderBase {
return (0 <= region && region < NUM_CDS_REGIONS);
}

bool check_must_match_flags() const {
return _must_match.runtime_check();
}

void print(outputStream* st);
};

@@ -4065,8 +4065,10 @@ jint Arguments::apply_ergo() {
log_info(verification)("Turning on remote verification because local verification is on");
FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
}
if (!EnableValhalla || (is_interpreter_only() && !is_dumping_archive())) {
// Disable calling convention optimizations if inline types are not supported
if (!EnableValhalla || (is_interpreter_only() && !is_dumping_archive() && !UseSharedSpaces)) {
// Disable calling convention optimizations if inline types are not supported.
// Also these aren't useful in -Xint. However, don't disable them when dumping or using
// the CDS archive, as the values must match between dumptime and runtime.
InlineTypePassFieldsAsArgs = false;
InlineTypeReturnedAsFields = false;
}

0 comments on commit a5516c1

Please sign in to comment.