Skip to content
Permalink
Browse files

8235673: [C1, C2] Split inlining control flags

Reviewed-by: neliasso, kvn, thartmann
  • Loading branch information
Martin Doerr
Martin Doerr committed May 18, 2020
1 parent d5bd523 commit 76b76654d2fcc2ee04766a9cd3cdddedbcd84fe9
@@ -44,7 +44,6 @@ define_pd_global(bool, TieredCompilation, false);
define_pd_global(intx, CompileThreshold, 1500 );

define_pd_global(intx, OnStackReplacePercentage, 933 );
define_pd_global(intx, FreqInlineSize, 325 );
define_pd_global(intx, NewSizeThreadIncrease, 4*K );
define_pd_global(intx, InitialCodeCacheSize, 160*K);
define_pd_global(intx, ReservedCodeCacheSize, 32*M );
@@ -45,7 +45,6 @@ define_pd_global(bool, TieredCompilation, false);
define_pd_global(intx, CompileThreshold, 1500 );

define_pd_global(intx, OnStackReplacePercentage, 933 );
define_pd_global(intx, FreqInlineSize, 325 );
define_pd_global(size_t, NewSizeThreadIncrease, 4*K );
define_pd_global(size_t, InitialCodeCacheSize, 160*K);
define_pd_global(size_t, ReservedCodeCacheSize, 32*M );
@@ -45,7 +45,6 @@ define_pd_global(intx, CompileThreshold, 1000);
define_pd_global(intx, OnStackReplacePercentage, 1400);
define_pd_global(bool, UseTLAB, true);
define_pd_global(bool, ProfileInterpreter, false);
define_pd_global(intx, FreqInlineSize, 325 );
define_pd_global(bool, ResizeTLAB, true);
define_pd_global(uintx, ReservedCodeCacheSize, 32*M);
define_pd_global(uintx, NonProfiledCodeHeapSize, 13*M );
@@ -46,7 +46,6 @@ define_pd_global(intx, CompileThreshold, 1000);
define_pd_global(intx, OnStackReplacePercentage, 1400);
define_pd_global(bool, UseTLAB, true);
define_pd_global(bool, ProfileInterpreter, false);
define_pd_global(intx, FreqInlineSize, 325);
define_pd_global(bool, ResizeTLAB, true);
define_pd_global(uintx, ReservedCodeCacheSize, 32*M);
define_pd_global(uintx, NonProfiledCodeHeapSize, 13*M);
@@ -44,7 +44,6 @@ define_pd_global(intx, CompileThreshold, 1000 ); // Design center r
define_pd_global(intx, OnStackReplacePercentage, 1400 );
define_pd_global(bool, UseTLAB, true );
define_pd_global(bool, ProfileInterpreter, false);
define_pd_global(intx, FreqInlineSize, 325 );
define_pd_global(bool, ResizeTLAB, true );
define_pd_global(uintx, ReservedCodeCacheSize, 32*M );
define_pd_global(uintx, NonProfiledCodeHeapSize, 13*M );
@@ -43,7 +43,6 @@ define_pd_global(bool, TieredCompilation, false);
define_pd_global(intx, CompileThreshold, 1500 );

define_pd_global(intx, OnStackReplacePercentage, 933 );
define_pd_global(intx, FreqInlineSize, 325 );
define_pd_global(size_t, NewSizeThreadIncrease, 4*K );
define_pd_global(uintx, InitialCodeCacheSize, 160*K);
define_pd_global(uintx, ReservedCodeCacheSize, 32*M );
@@ -701,10 +701,10 @@ GraphBuilder::ScopeData::ScopeData(ScopeData* parent)
if (parent != NULL) {
_max_inline_size = (intx) ((float) NestedInliningSizeRatio * (float) parent->max_inline_size() / 100.0f);
} else {
_max_inline_size = MaxInlineSize;
_max_inline_size = C1MaxInlineSize;
}
if (_max_inline_size < MaxTrivialSize) {
_max_inline_size = MaxTrivialSize;
if (_max_inline_size < C1MaxTrivialSize) {
_max_inline_size = C1MaxTrivialSize;
}
}

