diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index 83967fe98b8..10b0f1f04a3 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -606,6 +606,7 @@ void CompilerConfig::ergo_initialize() { IncrementalInline = false; IncrementalInlineMH = false; IncrementalInlineVirtual = false; + StressIncrementalInlining = false; } #ifndef PRODUCT if (!IncrementalInline) { diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 5055cd48a96..3e466539c87 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -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 " \ diff --git a/src/hotspot/share/opto/callGenerator.cpp b/src/hotspot/share/opto/callGenerator.cpp index 971c37e6b45..ef7c572f582 100644 --- a/src/hotspot/share/opto/callGenerator.cpp +++ b/src/hotspot/share/opto/callGenerator.cpp @@ -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. diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index bf0b809b0de..9d899933c2e 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -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(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); } diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 67e790ffa23..af4eb6b1ee0 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -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); diff --git a/src/hotspot/share/opto/doCall.cpp b/src/hotspot/share/opto/doCall.cpp index ca86c806338..bad44ca46d4 100644 --- a/src/hotspot/share/opto/doCall.cpp +++ b/src/hotspot/share/opto/doCall.cpp @@ -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; } diff --git a/test/hotspot/jtreg/compiler/ciReplay/TestIncrementalInlining.java b/test/hotspot/jtreg/compiler/ciReplay/TestIncrementalInlining.java index 8bac1ea283c..43daab7a9b0 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/TestIncrementalInlining.java +++ b/test/hotspot/jtreg/compiler/ciReplay/TestIncrementalInlining.java @@ -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(); } diff --git a/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java b/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java index 79433ef355d..2d2bf14d76f 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java @@ -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 */ diff --git a/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java b/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java index 827eae7168b..678b2883b16 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java @@ -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