Skip to content

Commit 12a0dd0

Browse files
author
Vladimir Kozlov
committed
8358738: AOT cache created without graal jit should not be used with graal jit
Reviewed-by: iklam, ccheung
1 parent 366650a commit 12a0dd0

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/hotspot/share/cds/filemap.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "classfile/systemDictionaryShared.hpp"
4545
#include "classfile/vmClasses.hpp"
4646
#include "classfile/vmSymbols.hpp"
47+
#include "compiler/compilerDefinitions.inline.hpp"
4748
#include "jvm.h"
4849
#include "logging/log.hpp"
4950
#include "logging/logMessage.hpp"
@@ -232,6 +233,8 @@ void FileMapHeader::populate(FileMapInfo *info, size_t core_region_alignment,
232233
} else {
233234
_narrow_klass_pointer_bits = _narrow_klass_shift = -1;
234235
}
236+
// Which JIT compier is used
237+
_compiler_type = (u1)CompilerConfig::compiler_type();
235238
_type_profile_level = TypeProfileLevel;
236239
_type_profile_args_limit = TypeProfileArgsLimit;
237240
_type_profile_parms_limit = TypeProfileParmsLimit;
@@ -1935,6 +1938,23 @@ bool FileMapHeader::validate() {
19351938
CompactStrings ? "enabled" : "disabled");
19361939
return false;
19371940
}
1941+
bool jvmci_compiler_is_enabled = CompilerConfig::is_jvmci_compiler_enabled();
1942+
CompilerType compiler_type = CompilerConfig::compiler_type();
1943+
CompilerType archive_compiler_type = CompilerType(_compiler_type);
1944+
// JVMCI compiler does different type profiling settigns and generate
1945+
// different code. We can't use archive which was produced
1946+
// without it and reverse.
1947+
// Only allow mix when JIT compilation is disabled.
1948+
// Interpreter is used by default when dumping archive.
1949+
bool intepreter_is_used = (archive_compiler_type == CompilerType::compiler_none) ||
1950+
(compiler_type == CompilerType::compiler_none);
1951+
if (!intepreter_is_used &&
1952+
jvmci_compiler_is_enabled != (archive_compiler_type == CompilerType::compiler_jvmci)) {
1953+
MetaspaceShared::report_loading_error("The %s's JIT compiler setting (%s)"
1954+
" does not equal the current setting (%s).", file_type,
1955+
compilertype2name(archive_compiler_type), compilertype2name(compiler_type));
1956+
return false;
1957+
}
19381958
if (TrainingData::have_data()) {
19391959
if (_type_profile_level != TypeProfileLevel) {
19401960
MetaspaceShared::report_loading_error("The %s's TypeProfileLevel setting (%d)"

src/hotspot/share/cds/filemap.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class FileMapHeader: private CDSFileMapHeaderBase {
147147
size_t _ro_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the ro region
148148

149149
// The following are parameters that affect MethodData layout.
150+
u1 _compiler_type;
150151
uint _type_profile_level;
151152
int _type_profile_args_limit;
152153
int _type_profile_parms_limit;

src/hotspot/share/compiler/compilerDefinitions.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class CompilerConfig : public AllStatic {
149149
inline static bool is_c2_or_jvmci_compiler_only();
150150
inline static bool is_c2_or_jvmci_compiler_enabled();
151151

152+
inline static CompilerType compiler_type();
153+
152154
private:
153155
static bool is_compilation_mode_selected();
154156
static void set_compilation_policy_flags();

src/hotspot/share/compiler/compilerDefinitions.inline.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,17 @@ inline bool CompilerConfig::is_c2_or_jvmci_compiler_enabled() {
131131
return is_c2_enabled() || is_jvmci_compiler_enabled();
132132
}
133133

134+
// Return type of most optimizing compiler which is used
135+
inline CompilerType CompilerConfig::compiler_type() {
136+
CompilerType compiler_type = CompilerType::compiler_none; // Interpreter only
137+
if (CompilerConfig::is_c2_enabled()) {
138+
compiler_type = CompilerType::compiler_c2;
139+
} else if (CompilerConfig::is_jvmci_compiler_enabled()) {
140+
compiler_type = CompilerType::compiler_jvmci;
141+
} else if (CompilerConfig::is_c1_enabled()) {
142+
compiler_type = CompilerType::compiler_c1;
143+
}
144+
return compiler_type;
145+
}
146+
134147
#endif // SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP

0 commit comments

Comments
 (0)