@@ -3817,18 +3817,24 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ign
// now perform tests that are based on flag settings
bool inlinee_by_directive = compilation()->directive()->should_inline(callee);
if (callee->force_inline() || inlinee_by_directive) {
if (inline_level() > MaxForceInlineLevel ) INLINE_BAILOUT("MaxForceInlineLevel");
if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("recursive inlining too deep");
if (inline_level() > MaxForceInlineLevel ) INLINE_BAILOUT("MaxForceInlineLevel");
if (recursive_inline_level(callee) > C1MaxRecursiveInlineLevel) INLINE_BAILOUT("recursive inlining too deep");

const char* msg = "";
if (callee->force_inline()) msg = "force inline by annotation";
if (inlinee_by_directive) msg = "force inline by CompileCommand";
print_inlining(callee, msg);
} else {
// use heuristic controls on inlining
if (inline_level() > MaxInlineLevel ) INLINE_BAILOUT("inlining too deep");
if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("recursive inlining too deep");
if (inline_level() > C1MaxInlineLevel ) INLINE_BAILOUT("inlining too deep");
int callee_recursive_level = recursive_inline_level(callee);
if (callee_recursive_level > C1MaxRecursiveInlineLevel ) INLINE_BAILOUT("recursive inlining too deep");
if (callee->code_size_for_inlining() > max_inline_size() ) INLINE_BAILOUT("callee is too large");
// Additional condition to limit stack usage for non-recursive calls.
if ((callee_recursive_level == 0) &&
(callee->max_stack() + callee->max_locals() - callee->size_of_parameters() > C1InlineStackLimit)) {
INLINE_BAILOUT("callee uses too much stack");
}

// don't inline throwable methods unless the inlining tree is rooted in a throwable class
if (callee->name() == ciSymbol::object_initializer_name() &&
@@ -170,6 +170,28 @@
develop(bool, UseTableRanges, true, \
"Faster versions of lookup table using ranges") \
\
product(intx, C1MaxInlineSize, 35, \
"The maximum bytecode size of a method to be inlined by C1") \
range(0, max_jint) \
\
product(intx, C1MaxTrivialSize, 6, \
"The maximum bytecode size of a trivial method to be inlined by " \
"C1") \
range(0, max_jint) \
\
product(intx, C1MaxInlineLevel, 9, \
"The maximum number of nested calls that are inlined by C1") \
range(0, max_jint) \
\
product(intx, C1MaxRecursiveInlineLevel, 1, \
"maximum number of nested recursive calls that are inlined by C1")\
range(0, max_jint) \
\
product(intx, C1InlineStackLimit, 10, \
"inlining only allowed for methods which don't exceed this " \
"number of expression stack and local slots") \
range(0, max_jint) \
\
develop(intx, NestedInliningSizeRatio, 90, \
"Percentage of prev. allowed inline size in recursive inlining") \
range(0, 100) \
@@ -278,6 +278,13 @@ void CompilerConfig::set_tiered_flags() {
}
#endif // INCLUDE_AOT
}

// Reduce stack usage due to inlining of methods which require much stack.
// (High tier compiler can inline better based on profiling information.)
if (FLAG_IS_DEFAULT(C1InlineStackLimit) &&
TieredStopAtLevel == CompLevel_full_optimization && !CompilationModeFlag::quick_only()) {
FLAG_SET_DEFAULT(C1InlineStackLimit, 5);
}
}

#endif // TIERED
@@ -52,7 +52,6 @@ define_pd_global(intx, CompileThreshold, 0);

define_pd_global(intx, OnStackReplacePercentage, 0);
define_pd_global(bool, ResizeTLAB, false);
define_pd_global(intx, FreqInlineSize, 0);
define_pd_global(size_t, NewSizeThreadIncrease, 4*K);
define_pd_global(bool, InlineClassNatives, true);
define_pd_global(bool, InlineUnsafeOps, true);
@@ -685,6 +685,35 @@
develop(bool, VerifyAliases, false, \
"perform extra checks on the results of alias analysis") \
\
product(intx, MaxInlineLevel, 15, \
"maximum number of nested calls that are inlined by high tier " \
"compiler") \
range(0, max_jint) \
\
product(intx, MaxRecursiveInlineLevel, 1, \
"maximum number of nested recursive calls that are inlined by " \
"high tier compiler") \
range(0, max_jint) \
\
product_pd(intx, InlineSmallCode, \
"Only inline already compiled methods if their code size is " \
"less than this") \
range(0, max_jint) \
\
product(intx, MaxInlineSize, 35, \
"The maximum bytecode size of a method to be inlined by high " \
"tier compiler") \
range(0, max_jint) \
\
product_pd(intx, FreqInlineSize, \
"The maximum bytecode size of a frequent method to be inlined") \
range(0, max_jint) \
\
product(intx, MaxTrivialSize, 6, \
"The maximum bytecode size of a trivial method to be inlined by " \
"high tier compiler") \
range(0, max_jint) \
\
product(bool, IncrementalInline, true, \
"do post parse inlining") \
\
@@ -570,6 +570,16 @@ static SpecialFlag const special_jvm_flags[] = {
{ "dup option", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
#endif

#ifndef COMPILER2
// These flags were generally available, but are C2 only, now.
{ "MaxInlineLevel", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) },
{ "MaxRecursiveInlineLevel", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) },
{ "InlineSmallCode", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) },
{ "MaxInlineSize", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) },
{ "FreqInlineSize", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) },
{ "MaxTrivialSize", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) },
#endif

{ NULL, JDK_Version(0), JDK_Version(0) }
};

