8319879: Stress mode to randomize incremental inlining decision

Reviewed-by: kvn, roland
This commit is contained in:
Tobias Hartmann 2023-11-21 07:18:04 +00:00
parent 099a8f5b2f
commit 303757b3a0
9 changed files with 19 additions and 12 deletions

View File

@ -606,6 +606,7 @@ void CompilerConfig::ergo_initialize() {
IncrementalInline = false;
IncrementalInlineMH = false;
IncrementalInlineVirtual = false;
StressIncrementalInlining = false;
}
#ifndef PRODUCT
if (!IncrementalInline) {

View File

@ -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 " \

View File

@ -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;
@ -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 {
@ -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;
@ -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.

View File

@ -839,7 +839,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);
@ -2262,7 +2262,7 @@ void Compile::Optimize() {
if (failing()) return;
if (AlwaysIncrementalInline) {
if (AlwaysIncrementalInline || StressIncrementalInlining) {
inline_incrementally(igvn);
}

View File

@ -1069,6 +1069,7 @@ private:
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);

View File

@ -185,7 +185,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
@ -204,14 +204,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;
}

View File

@ -68,6 +68,7 @@ public class TestIncrementalInlining extends InliningBase {
commandLineNormal.add("-XX:+WhiteBoxAPI");
commandLineNormal.add("-XX:MaxInlineLevel=2");
commandLineNormal.add("-XX:-AlwaysIncrementalInline");
commandLineNormal.add("-XX:-StressIncrementalInlining");
runTest();
}

View File

@ -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
*/

View File

@ -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