Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/hotspot/share/compiler/compilationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,10 @@ CompLevel CompilationPolicy::trained_transition_from_none(const methodHandle& me
return CompLevel_none;
}

if (PreloadAndC1Only) {
return CompLevel_simple;
}

bool training_has_profile = (mtd->final_profile() != nullptr);
if (mtd->saw_level(CompLevel_full_optimization) && !training_has_profile) {
return CompLevel_full_profile;
Expand Down Expand Up @@ -1452,6 +1456,9 @@ CompLevel CompilationPolicy::transition_from_none(const methodHandle& method, Co
CompLevel next_level = cur_level;
int i = method->invocation_count();
int b = method->backedge_count();
if (PreloadAndC1Only) {
return CompLevel_simple;
}
// If we were at full profile level, would we switch to full opt?
if (transition_from_full_profile<Predicate>(method, CompLevel_full_profile) == CompLevel_full_optimization) {
next_level = CompLevel_full_optimization;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/compiler/compilerDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@ void CompilerConfig::ergo_initialize() {
FLAG_SET_DEFAULT(ProfileInterpreter, false);
FLAG_SET_DEFAULT(UseOnStackReplacement, false);
FLAG_SET_DEFAULT(UseLoopCounter, false);
}

if (PreloadOnly || PreloadAndC1Only) {
// Disable compilations through training data replay.
FLAG_SET_DEFAULT(AOTReplayTraining, false);
}
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/compiler/compiler_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@
"Use preload code exclusively. This effectively disables most of "\
"profiling and JIT compilation, running close to AOT-only mode.") \
\
product(bool, PreloadAndC1Only, false, EXPERIMENTAL, \
"Use preload code and C1 compiles. This effectively disables any "\
"C2 use in production mode.") \
\

// end of COMPILER_FLAGS

Expand Down
17 changes: 11 additions & 6 deletions src/hotspot/share/compiler/precompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,22 @@ class PrecompileIterator : StackObj {
int high_top_level = highest_top_level(m);
switch (_comp_level) {
case CompLevel_simple:
case CompLevel_full_optimization:
// For final C1/C2 compilations, we only compile when there was relevant compilation during training.
return _comp_level == high_top_level;
case CompLevel_limited_profile:
// For profiled C1 compilations, generate limited profile when there was limited/full
// profiled compilation in training.
return CompLevel_limited_profile <= high_top_level && high_top_level <= CompLevel_full_profile;
// Depending on what the tiered policy needs at runtime, we might need
// C1 methods, even if only the C2 version is recorded in training data.
// This covers the cases of C2 deopt to C1 profiled version, or runtime
// policy disallowing C2 completely, or switching to C1 non-profiled version
// due to compiler overload.
// Additionally, this generates C1 limited profiled version for methods
// that only have C1 full profiled version.
return _comp_level <= high_top_level;
case CompLevel_full_profile:
// We do not include C1 full profiled methods at this time.
// TODO: See if it is profitable to do so.
return false;
case CompLevel_full_optimization:
// For C2 levels, we only care about the direct hits.
return _comp_level == high_top_level;
default:
assert(false, "Missed the case: %d", _comp_level);
}
Expand Down