@@ -1455,36 +1455,11 @@ const size_t minimumSymbolTableSize = 1024;
notproduct(intx, MaxSubklassPrintSize, 4, \
"maximum number of subklasses to print when printing klass") \
\
product(intx, MaxInlineLevel, 15, \
"maximum number of nested calls that are inlined") \
range(0, max_jint) \
\
product(intx, MaxRecursiveInlineLevel, 1, \
"maximum number of nested recursive calls that are inlined") \
range(0, max_jint) \
\
develop(intx, MaxForceInlineLevel, 100, \
"maximum number of nested calls that are forced for inlining " \
"(using CompileCommand or marked w/ @ForceInline)") \
range(0, max_jint) \
\
product_pd(intx, InlineSmallCode, \
"Only inline already compiled methods if their code size is " \
"less than this") \
range(0, max_jint) \
\
product(intx, MaxInlineSize, 35, \
"The maximum bytecode size of a method to be inlined") \
range(0, max_jint) \
\
product_pd(intx, FreqInlineSize, \
"The maximum bytecode size of a frequent method to be inlined") \
range(0, max_jint) \
\
product(intx, MaxTrivialSize, 6, \
"The maximum bytecode size of a trivial method to be inlined") \
range(0, max_jint) \
\
product(intx, MinInliningThreshold, 250, \
"The minimum invocation count a method needs to have to be " \
"inlined") \
@@ -27,7 +27,7 @@
* @bug 5091921
* @summary Sign flip issues in loop optimizer
*
* @run main/othervm -Xcomp -XX:MaxInlineSize=1
* @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:MaxInlineSize=1 -XX:C1MaxInlineSize=1
* -XX:CompileCommand=compileonly,compiler.c2.Test5091921::*
* compiler.c2.Test5091921
*/
@@ -26,7 +26,7 @@
* @bug 6792161
* @summary assert("No dead instructions after post-alloc")
*
* @run main/othervm/timeout=600 -Xcomp -XX:-TieredCompilation -XX:MaxInlineSize=120 compiler.c2.Test6792161
* @run main/othervm/timeout=600 -Xcomp -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:MaxInlineSize=120 compiler.c2.Test6792161
*/

package compiler.c2;
@@ -27,14 +27,14 @@
* @summary C2: NullPointerException/ClassCaseException is thrown when C2 with DeoptimizeALot is used
*
* @run main/othervm -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:+DeoptimizeALot
* -XX:+DoEscapeAnalysis -Xbatch -XX:InlineSmallCode=2000
* -XX:+DoEscapeAnalysis -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:InlineSmallCode=2000
* compiler.c2.Test6910605_2
*/

package compiler.c2;

/*
* Added InlineSmallCode=2000 to guaranty inlining of StringBuilder::append() to allow scalar replace StringBuilder object.
* Added InlineSmallCode=2000 to guarantee inlining of StringBuilder::append() to allow scalar replace StringBuilder object.
*
* original test: gc/gctests/StringGC
*/
@@ -33,8 +33,8 @@
public enum Command {
COMPILEONLY("compileonly", ".*", "-Xbatch"),
EXCLUDE("exclude", "", "-Xbatch"),
INLINE("inline", ".*", "-Xbatch", "-XX:InlineSmallCode=4000"),
DONTINLINE("dontinline", "", "-Xbatch", "-XX:InlineSmallCode=4000"),
INLINE("inline", ".*", "-Xbatch", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:InlineSmallCode=4000"),
DONTINLINE("dontinline", "", "-Xbatch", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:InlineSmallCode=4000"),
LOG("log", "", "-XX:+UnlockDiagnosticVMOptions",
"-XX:+LogCompilation", "-XX:LogFile=" + LogProcessor.LOG_FILE),
PRINT("print", ""),
@@ -37,6 +37,7 @@
* -Xmixed
* -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI
* -XX:+IgnoreUnrecognizedVMOptions
* -XX:MaxInlineSize=70
* -XX:MinInliningThreshold=0
* compiler.intrinsics.string.TestStringIntrinsics2
@@ -25,7 +25,7 @@
* @test
* @bug 8224162
* @summary Profile counter for a call site may overflow.
* @run main/othervm -Xbatch -XX:-UseOnStackReplacement -XX:MaxTrivialSize=0 compiler.profiling.TestProfileCounterOverflow
* @run main/othervm -Xbatch -XX:-UseOnStackReplacement -XX:+IgnoreUnrecognizedVMOptions -XX:MaxTrivialSize=0 -XX:C1MaxTrivialSize=0 compiler.profiling.TestProfileCounterOverflow
*/

package compiler.profiling;
@@ -29,7 +29,7 @@
* @modules java.base/jdk.internal.misc
* @modules java.base/jdk.internal.vm.annotation
*
* @run main/othervm -XX:MaxInlineLevel=2 -XX:CompileCommand=exclude,java/util/concurrent/locks/AbstractOwnableSynchronizer.setExclusiveOwnerThread ReservedStackTest
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:MaxInlineLevel=2 -XX:C1MaxInlineLevel=2 -XX:CompileCommand=exclude,java/util/concurrent/locks/AbstractOwnableSynchronizer.setExclusiveOwnerThread ReservedStackTest
*/

/* The exclusion of java.util.concurrent.locks.AbstractOwnableSynchronizer.setExclusiveOwnerThread()

0 comments on commit 76b7665

Please sign in to comment.