Skip to content

Commit

Permalink
8319879: Stress mode to randomize incremental inlining decision
Browse files Browse the repository at this point in the history
Backport-of: 303757b3a0d73329c954b28f08058fb60e5c9729
  • Loading branch information
GoeLin committed Jan 8, 2024
1 parent 307569f commit dfc9324
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/compiler/compilerDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ void CompilerConfig::ergo_initialize() {
IncrementalInline = false;
IncrementalInlineMH = false;
IncrementalInlineVirtual = false;
StressIncrementalInlining = false;
}
#ifndef PRODUCT
if (!IncrementalInline) {
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/opto/c2_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
product(bool, StressCCP, false, DIAGNOSTIC, \
"Randomize worklist traversal in CCP") \
\
product(bool, StressIncrementalInlining, false, DIAGNOSTIC, \
"Randomize the incremental inlining decision") \
\
product(uint, StressSeed, 0, DIAGNOSTIC, \
"Seed for randomized stress testing (if unset, a random one is " \
"generated). The seed is recorded in the compilation log, if " \
Expand Down
9 changes: 5 additions & 4 deletions src/hotspot/share/opto/callGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ bool LateInlineMHCallGenerator::do_late_inline_check(Compile* C, JVMState* jvms)
assert(!input_not_const, "sanity"); // shouldn't have been scheduled for inlining in the first place

if (cg != nullptr) {
assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline, "we're doing late inlining");
assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline || StressIncrementalInlining, "we're doing late inlining");
_inline_cg = cg;
C->dec_number_of_mh_late_inlines();
return true;
Expand Down Expand Up @@ -554,7 +554,7 @@ bool LateInlineVirtualCallGenerator::do_late_inline_check(Compile* C, JVMState*
true /*allow_intrinsics*/);

if (cg != nullptr) {
assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline, "we're doing late inlining");
assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline || StressIncrementalInlining, "we're doing late inlining");
_inline_cg = cg;
return true;
} else {
Expand Down Expand Up @@ -989,8 +989,9 @@ CallGenerator* CallGenerator::for_method_handle_call(JVMState* jvms, ciMethod* c
bool input_not_const;
CallGenerator* cg = CallGenerator::for_method_handle_inline(jvms, caller, callee, allow_inline, input_not_const);
Compile* C = Compile::current();
bool should_delay = C->should_delay_inlining();
if (cg != nullptr) {
if (AlwaysIncrementalInline) {
if (should_delay) {
return CallGenerator::for_late_inline(callee, cg);
} else {
return cg;
Expand All @@ -1001,7 +1002,7 @@ CallGenerator* CallGenerator::for_method_handle_call(JVMState* jvms, ciMethod* c
int call_site_count = caller->scale_count(profile.count());

if (IncrementalInlineMH && call_site_count > 0 &&
(input_not_const || !C->inlining_incrementally() || C->over_inlining_cutoff())) {
(should_delay || input_not_const || !C->inlining_incrementally() || C->over_inlining_cutoff())) {
return CallGenerator::for_mh_late_inline(caller, callee, input_not_const);
} else {
// Out-of-line call.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,

// If any phase is randomized for stress testing, seed random number
// generation and log the seed for repeatability.
if (StressLCM || StressGCM || StressIGVN || StressCCP) {
if (StressLCM || StressGCM || StressIGVN || StressCCP || StressIncrementalInlining) {
if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && directive->RepeatCompilationOption)) {
_stress_seed = static_cast<uint>(Ticks::now().nanoseconds());
FLAG_SET_ERGO(StressSeed, _stress_seed);
Expand Down Expand Up @@ -2244,7 +2244,7 @@ void Compile::Optimize() {

if (failing()) return;

if (AlwaysIncrementalInline) {
if (AlwaysIncrementalInline || StressIncrementalInlining) {
inline_incrementally(igvn);
}

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ class Compile : public Phase {
bool inline_incrementally_one();
void inline_incrementally_cleanup(PhaseIterGVN& igvn);
void inline_incrementally(PhaseIterGVN& igvn);
bool should_delay_inlining() { return AlwaysIncrementalInline || (StressIncrementalInlining && (random() % 2) == 0); }
void inline_string_calls(bool parse_time);
void inline_boxing_calls(PhaseIterGVN& igvn);
bool optimize_loops(PhaseIterGVN& igvn, LoopOptsMode mode);
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/opto/doCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool
// Try inlining a bytecoded method:
if (!call_does_dispatch) {
InlineTree* ilt = InlineTree::find_subtree_from_root(this->ilt(), jvms->caller(), jvms->method());
bool should_delay = AlwaysIncrementalInline;
bool should_delay = C->should_delay_inlining();
if (ilt->ok_to_inline(callee, jvms, profile, should_delay)) {
CallGenerator* cg = CallGenerator::for_inline(callee, expected_uses);
// For optimized virtual calls assert at runtime that receiver object
Expand All @@ -191,14 +191,14 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool
// Delay the inlining of this method to give us the
// opportunity to perform some high level optimizations
// first.
if (should_delay_string_inlining(callee, jvms)) {
if (should_delay) {
return CallGenerator::for_late_inline(callee, cg);
} else if (should_delay_string_inlining(callee, jvms)) {
return CallGenerator::for_string_late_inline(callee, cg);
} else if (should_delay_boxing_inlining(callee, jvms)) {
return CallGenerator::for_boxing_late_inline(callee, cg);
} else if (should_delay_vector_reboxing_inlining(callee, jvms)) {
return CallGenerator::for_vector_reboxing_late_inline(callee, cg);
} else if (should_delay) {
return CallGenerator::for_late_inline(callee, cg);
} else {
return cg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public static void main(String[] args) {
commandLineNormal.add("-XX:+WhiteBoxAPI");
commandLineNormal.add("-XX:MaxInlineLevel=2");
commandLineNormal.add("-XX:-AlwaysIncrementalInline");
commandLineNormal.add("-XX:-StressIncrementalInlining");
runTest();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* -Xmixed -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:CompileThreshold=1000
* -XX:+UnlockExperimentalVMOptions -XX:PerMethodTrapLimit=100 -XX:-StressReflectiveCode
* -XX:+UncommonNullCast -XX:-StressMethodHandleLinkerInlining -XX:TypeProfileLevel=0
* -XX:-AlwaysIncrementalInline
* -XX:-AlwaysIncrementalInline -XX:-StressIncrementalInlining
* -XX:CompileCommand=exclude,compiler.intrinsics.klass.CastNullCheckDroppingsTest::runTest
* compiler.intrinsics.klass.CastNullCheckDroppingsTest
*/
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/compiler/uncommontrap/Decompile.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* -Xbatch -XX:-UseOnStackReplacement -XX:-TieredCompilation
* -XX:+UnlockExperimentalVMOptions -XX:PerMethodTrapLimit=100 -XX:PerBytecodeTrapLimit=4
* -XX:TypeProfileLevel=0
* -XX:+IgnoreUnrecognizedVMOptions -XX:-AlwaysIncrementalInline
* -XX:+IgnoreUnrecognizedVMOptions -XX:-AlwaysIncrementalInline -XX:-StressIncrementalInlining
* -XX:CompileCommand=compileonly,compiler.uncommontrap.Decompile::uncommonTrap
* -XX:CompileCommand=inline,compiler.uncommontrap.Decompile*::foo
* compiler.uncommontrap.Decompile
Expand Down

1 comment on commit dfc9324

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.